* [FFmpeg-devel] fix for defect #10531
[not found] <d12d8732-bbfc-ad5e-a2b7-efe5e0261859@tiscali.it>
@ 2023-09-11 14:48 ` Francesco Carusi
0 siblings, 0 replies; only message in thread
From: Francesco Carusi @ 2023-09-11 14:48 UTC (permalink / raw)
To: ffmpeg-devel
[-- Attachment #1: Type: text/plain, Size: 910 bytes --]
I attached a patch for defect [ #10531: vf_drawtext causing font
rendering jitter after libharfbuz commit. ]
Before the patch the width of a text line was measured up to the
rightmost visible pixel of the last character.
Pros: the right padding specified with the boxborderw parameter is exact
with respect to the visible text
Cons: the width of a text line depends on the last character, even with
monospaced fonts
After the patch the width of the last character is set equal to the
width specified in the font file, which may include some empty space.
Pros: when using monospaced fonts the width of a line depends only on
the number of characters, this is also the standard behavior adopted by
other rendering strategies, e.g. in browsers
Cons: the user specified right padding may not be equal to the distance
between the background box right border and the rightmost visible pixel
of the text.
[-- Attachment #2: 0001-text-width-measurement-fixed.patch --]
[-- Type: text/plain, Size: 1622 bytes --]
From 62ccf3fc27f2a7df7b79a6241aae2e8d7fd8058d Mon Sep 17 00:00:00 2001
From: yethie <klimklim@tiscali.it>
Date: Thu, 7 Sep 2023 18:39:25 +0200
Subject: [PATCH 1/1] text width measurement fixed
---
libavfilter/vf_drawtext.c | 14 +++++++++++---
1 file changed, 11 insertions(+), 3 deletions(-)
diff --git a/libavfilter/vf_drawtext.c b/libavfilter/vf_drawtext.c
index ec8d215795..9e5f013c09 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;
--
2.30.2
[-- Attachment #3: Type: text/plain, Size: 251 bytes --]
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2023-09-11 14:48 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
[not found] <d12d8732-bbfc-ad5e-a2b7-efe5e0261859@tiscali.it>
2023-09-11 14:48 ` [FFmpeg-devel] fix for defect #10531 Francesco Carusi
Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
This inbox may be cloned and mirrored by anyone:
git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git
# If you have public-inbox 1.1+ installed, you may
# initialize and index your mirror using the following commands:
public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \
ffmpegdev@gitmailbox.com
public-inbox-index ffmpegdev
Example config snippet for mirrors.
AGPL code for this site: git clone https://public-inbox.org/public-inbox.git