[HarfBuzz] harfbuzz: Branch 'master' - 2 commits

Behdad Esfahbod behdad at kemper.freedesktop.org
Sun Aug 10 14:41:18 PDT 2014


 src/hb-coretext.cc |   32 ++++++++++++++------------------
 1 file changed, 14 insertions(+), 18 deletions(-)

New commits:
commit b9993d8d6d332994dfbd29e99ff8043622003417
Author: Behdad Esfahbod <behdad at behdad.org>
Date:   Sun Aug 10 17:40:24 2014 -0400

    [coretext] Fix assert on Yosemite
    
    Apparently those functions documented as sometimes returning NULL
    actually exercise that right in OS X 10.10 Yosemite.  The scratch
    was too small for that.  I *think* I fixed it, but haven't tested
    as I don't have Yosemite.

diff --git a/src/hb-coretext.cc b/src/hb-coretext.cc
index df3f33f..72cba8c 100644
--- a/src/hb-coretext.cc
+++ b/src/hb-coretext.cc
@@ -735,7 +735,11 @@ _hb_coretext_shape (hb_shape_plan_t    *shape_plan,
     if (num_glyphs == 0)
       continue;
 
-    buffer->ensure (buffer->len + num_glyphs);
+    /* Needed buffer size in case we end up using scratch buffer. */
+    unsigned int alt_size = (sizeof (CGGlyph) + sizeof (CGPoint) + sizeof (CFIndex)) / sizeof (hb_glyph_info_t) + 2;
+    buffer->ensure (MAX (buffer->len + num_glyphs, alt_size));
+    if (buffer->in_error)
+      FAIL ("Buffer resize failed");
 
     scratch = buffer->get_scratch_buffer (&scratch_size);
 
commit 087733dd66e17297ef0e53680fafe42c84884104
Author: Behdad Esfahbod <behdad at behdad.org>
Date:   Fri Apr 18 11:21:08 2014 -0700

    [coretext] Use CGFont as face_data

diff --git a/src/hb-coretext.cc b/src/hb-coretext.cc
index d92c6ba..df3f33f 100644
--- a/src/hb-coretext.cc
+++ b/src/hb-coretext.cc
@@ -27,6 +27,7 @@
  */
 
 #define HB_SHAPER coretext
+#define hb_coretext_shaper_face_data_t CGFont
 #include "hb-shaper-impl-private.hh"
 
 #include "hb-coretext.h"
@@ -77,10 +78,6 @@ HB_SHAPER_DATA_ENSURE_DECLARE(coretext, font)
  * shaper face data
  */
 
-struct hb_coretext_shaper_face_data_t {
-  CGFontRef cg_font;
-};
-
 static void
 release_data (void *info, const void *data, size_t size)
 {
@@ -93,13 +90,11 @@ release_data (void *info, const void *data, size_t size)
 hb_coretext_shaper_face_data_t *
 _hb_coretext_shaper_face_data_create (hb_face_t *face)
 {
-  hb_coretext_shaper_face_data_t *data = (hb_coretext_shaper_face_data_t *) calloc (1, sizeof (hb_coretext_shaper_face_data_t));
-  if (unlikely (!data))
-    return NULL;
+  hb_coretext_shaper_face_data_t *data = NULL;
 
   if (face->destroy == (hb_destroy_func_t) CGFontRelease)
   {
-    data->cg_font = CGFontRetain ((CGFontRef) face->user_data);
+    data = CGFontRetain ((CGFontRef) face->user_data);
   }
   else
   {
@@ -110,14 +105,12 @@ _hb_coretext_shaper_face_data_create (hb_face_t *face)
       DEBUG_MSG (CORETEXT, face, "Face has empty blob");
 
     CGDataProviderRef provider = CGDataProviderCreateWithData (blob, blob_data, blob_length, &release_data);
-    data->cg_font = CGFontCreateWithDataProvider (provider);
+    data = CGFontCreateWithDataProvider (provider);
     CGDataProviderRelease (provider);
   }
 
-  if (unlikely (!data->cg_font)) {
+  if (unlikely (!data)) {
     DEBUG_MSG (CORETEXT, face, "Face CGFontCreateWithDataProvider() failed");
-    free (data);
-    return NULL;
   }
 
   return data;
@@ -126,8 +119,7 @@ _hb_coretext_shaper_face_data_create (hb_face_t *face)
 void
 _hb_coretext_shaper_face_data_destroy (hb_coretext_shaper_face_data_t *data)
 {
-  CFRelease (data->cg_font);
-  free (data);
+  CFRelease (data);
 }
 
 CGFontRef
@@ -135,7 +127,7 @@ hb_coretext_face_get_cg_font (hb_face_t *face)
 {
   if (unlikely (!hb_coretext_shaper_face_data_ensure (face))) return NULL;
   hb_coretext_shaper_face_data_t *face_data = HB_SHAPER_DATA_GET (face);
-  return face_data->cg_font;
+  return face_data;
 }
 
 
@@ -159,7 +151,7 @@ _hb_coretext_shaper_font_data_create (hb_font_t *font)
   hb_face_t *face = font->face;
   hb_coretext_shaper_face_data_t *face_data = HB_SHAPER_DATA_GET (face);
 
-  data->ct_font = CTFontCreateWithGraphicsFont (face_data->cg_font, font->y_scale, NULL, NULL);
+  data->ct_font = CTFontCreateWithGraphicsFont (face_data, font->y_scale, NULL, NULL);
   if (unlikely (!data->ct_font)) {
     DEBUG_MSG (CORETEXT, font, "Font CTFontCreateWithGraphicsFont() failed");
     free (data);
@@ -698,7 +690,7 @@ _hb_coretext_shape (hb_shape_plan_t    *shape_plan,
     CFDictionaryRef attributes = CTRunGetAttributes (run);
     CTFontRef run_ct_font = static_cast<CTFontRef>(CFDictionaryGetValue (attributes, kCTFontAttributeName));
     CGFontRef run_cg_font = CTFontCopyGraphicsFont (run_ct_font, 0);
-    if (!CFEqual (run_cg_font, face_data->cg_font))
+    if (!CFEqual (run_cg_font, face_data))
     {
         CFRelease (run_cg_font);
 


More information about the HarfBuzz mailing list