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

Behdad Esfahbod behdad at kemper.freedesktop.org
Sun Aug 10 16:06:02 PDT 2014


 src/hb-coretext.cc |   31 +++++++++++++++++++++----------
 src/hb-private.hh  |    4 +++-
 2 files changed, 24 insertions(+), 11 deletions(-)

New commits:
commit 25f4fb9b56bb3f8bec821571c78f8829e40daa54
Author: Behdad Esfahbod <behdad at behdad.org>
Date:   Sun Aug 10 19:05:25 2014 -0400

    [coretext] Fix fallback detection
    
    Fixes http://github.com/behdad/harfbuzz/pull/36

diff --git a/src/hb-coretext.cc b/src/hb-coretext.cc
index 60a5d3b..9c7425b 100644
--- a/src/hb-coretext.cc
+++ b/src/hb-coretext.cc
@@ -661,10 +661,6 @@ _hb_coretext_shape (hb_shape_plan_t    *shape_plan,
     if (start != chars_len && last_range->font)
       CFAttributedStringSetAttribute (attr_string, CFRangeMake (start, chars_len - start),
 				      kCTFontAttributeName, last_range->font);
-
-    for (unsigned int i = 0; i < range_records.len; i++)
-      if (range_records[i].font)
-	CFRelease (range_records[i].font);
   }
 
   CTLineRef line = CTLineCreateWithAttributedString (attr_string);
@@ -689,11 +685,22 @@ _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))
+    if (!CFEqual (run_ct_font, font_data->ct_font))
     {
-        CFRelease (run_cg_font);
-
+      /* The run doesn't use our main font.  See if it uses any of our subfonts
+       * created to set font features...  Only if the font didn't match any of
+       * those, consider reject the font.  What we really want is to check the
+       * underlying CGFont, but apparently there's no safe way to do that.
+       * See: http://github.com/behdad/harfbuzz/pull/36 */
+      bool matched = false;
+      for (unsigned int i = 0; i < range_records.len; i++)
+	if (range_records[i].font && CFEqual (run_ct_font, range_records[i].font))
+	{
+	  matched = true;
+	  break;
+	}
+      if (!matched)
+      {
 	CFRange range = CTRunGetStringRange (run);
 	buffer->ensure (buffer->len + range.length);
 	if (unlikely (buffer->in_error))
@@ -728,8 +735,8 @@ _hb_coretext_shape (hb_shape_plan_t    *shape_plan,
 	    buffer->len++;
         }
         continue;
+      }
     }
-    CFRelease (run_cg_font);
 
     unsigned int num_glyphs = CTRunGetGlyphCount (run);
     if (num_glyphs == 0)
@@ -788,6 +795,10 @@ _hb_coretext_shape (hb_shape_plan_t    *shape_plan,
     }
   }
 
+  for (unsigned int i = 0; i < range_records.len; i++)
+    if (range_records[i].font)
+      CFRelease (range_records[i].font);
+
   buffer->clear_positions ();
 
   unsigned int count = buffer->len;
commit 77a7a53acef7de355116d488e7d64ff1d7e9e9e1
Author: Behdad Esfahbod <behdad at behdad.org>
Date:   Sun Aug 10 18:59:47 2014 -0400

    [coretext] Fix last range
    
    Test with:
    
    hb-view /Library/Fonts/Zapfino.ttf ZapfinoZapfino --features=-dlig[7:] --shaper=coretext

diff --git a/src/hb-coretext.cc b/src/hb-coretext.cc
index 844ad01..60a5d3b 100644
--- a/src/hb-coretext.cc
+++ b/src/hb-coretext.cc
@@ -659,7 +659,7 @@ _hb_coretext_shape (hb_shape_plan_t    *shape_plan,
       last_range = range;
     }
     if (start != chars_len && last_range->font)
-      CFAttributedStringSetAttribute (attr_string, CFRangeMake (start, chars_len - start - 1),
+      CFAttributedStringSetAttribute (attr_string, CFRangeMake (start, chars_len - start),
 				      kCTFontAttributeName, last_range->font);
 
     for (unsigned int i = 0; i < range_records.len; i++)
commit c2b151d95262a8dc2d2ce94e19ab0ef5b0c8f98d
Author: Behdad Esfahbod <behdad at behdad.org>
Date:   Sun Aug 10 18:52:07 2014 -0400

    Fix hb_in_range() for types smaller than int
    
    As exercised by hb-coretext .notdef code.

diff --git a/src/hb-private.hh b/src/hb-private.hh
index e97aab6..2709c0e 100644
--- a/src/hb-private.hh
+++ b/src/hb-private.hh
@@ -848,7 +848,9 @@ hb_in_range (T u, T lo, T hi)
    * to generate a warning than unused variables. */
   ASSERT_STATIC (sizeof (hb_assert_unsigned_t<T>) >= 0);
 
-  return (u - lo) <= (hi - lo);
+  /* The casts below are important as if T is smaller than int,
+   * the subtract results will become a signed int! */
+  return (T)(u - lo) <= (T)(hi - lo);
 }
 
 template <typename T> static inline bool


More information about the HarfBuzz mailing list