[HarfBuzz] harfbuzz: Branch 'master'

Behdad Esfahbod behdad at kemper.freedesktop.org
Tue Sep 11 12:41:48 UTC 2018


 src/hb-ft.cc |    9 +++++++++
 1 file changed, 9 insertions(+)

New commits:
commit 383060cc3354e12611dec3082a6fe08fdb25f652
Author: Behdad Esfahbod <behdad at behdad.org>
Date:   Tue Sep 11 14:41:19 2018 +0200

    [ft] Invalidate advance cache if font size changed

diff --git a/src/hb-ft.cc b/src/hb-ft.cc
index 121b7159..3aed7188 100644
--- a/src/hb-ft.cc
+++ b/src/hb-ft.cc
@@ -69,6 +69,8 @@ struct hb_ft_font_t
   int load_flags;
   bool symbol; /* Whether selected cmap is symbol cmap. */
   bool unref; /* Whether to destroy ft_face when done. */
+
+  mutable int cached_x_scale;
   mutable hb_advance_cache_t advance_cache;
 };
 
@@ -86,6 +88,7 @@ _hb_ft_font_create (FT_Face ft_face, bool symbol, bool unref)
 
   ft_font->load_flags = FT_LOAD_DEFAULT | FT_LOAD_NO_HINTING;
 
+  ft_font->cached_x_scale = 0;
   ft_font->advance_cache.init ();
 
   return ft_font;
@@ -247,6 +250,12 @@ hb_ft_get_glyph_h_advances (hb_font_t* font, void* font_data,
   int load_flags = ft_font->load_flags;
   int mult = font->x_scale < 0 ? -1 : +1;
 
+  if (font->x_scale != ft_font->cached_x_scale)
+  {
+    ft_font->advance_cache.clear ();
+    ft_font->cached_x_scale = font->x_scale;
+  }
+
   for (unsigned int i = 0; i < count; i++)
   {
     FT_Fixed v = 0;


More information about the HarfBuzz mailing list