]> granicus.if.org Git - libass/commitdiff
shaper: correctly handle @font advance
authorGrigori Goronzy <greg@blackbox>
Sun, 3 Mar 2013 22:45:26 +0000 (23:45 +0100)
committerGrigori Goronzy <greg@blackbox>
Sun, 3 Mar 2013 22:45:26 +0000 (23:45 +0100)
The code was confusing glyph index and unicode codepoint index.

Fixes issue 94.

libass/ass_shaper.c

index 9434f432088878035a26b95b020789844a86fd08..6ffc083aded37962b3267a85ca9c07f6638b7bd6 100644 (file)
@@ -203,6 +203,12 @@ get_cached_metrics(struct ass_shaper_metrics_data *metrics, FT_Face face,
             return NULL;
 
         memcpy(&new_val.metrics, &face->glyph->metrics, sizeof(FT_Glyph_Metrics));
+
+        // if @font rendering is enabled and the glyph should be rotated,
+        // make cached_h_advance pick up the right advance later
+        if (metrics->vertical && glyph >= VERTICAL_LOWER_BOUND)
+            new_val.metrics.horiAdvance = new_val.metrics.vertAdvance;
+
         val = ass_cache_put(metrics->metrics_cache, &metrics->hash_key, &new_val);
     }
 
@@ -234,9 +240,6 @@ cached_h_advance(hb_font_t *font, void *font_data, hb_codepoint_t glyph,
     if (!metrics)
         return 0;
 
-    if (metrics_priv->vertical && glyph > VERTICAL_LOWER_BOUND)
-        return metrics->metrics.vertAdvance;
-
     return metrics->metrics.horiAdvance;
 }