From: Francesco Carusi <klimklim@tiscali.it>
To: ffmpeg-devel <ffmpeg-devel@ffmpeg.org>
Subject: [FFmpeg-devel] fix for defect #10531
Date: Mon, 11 Sep 2023 16:48:17 +0200
Message-ID: <7fc3d15e-ab08-8e7b-cd68-2308e548906d@tiscali.it> (raw)
In-Reply-To: <d12d8732-bbfc-ad5e-a2b7-efe5e0261859@tiscali.it>
[-- 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".
parent reply other threads:[~2023-09-11 14:48 UTC|newest]
Thread overview: expand[flat|nested] mbox.gz Atom feed
[parent not found: <d12d8732-bbfc-ad5e-a2b7-efe5e0261859@tiscali.it>]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=7fc3d15e-ab08-8e7b-cd68-2308e548906d@tiscali.it \
--to=klimklim@tiscali.it \
--cc=ffmpeg-devel@ffmpeg.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
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