History

avfilter/vf_drawtext: fix text width measurement

yethie committed 3 years ago

Commit aeff5bc1 parent da784b81 file · +11 −3Browse files

Showing the changes to libavfilter (1 of 1 file). Show all

Unified · Split

libavfilter/vf_drawtext.c+11−3
@@ -1757,9 +1757,17 @@ continue_on_failed2: · 1756 unmodified lines
17571757 first_min_x64 = FFMIN(glyph->bbox.xMin, first_min_x64);
17581758 }
17591759 if (t == hb->glyph_count - 1) {
1760− w64 += glyph->bbox.xMax;
1761− last_max_x64 = FFMAX(glyph->bbox.xMax, last_max_x64);
1762− cur_line->offset_right64 = glyph->bbox.xMax;
1760+ // The following code measures the width of the line up to the last
1761+ // character's horizontal advance
1762+ int last_char_width = hb->glyph_pos[t].x_advance;
1763+
1764+ // The following code measures the width of the line up to the rightmost
1765+ // visible pixel of the last character
1766+ // int last_char_width = glyph->bbox.xMax;
1767+
1768+ w64 += last_char_width;
1769+ last_max_x64 = FFMAX(last_char_width, last_max_x64);
1770+ cur_line->offset_right64 = last_char_width;
17631771 } else {
17641772 if (is_tab) {
17651773 int size = s->blank_advance64 * s->tabsize;

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t