diff options
author | Grigori Goronzy <greg@blackbox> | 2011-07-22 01:54:00 +0200 |
---|---|---|
committer | Grigori Goronzy <greg@blackbox> | 2011-07-22 01:54:00 +0200 |
commit | 4bb1e2df3689f4f404f7ef1640b9fac7b58f2e94 (patch) | |
tree | 707cf64464f299125b669abd6d6e630729b05a51 | |
parent | 29638467c702fd528327da34cf6d96cf9dbf486a (diff) | |
download | libass-4bb1e2df3689f4f404f7ef1640b9fac7b58f2e94.tar.bz2 libass-4bb1e2df3689f4f404f7ef1640b9fac7b58f2e94.tar.xz |
Update HarfBuzz' font metrics
-rw-r--r-- | libass/ass_shaper.c | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/libass/ass_shaper.c b/libass/ass_shaper.c index e6745da..5f2ec50 100644 --- a/libass/ass_shaper.c +++ b/libass/ass_shaper.c @@ -140,6 +140,20 @@ static void set_run_features(ASS_Shaper *shaper, GlyphInfo *info) } /** + * \brief Update HarfBuzz's idea of font metrics + * \param hb_font HarfBuzz font + * \param face associated FreeType font face + */ +static void update_hb_size(hb_font_t *hb_font, FT_Face face) +{ + hb_font_set_scale (hb_font, + ((uint64_t) face->size->metrics.x_scale * (uint64_t) face->units_per_EM) >> 16, + ((uint64_t) face->size->metrics.y_scale * (uint64_t) face->units_per_EM) >> 16); + hb_font_set_ppem (hb_font, face->size->metrics.x_ppem, + face->size->metrics.y_ppem); +} + +/** * \brief Retrieve HarfBuzz font from cache. * Create it from FreeType font, if needed. * \param info glyph cluster @@ -153,12 +167,14 @@ static hb_font_t *get_hb_font(GlyphInfo *info) if (!font->shaper_priv) font->shaper_priv = calloc(sizeof(ASS_ShaperFontData), 1); + hb_fonts = font->shaper_priv->fonts; if (!hb_fonts[info->face_index]) 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); + update_hb_size(hb_fonts[info->face_index], font->faces[info->face_index]); return hb_fonts[info->face_index]; } |