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

Behdad Esfahbod behdad at kemper.freedesktop.org
Tue Jan 28 14:30:32 PST 2014


 src/hb-coretext.cc |   22 ++++++++++++++++------
 1 file changed, 16 insertions(+), 6 deletions(-)

New commits:
commit c29993a181c2139eaec97b5f6225824040ca3ac9
Author: Behdad Esfahbod <behdad at behdad.org>
Date:   Tue Jan 28 17:29:42 2014 -0500

    [coretext] Handle surrogate pairs when generating notdef glyphs
    
    Fixes github.com/behdad/harfbuzz/pull/19

diff --git a/src/hb-coretext.cc b/src/hb-coretext.cc
index f247c08..87dd779 100644
--- a/src/hb-coretext.cc
+++ b/src/hb-coretext.cc
@@ -591,7 +591,6 @@ _hb_coretext_shape (hb_shape_plan_t    *shape_plan,
 
   CFMutableAttributedStringRef attr_string = CFAttributedStringCreateMutable (NULL, chars_len);
   CFAttributedStringReplaceString (attr_string, CFRangeMake (0, 0), string_ref);
-  CFRelease (string_ref);
   CFAttributedStringSetAttribute (attr_string, CFRangeMake (0, chars_len),
 				  kCTFontAttributeName, font_data->ct_font);
 
@@ -671,23 +670,33 @@ _hb_coretext_shape (hb_shape_plan_t    *shape_plan,
 	if (buffer->in_error)
 	  FAIL ("Buffer resize failed");
 	hb_glyph_info_t *info = buffer->info + buffer->len;
-	buffer->len += range.length;
 
 	CGGlyph notdef = 0;
 	double advance = CTFontGetAdvancesForGlyphs (font_data->ct_font, kCTFontHorizontalOrientation, &notdef, NULL, 1);
 
-        for (CFIndex j = 0; j < range.length; j++)
+        for (CFIndex j = range.location; j < range.location + range.length; j++)
 	{
+	    UniChar ch = CFStringGetCharacterAtIndex (string_ref, j);
+	    if (hb_in_range<UniChar> (ch, 0xDC00, 0xDFFF) && range.location < j)
+	    {
+	      ch = CFStringGetCharacterAtIndex (string_ref, j - 1);
+	      if (hb_in_range<UniChar> (ch, 0xD800, 0xDBFF))
+	        /* This is the second of a surrogate pair.  Don't need .notdef
+		 * for this one. */
+	        continue;
+	    }
+
             info->codepoint = notdef;
 	    /* TODO We have to fixup clusters later.  See vis_clusters in
 	     * hb-uniscribe.cc for example. */
-            info->cluster = range.location + j;
+            info->cluster = j;
 
             info->mask = advance;
             info->var1.u32 = 0;
             info->var2.u32 = 0;
 
 	    info++;
+	    buffer->len++;
         }
         continue;
     }
@@ -796,6 +805,7 @@ _hb_coretext_shape (hb_shape_plan_t    *shape_plan,
     }
   }
 
+  CFRelease (string_ref);
   CFRelease (line);
 
   return true;
commit 748b2782e4898420003a3bbc041dcccbe9e3edc2
Author: Behdad Esfahbod <behdad at behdad.org>
Date:   Tue Jan 28 17:10:05 2014 -0500

    [coretext] Minor optimization

diff --git a/src/hb-coretext.cc b/src/hb-coretext.cc
index 25e4055..f247c08 100644
--- a/src/hb-coretext.cc
+++ b/src/hb-coretext.cc
@@ -673,11 +673,11 @@ _hb_coretext_shape (hb_shape_plan_t    *shape_plan,
 	hb_glyph_info_t *info = buffer->info + buffer->len;
 	buffer->len += range.length;
 
+	CGGlyph notdef = 0;
+	double advance = CTFontGetAdvancesForGlyphs (font_data->ct_font, kCTFontHorizontalOrientation, &notdef, NULL, 1);
+
         for (CFIndex j = 0; j < range.length; j++)
 	{
-            CGGlyph notdef = 0;
-            double advance = CTFontGetAdvancesForGlyphs (font_data->ct_font, kCTFontHorizontalOrientation, &notdef, NULL, 1);
-
             info->codepoint = notdef;
 	    /* TODO We have to fixup clusters later.  See vis_clusters in
 	     * hb-uniscribe.cc for example. */


More information about the HarfBuzz mailing list