summaryrefslogtreecommitdiffstats
path: root/libass
diff options
context:
space:
mode:
authorGrigori Goronzy <greg@blackbox>2009-08-12 01:45:39 +0200
committerGrigori Goronzy <greg@blackbox>2009-08-12 01:50:59 +0200
commitceefa4d7517a611de4c27c7de416a4ca7d22eeef (patch)
treed81b8a9036e8aa5ce604907a9be09e2aa1a9bfa9 /libass
parentf3b3c6897e5cb7df6b40885c772e564d7ab5c82d (diff)
downloadlibass-ceefa4d7517a611de4c27c7de416a4ca7d22eeef.tar.bz2
libass-ceefa4d7517a611de4c27c7de416a4ca7d22eeef.tar.xz
Fix advance for italic to non-italic style changes
After a italic to non-italic style change the space between the glyphs is sometimes wrongly calculated, especially if the font doesn't have an italic version and FreeType falls back to oblique glyphs. In such cases, add additional space to the glyph's advance to make up for the slant of the glyph; the amount is calculated from the glyph's bbox.
Diffstat (limited to 'libass')
-rw-r--r--libass/ass_render.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/libass/ass_render.c b/libass/ass_render.c
index f970f96..a7557fe 100644
--- a/libass/ass_render.c
+++ b/libass/ass_render.c
@@ -2576,6 +2576,15 @@ ass_render_event(ASS_Renderer *render_priv, ASS_Event *event,
get_outline_glyph(render_priv, code,
text_info->glyphs + text_info->length, drawing);
+ // Add additional space after italic to nonitalic style changes
+ if (text_info->length &&
+ text_info->glyphs[text_info->length - 1].hash_key.italic &&
+ !render_priv->state.italic) {
+ GlyphInfo *og = &text_info->glyphs[text_info->length - 1];
+ int advmax = FFMAX(0, og->bbox.xMax - og->advance.x);
+ pen.x += advmax;
+ }
+
text_info->glyphs[text_info->length].pos.x = pen.x;
text_info->glyphs[text_info->length].pos.y = pen.y;