PR #22589 opened by Zhao Zhili (quink)
URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/22589
Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/22589.patch

GET_UTF8 advances the pointer past the newline byte before the
newline check, so shape_text_hb receives text that includes the
newline character. Since HarfBuzz does not treat U+000A as
default-ignorable, it gets shaped into a .notdef glyph.

Fixes #21565

Reported-by: scriptituk <[email protected]>
Signed-off-by: Zhao Zhili <[email protected]>


>From 2dcdd7b42f80263c59dc61fe58ded22f4d35140d Mon Sep 17 00:00:00 2001
From: Zhao Zhili <[email protected]>
Date: Mon, 23 Mar 2026 20:10:12 +0800
Subject: [PATCH] avfilter/vf_drawtext: fix newline rendered as .notdef glyph

GET_UTF8 advances the pointer past the newline byte before the
newline check, so shape_text_hb receives text that includes the
newline character. Since HarfBuzz does not treat U+000A as
default-ignorable, it gets shaped into a .notdef glyph.

Fixes #21565

Reported-by: scriptituk <[email protected]>
Signed-off-by: Zhao Zhili <[email protected]>
---
 libavfilter/vf_drawtext.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/libavfilter/vf_drawtext.c b/libavfilter/vf_drawtext.c
index 2812de37f5..5d2a301859 100644
--- a/libavfilter/vf_drawtext.c
+++ b/libavfilter/vf_drawtext.c
@@ -1452,13 +1452,14 @@ continue_on_failed:
             s->tab_clusters[tab_idx++] = i;
             *p = ' ';
         }
+        const uint8_t *p_before = p;
         GET_UTF8(code, *p ? *p++ : 0, code = 0xfffd; goto 
continue_on_failed2;);
 continue_on_failed2:
         if (ff_is_newline(code) || code == 0) {
             TextLine *cur_line = &s->lines[line_count];
             HarfbuzzData *hb = &cur_line->hb_data;
             cur_line->cluster_offset = line_offset;
-            ret = shape_text_hb(s, hb, start, p - start);
+            ret = shape_text_hb(s, hb, start, p_before - start);
             if (ret != 0) {
                 goto done;
             }
-- 
2.52.0

_______________________________________________
ffmpeg-devel mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to