aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoryethie <klimklim@tiscali.it>2023-09-07 18:39:25 +0200
committerPaul B Mahol <onemda@gmail.com>2023-09-12 19:33:09 +0200
commitaeff5bcba092583cb85b823bb5dbc14099591408 (patch)
tree357bec5e6d73ebdedc98219c9172a607b413f8d8
parentda784b81a671677342c54e32add39d7d9ce15563 (diff)
downloadffmpeg-aeff5bcba092583cb85b823bb5dbc14099591408.tar.gz
avfilter/vf_drawtext: fix text width measurement
-rw-r--r--libavfilter/vf_drawtext.c14
1 files changed, 11 insertions, 3 deletions
diff --git a/libavfilter/vf_drawtext.c b/libavfilter/vf_drawtext.c
index ec8d215795..c5477cbff1 100644
--- a/libavfilter/vf_drawtext.c
+++ b/libavfilter/vf_drawtext.c
@@ -1757,9 +1757,17 @@ continue_on_failed2:
first_min_x64 = FFMIN(glyph->bbox.xMin, first_min_x64);
}
if (t == hb->glyph_count - 1) {
- w64 += glyph->bbox.xMax;
- last_max_x64 = FFMAX(glyph->bbox.xMax, last_max_x64);
- cur_line->offset_right64 = glyph->bbox.xMax;
+ // The following code measures the width of the line up to the last
+ // character's horizontal advance
+ int last_char_width = hb->glyph_pos[t].x_advance;
+
+ // The following code measures the width of the line up to the rightmost
+ // visible pixel of the last character
+ // int last_char_width = glyph->bbox.xMax;
+
+ w64 += last_char_width;
+ last_max_x64 = FFMAX(last_char_width, last_max_x64);
+ cur_line->offset_right64 = last_char_width;
} else {
if (is_tab) {
int size = s->blank_advance64 * s->tabsize;