[HarfBuzz] harfbuzz: Branch 'master'

Behdad Esfahbod behdad at kemper.freedesktop.org
Sat Dec 2 23:04:03 UTC 2017


 src/hb-coretext.cc |   55 +++++++++++++++++++++++++++++++++--------------------
 src/hb-coretext.h  |    3 ++
 2 files changed, 38 insertions(+), 20 deletions(-)

New commits:
commit d5e29303db47a1868fa9b044ca61e146f882179c
Author: Behdad Esfahbod <behdad at behdad.org>
Date:   Tue Nov 28 23:11:34 2017 -0800

    [coretext] Add hb_coretext_font_create()
    
    Fixes https://github.com/harfbuzz/harfbuzz/issues/628
    
    New API:
    hb_coretext_font_create()

diff --git a/src/hb-coretext.cc b/src/hb-coretext.cc
index 41eb7d6a..2dd10d2d 100644
--- a/src/hb-coretext.cc
+++ b/src/hb-coretext.cc
@@ -81,21 +81,12 @@ _hb_cg_font_release (void *data)
   CGFontRelease ((CGFontRef) data);
 }
 
-hb_face_t *
-hb_coretext_face_create (CGFontRef cg_font)
-{
-  return hb_face_create_for_tables (reference_table, CGFontRetain (cg_font), _hb_cg_font_release);
-}
 
 HB_SHAPER_DATA_ENSURE_DEFINE(coretext, face)
 HB_SHAPER_DATA_ENSURE_DEFINE_WITH_CONDITION(coretext, font,
 	fabs (CTFontGetSize((CTFontRef) data) - coretext_font_size (font->ptem)) <= .5
 )
 
-/*
- * shaper face data
- */
-
 static CTFontDescriptorRef
 get_last_resort_font_desc (void)
 {
@@ -267,6 +258,12 @@ _hb_coretext_shaper_face_data_destroy (hb_coretext_shaper_face_data_t *data)
   CFRelease ((CGFontRef) data);
 }
 
+hb_face_t *
+hb_coretext_face_create (CGFontRef cg_font)
+{
+  return hb_face_create_for_tables (reference_table, CGFontRetain (cg_font), _hb_cg_font_release);
+}
+
 /*
  * Since: 0.9.10
  */
@@ -278,10 +275,6 @@ hb_coretext_face_get_cg_font (hb_face_t *face)
 }
 
 
-/*
- * shaper font data
- */
-
 hb_coretext_shaper_font_data_t *
 _hb_coretext_shaper_font_data_create (hb_font_t *font)
 {
@@ -306,6 +299,35 @@ _hb_coretext_shaper_font_data_destroy (hb_coretext_shaper_font_data_t *data)
   CFRelease ((CTFontRef) data);
 }
 
+/*
+ * Since: 1.7.2
+ */
+hb_font_t *
+hb_coretext_font_create (CTFontRef ct_font)
+{
+  CGFontRef cg_font = CTFontCopyGraphicsFont (ct_font, 0);
+  hb_face_t *face = hb_coretext_face_create (cg_font);
+  CFRelease (cg_font);
+  hb_font_t *font = hb_font_create (face);
+  hb_face_destroy (face);
+
+  if (unlikely (hb_object_is_inert (font)))
+    return font;
+
+  /* Let there be dragons here... */
+  HB_SHAPER_DATA_GET (font) = (hb_coretext_shaper_font_data_t *) CFRetain (ct_font);
+
+  return font;
+}
+
+CTFontRef
+hb_coretext_font_get_ct_font (hb_font_t *font)
+{
+  if (unlikely (!hb_coretext_shaper_font_data_ensure (font))) return nullptr;
+  return (CTFontRef) HB_SHAPER_DATA_GET (font);
+}
+
+
 
 /*
  * shaper shape_plan data
@@ -328,13 +350,6 @@ _hb_coretext_shaper_shape_plan_data_destroy (hb_coretext_shaper_shape_plan_data_
 {
 }
 
-CTFontRef
-hb_coretext_font_get_ct_font (hb_font_t *font)
-{
-  if (unlikely (!hb_coretext_shaper_font_data_ensure (font))) return nullptr;
-  return (CTFontRef)HB_SHAPER_DATA_GET (font);
-}
-
 
 /*
  * shaper
diff --git a/src/hb-coretext.h b/src/hb-coretext.h
index c9136ff4..4b0a6f01 100644
--- a/src/hb-coretext.h
+++ b/src/hb-coretext.h
@@ -48,6 +48,9 @@ HB_BEGIN_DECLS
 HB_EXTERN hb_face_t *
 hb_coretext_face_create (CGFontRef cg_font);
 
+HB_EXTERN hb_font_t *
+hb_coretext_font_create (CTFontRef ct_font);
+
 
 HB_EXTERN CGFontRef
 hb_coretext_face_get_cg_font (hb_face_t *face);


More information about the HarfBuzz mailing list