From ceefa4d7517a611de4c27c7de416a4ca7d22eeef Mon Sep 17 00:00:00 2001 From: Grigori Goronzy Date: Wed, 12 Aug 2009 01:45:39 +0200 Subject: 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. --- libass/ass_render.c | 9 +++++++++ 1 file changed, 9 insertions(+) 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; -- cgit v1.2.3