diff options
-rw-r--r-- | libass/ass_shaper.c | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/libass/ass_shaper.c b/libass/ass_shaper.c index 395f9c5..d5a970e 100644 --- a/libass/ass_shaper.c +++ b/libass/ass_shaper.c @@ -185,7 +185,7 @@ static void update_hb_size(hb_font_t *hb_font, FT_Face face) GlyphMetricsHashValue * get_cached_metrics(struct ass_shaper_metrics_data *metrics, FT_Face face, - hb_codepoint_t glyph) + hb_codepoint_t unicode, hb_codepoint_t glyph) { GlyphMetricsHashValue *val; @@ -204,7 +204,7 @@ get_cached_metrics(struct ass_shaper_metrics_data *metrics, FT_Face face, // 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) + if (metrics->vertical && unicode >= VERTICAL_LOWER_BOUND) new_val.metrics.horiAdvance = new_val.metrics.vertAdvance; val = ass_cache_put(metrics->metrics_cache, &metrics->hash_key, &new_val); @@ -218,12 +218,17 @@ get_glyph(hb_font_t *font, void *font_data, hb_codepoint_t unicode, hb_codepoint_t variation, hb_codepoint_t *glyph, void *user_data) { FT_Face face = font_data; + struct ass_shaper_metrics_data *metrics_priv = user_data; if (variation) *glyph = FT_Face_GetCharVariantIndex(face, ass_font_index_magic(face, unicode), variation); else *glyph = FT_Get_Char_Index(face, ass_font_index_magic(face, unicode)); + // rotate glyph advances for @fonts while we still know the Unicode codepoints + if (*glyph != 0) + get_cached_metrics(metrics_priv, face, unicode, glyph); + return *glyph != 0; } @@ -233,7 +238,7 @@ cached_h_advance(hb_font_t *font, void *font_data, hb_codepoint_t glyph, { FT_Face face = font_data; struct ass_shaper_metrics_data *metrics_priv = user_data; - GlyphMetricsHashValue *metrics = get_cached_metrics(metrics_priv, face, glyph); + GlyphMetricsHashValue *metrics = get_cached_metrics(metrics_priv, face, 0, glyph); if (!metrics) return 0; @@ -247,7 +252,7 @@ cached_v_advance(hb_font_t *font, void *font_data, hb_codepoint_t glyph, { FT_Face face = font_data; struct ass_shaper_metrics_data *metrics_priv = user_data; - GlyphMetricsHashValue *metrics = get_cached_metrics(metrics_priv, face, glyph); + GlyphMetricsHashValue *metrics = get_cached_metrics(metrics_priv, face, 0, glyph); if (!metrics) return 0; @@ -269,7 +274,7 @@ cached_v_origin(hb_font_t *font, void *font_data, hb_codepoint_t glyph, { FT_Face face = font_data; struct ass_shaper_metrics_data *metrics_priv = user_data; - GlyphMetricsHashValue *metrics = get_cached_metrics(metrics_priv, face, glyph); + GlyphMetricsHashValue *metrics = get_cached_metrics(metrics_priv, face, 0, glyph); if (!metrics) return 0; @@ -306,7 +311,7 @@ cached_extents(hb_font_t *font, void *font_data, hb_codepoint_t glyph, { FT_Face face = font_data; struct ass_shaper_metrics_data *metrics_priv = user_data; - GlyphMetricsHashValue *metrics = get_cached_metrics(metrics_priv, face, glyph); + GlyphMetricsHashValue *metrics = get_cached_metrics(metrics_priv, face, 0, glyph); if (!metrics) return 0; |