summaryrefslogtreecommitdiffstats
path: root/libass
diff options
context:
space:
mode:
authorrcombs <rcombs@rcombs.me>2020-05-27 12:49:59 -0500
committerOleg Oshmyan <chortos@inbox.lv>2020-07-05 22:13:51 +0300
commitdbb76629145567458c683823a1c20a3c6c2aae64 (patch)
tree7aab264cbdf62478bb4d231a6601d6c47018e34b /libass
parent82ae68b9bc7cfba9a633444c4b7fdabf1d3a7f6c (diff)
downloadlibass-dbb76629145567458c683823a1c20a3c6c2aae64.tar.bz2
libass-dbb76629145567458c683823a1c20a3c6c2aae64.tar.xz
ass_shaper: fix harfbuzz deprecation warning; closes #320
Diffstat (limited to 'libass')
-rw-r--r--libass/ass_shaper.c30
1 files changed, 23 insertions, 7 deletions
diff --git a/libass/ass_shaper.c b/libass/ass_shaper.c
index 1a75ef1..80e78aa 100644
--- a/libass/ass_shaper.c
+++ b/libass/ass_shaper.c
@@ -267,16 +267,30 @@ size_t ass_glyph_metrics_construct(void *key, void *value, void *priv)
}
static hb_bool_t
-get_glyph(hb_font_t *font, void *font_data, hb_codepoint_t unicode,
- hb_codepoint_t variation, hb_codepoint_t *glyph, void *user_data)
+get_glyph_nominal(hb_font_t *font, void *font_data, hb_codepoint_t unicode,
+ 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));
+ *glyph = FT_Get_Char_Index(face, ass_font_index_magic(face, unicode));
+ if (!*glyph)
+ return false;
+
+ // rotate glyph advances for @fonts while we still know the Unicode codepoints
+ FT_Glyph_Metrics *metrics = get_cached_metrics(metrics_priv, unicode, *glyph);
+ ass_cache_dec_ref(metrics);
+ return true;
+}
+
+static hb_bool_t
+get_glyph_variation(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;
+
+ *glyph = FT_Face_GetCharVariantIndex(face, ass_font_index_magic(face, unicode), variation);
if (!*glyph)
return false;
@@ -423,7 +437,9 @@ static hb_font_t *get_hb_font(ASS_Shaper *shaper, GlyphInfo *info)
hb_font_funcs_t *funcs = hb_font_funcs_create();
font->shaper_priv->font_funcs[info->face_index] = funcs;
- hb_font_funcs_set_glyph_func(funcs, get_glyph,
+ hb_font_funcs_set_nominal_glyph_func(funcs, get_glyph_nominal,
+ metrics, NULL);
+ hb_font_funcs_set_variation_glyph_func(funcs, get_glyph_variation,
metrics, NULL);
hb_font_funcs_set_glyph_h_advance_func(funcs, cached_h_advance,
metrics, NULL);