[HarfBuzz] harfbuzz: Branch 'master'
Behdad Esfahbod
behdad at kemper.freedesktop.org
Thu Oct 12 08:34:13 UTC 2017
docs/harfbuzz-sections.txt | 1 +
src/hb-ft.cc | 15 +++++++++++++--
src/hb-ft.h | 8 +++++++-
3 files changed, 21 insertions(+), 3 deletions(-)
New commits:
commit 4e4781319b36bba154f3e5d4eb678945d8f6b4fc
Author: Behdad Esfahbod <behdad at behdad.org>
Date: Thu Oct 12 10:33:16 2017 +0200
[ft] Add hb_ft_font_changed()
When the font size or variations settings on underlying FT_Face change,
one can call hb_ft_font_changed() and continue using hb_font created using
hb_ft_font_create().
Fixes https://github.com/behdad/harfbuzz/issues/559
New API:
hb_ft_font_changed()
diff --git a/docs/harfbuzz-sections.txt b/docs/harfbuzz-sections.txt
index 6d86d941..06a78f5f 100644
--- a/docs/harfbuzz-sections.txt
+++ b/docs/harfbuzz-sections.txt
@@ -291,6 +291,7 @@ hb_ft_face_create_cached
hb_ft_face_create_referenced
hb_ft_font_create
hb_ft_font_create_referenced
+hb_ft_font_changed
hb_ft_font_get_face
hb_ft_font_set_load_flags
hb_ft_font_get_load_flags
diff --git a/src/hb-ft.cc b/src/hb-ft.cc
index c560b219..83af9942 100644
--- a/src/hb-ft.cc
+++ b/src/hb-ft.cc
@@ -610,6 +610,19 @@ hb_ft_font_create (FT_Face ft_face,
font = hb_font_create (face);
hb_face_destroy (face);
_hb_ft_font_set_funcs (font, ft_face, false);
+ hb_ft_font_changed (font);
+ return font;
+}
+
+void
+hb_ft_font_changed (hb_font_t *font)
+{
+ if (font->destroy != _hb_ft_font_destroy)
+ return;
+
+ hb_ft_font_t *ft_font = (hb_ft_font_t *) font->user_data;
+ FT_Face ft_face = ft_font->ft_face;
+
hb_font_set_scale (font,
(int) (((uint64_t) ft_face->size->metrics.x_scale * (uint64_t) ft_face->units_per_EM + (1u<<15)) >> 16),
(int) (((uint64_t) ft_face->size->metrics.y_scale * (uint64_t) ft_face->units_per_EM + (1u<<15)) >> 16));
@@ -640,8 +653,6 @@ hb_ft_font_create (FT_Face ft_face,
free (mm_var);
}
#endif
-
- return font;
}
/**
diff --git a/src/hb-ft.h b/src/hb-ft.h
index dc8ef855..94013eeb 100644
--- a/src/hb-ft.h
+++ b/src/hb-ft.h
@@ -116,7 +116,13 @@ hb_ft_font_set_load_flags (hb_font_t *font, int load_flags);
HB_EXTERN int
hb_ft_font_get_load_flags (hb_font_t *font);
-/* Makes an hb_font_t use FreeType internally to implement font functions. */
+/* Call when size or variations settings on underlying FT_Face change. */
+HB_EXTERN void
+hb_ft_font_changed (hb_font_t *font);
+
+/* Makes an hb_font_t use FreeType internally to implement font functions.
+ * Note: this internally creates an FT_Face. Use it when you create your
+ * hb_face_t using hb_face_create(). */
HB_EXTERN void
hb_ft_font_set_funcs (hb_font_t *font);
More information about the HarfBuzz
mailing list