]> granicus.if.org Git - libass/commitdiff
Fix advance for italic to non-italic style changes
authorGrigori Goronzy <greg@blackbox>
Tue, 11 Aug 2009 23:45:39 +0000 (01:45 +0200)
committerGrigori Goronzy <greg@blackbox>
Tue, 11 Aug 2009 23:50:59 +0000 (01:50 +0200)
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.

libass/ass_render.c

index f970f9638ed1036806f80bb2be516e085bb4f63d..a7557fe9ed9e3e2ea68097790e3e8b22e6d7f23e 100644 (file)
@@ -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;