]> granicus.if.org Git - libass/commitdiff
shaper: fix run-specific font size
authorGrigori Goronzy <greg@blackbox>
Sat, 16 Jul 2011 01:00:41 +0000 (03:00 +0200)
committerGrigori Goronzy <greg@blackbox>
Sat, 16 Jul 2011 01:00:41 +0000 (03:00 +0200)
Make sure to set the font size for every run, as needed, to get metrics
(advance/offset) for the right size.

libass/ass_font.c
libass/ass_font.h
libass/ass_render.c
libass/ass_shaper.c

index 954040e0dc1edb8273d4bcbdbc8d62c7006c0303..d65b9763279ed04c36a0f03ac6d8e1e330633479 100644 (file)
@@ -90,8 +90,6 @@ static int find_font(ASS_Library *library, char *name)
     return -1;
 }
 
-static void face_set_size(FT_Face face, double size);
-
 static void buggy_font_workaround(FT_Face face)
 {
     // Some fonts have zero Ascender/Descender fields in 'hhea' table.
@@ -160,7 +158,7 @@ static int add_face(void *fc_priv, ASS_Font *font, uint32_t ch)
     buggy_font_workaround(face);
 
     font->faces[font->n_faces++] = face;
-    face_set_size(face, font->size);
+    ass_face_set_size(face, font->size);
     free(path);
     return font->n_faces - 1;
 }
@@ -216,7 +214,7 @@ void ass_font_set_transform(ASS_Font *font, double scale_x,
     }
 }
 
-static void face_set_size(FT_Face face, double size)
+void ass_face_set_size(FT_Face face, double size)
 {
     TT_HoriHeader *hori = FT_Get_Sfnt_Table(face, ft_sfnt_hhea);
     TT_OS2 *os2 = FT_Get_Sfnt_Table(face, ft_sfnt_os2);
@@ -251,7 +249,7 @@ void ass_font_set_size(ASS_Font *font, double size)
     if (font->size != size) {
         font->size = size;
         for (i = 0; i < font->n_faces; ++i)
-            face_set_size(font->faces[i], size);
+            ass_face_set_size(font->faces[i], size);
     }
 }
 
index 06fda21d775e65b348b73e86ec820a820d1b17a7..725a7c148be8e0ecaa59e80880bfec79a4ea2eaa 100644 (file)
@@ -60,6 +60,7 @@ ASS_Font *ass_font_new(Cache *font_cache, ASS_Library *library,
                        ASS_FontDesc *desc);
 void ass_font_set_transform(ASS_Font *font, double scale_x,
                             double scale_y, FT_Vector *v);
+void ass_face_set_size(FT_Face face, double size);
 void ass_font_set_size(ASS_Font *font, double size);
 void ass_font_get_asc_desc(ASS_Font *font, uint32_t ch, int *asc,
                            int *desc);
index 3d23e29d3081137e531c193fb85b4f5e86ab025c..0ac1ff992a72216d7aca0bf5aee6aa5d42dbf2bb 100644 (file)
@@ -1139,9 +1139,8 @@ get_outline_glyph(ASS_Renderer *render_priv, GlyphInfo *info)
             info->desc = drawing->desc;
             ass_drawing_free(drawing);
         } else {
-            double size_scaled = ensure_font_size(render_priv,
-                    info->font_size * render_priv->font_scale);
-            ass_font_set_size(info->font, size_scaled);
+            ass_face_set_size(info->font->faces[info->face_index],
+                    info->font_size);
             ass_font_set_transform(info->font, info->scale_x,
                     info->scale_y, NULL);
             // symbol might have been changed. re-get it.
@@ -1797,7 +1796,8 @@ ass_render_event(ASS_Renderer *render_priv, ASS_Event *event,
             render_priv->state.effect_timing;
         glyphs[text_info->length].effect_skip_timing =
             render_priv->state.effect_skip_timing;
-        glyphs[text_info->length].font_size = render_priv->state.font_size;
+        glyphs[text_info->length].font_size = ensure_font_size(render_priv,
+                    render_priv->state.font_size * render_priv->font_scale);
         glyphs[text_info->length].be = render_priv->state.be;
         glyphs[text_info->length].blur = render_priv->state.blur;
         glyphs[text_info->length].shadow_x = render_priv->state.shadow_x;
index 55bcaae7d544f70927d2f47c2bffe83d7d3fe2e3..9796dc55d92f65d1291dfcdb718f2de5a429e4da 100644 (file)
@@ -158,6 +158,8 @@ static hb_font_t *get_hb_font(GlyphInfo *info)
         hb_fonts[info->face_index] =
             hb_ft_font_create(font->faces[info->face_index], NULL);
 
+    ass_face_set_size(font->faces[info->face_index], info->font_size);
+
     return hb_fonts[info->face_index];
 }
 
@@ -307,7 +309,6 @@ void ass_shaper_find_runs(ASS_Shaper *shaper, ASS_Renderer *render_priv,
         // set size and get glyph index
         double size_scaled = ensure_font_size(render_priv,
                 info->font_size * render_priv->font_scale);
-        ass_font_set_size(info->font, size_scaled);
         ass_font_get_index(render_priv->fontconfig_priv, info->font,
                 info->symbol, &info->face_index, &info->glyph_index);
         // shape runs share the same font face and size