summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGrigori Goronzy <greg@blackbox>2009-08-31 02:52:03 +0200
committerGrigori Goronzy <greg@blackbox>2009-08-31 05:25:24 +0200
commita69a6eca41f633bad80cbaf6488788fda9ec5c82 (patch)
tree30615629e87bc971967fab6ca18172d4ec92788b
parent7a3f45457b04977ea3d8a59ad66f802fadd43fcb (diff)
downloadlibass-a69a6eca41f633bad80cbaf6488788fda9ec5c82.tar.bz2
libass-a69a6eca41f633bad80cbaf6488788fda9ec5c82.tar.xz
Calculate glyph slant width correctly
If a glyph is wider than its advance width for italic to non-italic style changes, assume it was obliqued by FreeType's FT_GlyphSlot_Oblique function and offset the next glyph accordingly.
-rw-r--r--libass/ass_render.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/libass/ass_render.c b/libass/ass_render.c
index b595881..f67cba6 100644
--- a/libass/ass_render.c
+++ b/libass/ass_render.c
@@ -2737,9 +2737,6 @@ ass_render_event(ASS_Renderer *render_priv, ASS_Event *event,
get_outline_glyph(render_priv, code,
text_info->glyphs + text_info->length, drawing);
- text_info->glyphs[text_info->length].pos.x = pen.x;
- text_info->glyphs[text_info->length].pos.y = pen.y;
-
// Add additional space after italic to non-italic style changes
if (text_info->length &&
text_info->glyphs[text_info->length - 1].hash_key.italic &&
@@ -2748,9 +2745,15 @@ ass_render_event(ASS_Renderer *render_priv, ASS_Event *event,
GlyphInfo *og = &text_info->glyphs[back];
while (og->bbox.xMax - og->bbox.xMin == 0 && og->hash_key.italic)
og = &text_info->glyphs[--back];
- pen.x += FFMAX(0, og->bbox.xMax - og->advance.x);
+ if (og->bbox.xMax > og->advance.x) {
+ // The FreeType oblique slants by 6/16
+ pen.x += og->bbox.yMax * 0.375;
+ }
}
+ text_info->glyphs[text_info->length].pos.x = pen.x;
+ text_info->glyphs[text_info->length].pos.y = pen.y;
+
pen.x += text_info->glyphs[text_info->length].advance.x;
pen.x += double_to_d6(render_priv->state.hspacing *
render_priv->font_scale