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

Behdad Esfahbod behdad at kemper.freedesktop.org
Wed Jan 28 12:42:48 PST 2015


 src/hb-coretext.cc |   37 +++++++++++++++++++++++++++++--------
 src/hb-ft.cc       |    8 ++++++++
 src/hb-ot-shape.cc |    2 +-
 3 files changed, 38 insertions(+), 9 deletions(-)

New commits:
commit 7888a6b07a9922cedd3e0d235959058e0011357b
Author: Behdad Esfahbod <behdad at behdad.org>
Date:   Wed Jan 28 12:40:40 2015 -0800

    [ft] Handle negative scales with vertical writing

diff --git a/src/hb-ft.cc b/src/hb-ft.cc
index f57f566..322f93a 100644
--- a/src/hb-ft.cc
+++ b/src/hb-ft.cc
@@ -118,6 +118,9 @@ hb_ft_get_glyph_v_advance (hb_font_t *font HB_UNUSED,
   if (unlikely (FT_Get_Advance (ft_face, glyph, load_flags, &v)))
     return 0;
 
+  if (font->y_scale < 0)
+    v = -v;
+
   /* Note: FreeType's vertical metrics grows downward while other FreeType coordinates
    * have a Y growing upward.  Hence the extra negation. */
   return (-v + (1<<9)) >> 10;
@@ -154,6 +157,11 @@ hb_ft_get_glyph_v_origin (hb_font_t *font HB_UNUSED,
   *x = ft_face->glyph->metrics.horiBearingX -   ft_face->glyph->metrics.vertBearingX;
   *y = ft_face->glyph->metrics.horiBearingY - (-ft_face->glyph->metrics.vertBearingY);
 
+  if (font->x_scale < 0)
+    *x = -*x;
+  if (font->y_scale < 0)
+    *y = -*y;
+
   return true;
 }
 
commit 982d94eaa2a377616f22f39427e5ed9f1ce43263
Author: Behdad Esfahbod <behdad at behdad.org>
Date:   Wed Jan 28 10:51:33 2015 -0800

    [coretext] Don't generate notdef glyph for default-ignorables
    
    As discovered on Chrome Mac:
    https://code.google.com/p/chromium/issues/detail?id=452326

diff --git a/src/hb-coretext.cc b/src/hb-coretext.cc
index 4a1e14c..4a45175 100644
--- a/src/hb-coretext.cc
+++ b/src/hb-coretext.cc
@@ -897,6 +897,8 @@ retry:
 		   * for this one. */
 		  continue;
 	      }
+	      if (buffer->unicode->is_default_ignorable (ch))
+	        continue;
 
 	      info->codepoint = notdef;
 	      info->cluster = log_clusters[j];
diff --git a/src/hb-ot-shape.cc b/src/hb-ot-shape.cc
index a0b503a..07adb04 100644
--- a/src/hb-ot-shape.cc
+++ b/src/hb-ot-shape.cc
@@ -676,7 +676,7 @@ hb_ot_hide_default_ignorables (hb_ot_shape_context_t *c)
 	pos[i].y_advance = 0;
       }
       else
-	continue; /* Delete it. */
+	continue; /* Delete it. XXX Merge clusters? */
     }
     if (j != i)
     {
commit 6917a045fd8d16952cad75fda8b291b11e1d3564
Author: Behdad Esfahbod <behdad at behdad.org>
Date:   Wed Jan 28 10:43:32 2015 -0800

    [coretext] Unbreak glyph positioning in presence of notdef runs
    
    As discovered on Chrome Mac:
    https://code.google.com/p/chromium/issues/detail?id=452326
    
    This was originally broken in:
    
    	commit 5a0eed3b50629be4826e4e9428f2c3255195395d
    	Author: Behdad Esfahbod <behdad at behdad.org>
    	Date:   Mon Aug 11 23:47:16 2014 -0400
    
    	    [coretext] Implement vertical shaping

diff --git a/src/hb-coretext.cc b/src/hb-coretext.cc
index 16e069d..4a1e14c 100644
--- a/src/hb-coretext.cc
+++ b/src/hb-coretext.cc
@@ -787,6 +787,7 @@ retry:
 
     buffer->len = 0;
     uint32_t status_and = ~0, status_or = 0;
+    double advances_so_far = 0;
 
     const CFRange range_all = CFRangeMake (0, 0);
 
@@ -797,6 +798,10 @@ retry:
       status_or  |= run_status;
       status_and &= run_status;
       DEBUG_MSG (CORETEXT, run, "CTRunStatus: %x", run_status);
+      double run_advance = CTRunGetTypographicBounds (run, range_all, NULL, NULL, NULL);
+      if (HB_DIRECTION_IS_VERTICAL (buffer->props.direction))
+	  run_advance = -run_advance;
+      DEBUG_MSG (CORETEXT, run, "Run advance: %g", run_advance);
 
       /* CoreText does automatic font fallback (AKA "cascading") for  characters
        * not supported by the requested font, and provides no way to turn it off,
@@ -905,6 +910,7 @@ retry:
 	  }
 	  if (HB_DIRECTION_IS_BACKWARD (buffer->props.direction))
 	    buffer->reverse_range (old_len, buffer->len);
+	  advances_so_far += run_advance;
 	  continue;
 	}
       }
@@ -934,7 +940,7 @@ retry:
   scratch_size = scratch_size_saved; \
   scratch = scratch_saved;
 
-      {
+      { /* Setup glyphs */
         SCRATCH_SAVE();
 	const CGGlyph* glyphs = USE_PTR ? CTRunGetGlyphsPtr (run) : NULL;
 	if (!glyphs) {
@@ -958,6 +964,11 @@ retry:
 	SCRATCH_RESTORE();
       }
       {
+        /* Setup positions.
+	 * Note that CoreText does not return advances for glyphs.  As such,
+	 * for all but last glyph, we use the delta position to next glyph as
+	 * advance (in the advance direction only), and for last glyph we set
+	 * whatever is needed to make the whole run's advance add up. */
         SCRATCH_SAVE();
 	const CGPoint* positions = USE_PTR ? CTRunGetPositionsPtr (run) : NULL;
 	if (!positions) {
@@ -965,34 +976,42 @@ retry:
 	  CTRunGetPositions (run, range_all, position_buf);
 	  positions = position_buf;
 	}
-	double run_advance = CTRunGetTypographicBounds (run, range_all, NULL, NULL, NULL);
-	DEBUG_MSG (CORETEXT, run, "Run advance: %g", run_advance);
 	hb_glyph_info_t *info = run_info;
 	CGFloat x_mult = font_data->x_mult, y_mult = font_data->y_mult;
 	if (HB_DIRECTION_IS_HORIZONTAL (buffer->props.direction))
 	{
+	  hb_position_t x_offset = (positions[0].x - advances_so_far) * x_mult;
 	  for (unsigned int j = 0; j < num_glyphs; j++)
 	  {
-	    double advance = (j + 1 < num_glyphs ? positions[j + 1].x : positions[0].x + run_advance) - positions[j].x;
+	    double advance;
+	    if (likely (j + 1 < num_glyphs))
+	      advance = positions[j + 1].x - positions[j].x;
+	    else /* last glyph */
+	      advance = run_advance - (positions[j].x - positions[0].x);
 	    info->mask = advance * x_mult;
-	    info->var1.u32 = positions[0].x * x_mult; /* Yes, zero. */
+	    info->var1.u32 = x_offset;
 	    info->var2.u32 = positions[j].y * y_mult;
 	    info++;
 	  }
 	}
 	else
 	{
-	  run_advance = -run_advance;
+	  hb_position_t y_offset = (positions[0].y - advances_so_far) * y_mult;
 	  for (unsigned int j = 0; j < num_glyphs; j++)
 	  {
-	    double advance = (j + 1 < num_glyphs ? positions[j + 1].y : positions[0].y + run_advance) - positions[j].y;
+	    double advance;
+	    if (likely (j + 1 < num_glyphs))
+	      advance = positions[j + 1].y - positions[j].y;
+	    else /* last glyph */
+	      advance = run_advance - (positions[j].y - positions[0].y);
 	    info->mask = advance * y_mult;
 	    info->var1.u32 = positions[j].x * x_mult;
-	    info->var2.u32 = positions[0].y * y_mult; /* Yes, zero. */
+	    info->var2.u32 = y_offset;
 	    info++;
 	  }
 	}
 	SCRATCH_RESTORE();
+	advances_so_far += run_advance;
       }
 #undef SCRATCH_RESTORE
 #undef SCRATCH_SAVE


More information about the HarfBuzz mailing list