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

Behdad Esfahbod behdad at kemper.freedesktop.org
Wed Jan 10 04:27:56 UTC 2018


 src/hb-font-private.hh         |    8 ++++++-
 src/hb-ot-layout-gpos-table.hh |   46 ++++++++++++++++++++---------------------
 src/hb-private.hh              |    1 
 test/shaping/Makefile.am       |    8 +++----
 4 files changed, 35 insertions(+), 28 deletions(-)

New commits:
commit 4c982b4867707fcd2259b344b06e5bba8dd0c1e3
Author: Behdad Esfahbod <behdad at behdad.org>
Date:   Wed Jan 10 05:26:55 2018 +0100

    [test] Whitelist one more passing test

diff --git a/test/shaping/Makefile.am b/test/shaping/Makefile.am
index a73fa2a1..0cd4503d 100644
--- a/test/shaping/Makefile.am
+++ b/test/shaping/Makefile.am
@@ -108,6 +108,7 @@ TESTS = \
 	data/text-rendering-tests/tests/HVAR-2.tests \
 	data/text-rendering-tests/tests/KERN-1.tests \
 	data/text-rendering-tests/tests/KERN-2.tests \
+	data/text-rendering-tests/tests/SHBALI-3.tests \
 	data/text-rendering-tests/tests/SHKNDA-1.tests \
 	$(NULL)
 
@@ -120,7 +121,6 @@ DISABLED_TESTS = \
 	data/text-rendering-tests/tests/SHARAN-1.tests # Rounding difference \
 	data/text-rendering-tests/tests/SHBALI-1.tests # Rounding difference \
 	data/text-rendering-tests/tests/SHBALI-2.tests # Rounding difference \
-	data/text-rendering-tests/tests/SHBALI-3.tests # Rounding difference \
 	data/text-rendering-tests/tests/SHKNDA-2.tests # Rounding difference \
 	data/text-rendering-tests/tests/SHKNDA-3.tests # Rounding difference \
 	$(NULL)
commit 188ee6e5eeef3c63c332cfa30795d37da1bc1682
Author: Behdad Esfahbod <behdad at behdad.org>
Date:   Wed Jan 10 05:13:47 2018 +0100

    Calculate anchor positions in float, then round
    
    Hoping to reduce rounding error, to make tests happier...
    No luck.

diff --git a/src/hb-font-private.hh b/src/hb-font-private.hh
index d391f462..992152f1 100644
--- a/src/hb-font-private.hh
+++ b/src/hb-font-private.hh
@@ -128,6 +128,8 @@ struct hb_font_t {
   inline hb_position_t em_scale_y (int16_t v) { return em_scale (v, y_scale); }
   inline hb_position_t em_scalef_x (float v) { return em_scalef (v, this->x_scale); }
   inline hb_position_t em_scalef_y (float v) { return em_scalef (v, this->y_scale); }
+  inline float em_fscale_x (int16_t v) { return em_fscale (v, x_scale); }
+  inline float em_fscale_y (int16_t v) { return em_fscale (v, y_scale); }
   inline hb_position_t em_scale_dir (int16_t v, hb_direction_t direction)
   { return em_scale (v, dir_scale (direction)); }
 
@@ -543,6 +545,10 @@ struct hb_font_t {
   {
     return (hb_position_t) round (v * scale / face->get_upem ());
   }
+  inline float em_fscale (int16_t v, int scale)
+  {
+    return (float) v * scale / face->get_upem ();
+  }
 };
 
 #define HB_SHAPER_DATA_CREATE_FUNC_EXTRA_ARGS
diff --git a/src/hb-ot-layout-gpos-table.hh b/src/hb-ot-layout-gpos-table.hh
index c8ea6e05..836a2e24 100644
--- a/src/hb-ot-layout-gpos-table.hh
+++ b/src/hb-ot-layout-gpos-table.hh
@@ -233,11 +233,11 @@ struct ValueFormat : HBUINT16
 struct AnchorFormat1
 {
   inline void get_anchor (hb_apply_context_t *c, hb_codepoint_t glyph_id HB_UNUSED,
-			  hb_position_t *x, hb_position_t *y) const
+			  float *x, float *y) const
   {
     hb_font_t *font = c->font;
-    *x = font->em_scale_x (xCoordinate);
-    *y = font->em_scale_y (yCoordinate);
+    *x = font->em_fscale_x (xCoordinate);
+    *y = font->em_fscale_y (yCoordinate);
   }
 
   inline bool sanitize (hb_sanitize_context_t *c) const
@@ -257,7 +257,7 @@ struct AnchorFormat1
 struct AnchorFormat2
 {
   inline void get_anchor (hb_apply_context_t *c, hb_codepoint_t glyph_id,
-			  hb_position_t *x, hb_position_t *y) const
+			  float *x, float *y) const
   {
     hb_font_t *font = c->font;
     unsigned int x_ppem = font->x_ppem;
@@ -267,8 +267,8 @@ struct AnchorFormat2
 
     ret = (x_ppem || y_ppem) &&
 	   font->get_glyph_contour_point_for_origin (glyph_id, anchorPoint, HB_DIRECTION_LTR, &cx, &cy);
-    *x = ret && x_ppem ? cx : font->em_scale_x (xCoordinate);
-    *y = ret && y_ppem ? cy : font->em_scale_y (yCoordinate);
+    *x = ret && x_ppem ? cx : font->em_fscale_x (xCoordinate);
+    *y = ret && y_ppem ? cy : font->em_fscale_y (yCoordinate);
   }
 
   inline bool sanitize (hb_sanitize_context_t *c) const
@@ -289,11 +289,11 @@ struct AnchorFormat2
 struct AnchorFormat3
 {
   inline void get_anchor (hb_apply_context_t *c, hb_codepoint_t glyph_id HB_UNUSED,
-			  hb_position_t *x, hb_position_t *y) const
+			  float *x, float *y) const
   {
     hb_font_t *font = c->font;
-    *x = font->em_scale_x (xCoordinate);
-    *y = font->em_scale_y (yCoordinate);
+    *x = font->em_fscale_x (xCoordinate);
+    *y = font->em_fscale_y (yCoordinate);
 
     if (font->x_ppem || font->num_coords)
       *x += (this+xDeviceTable).get_x_delta (font, c->var_store);
@@ -326,7 +326,7 @@ struct AnchorFormat3
 struct Anchor
 {
   inline void get_anchor (hb_apply_context_t *c, hb_codepoint_t glyph_id,
-			  hb_position_t *x, hb_position_t *y) const
+			  float *x, float *y) const
   {
     *x = *y = 0;
     switch (u.format) {
@@ -430,15 +430,15 @@ struct MarkArray : ArrayOf<MarkRecord>	/* Array of MarkRecords--in Coverage orde
      * return false such that the subsequent subtables have a chance at it. */
     if (unlikely (!found)) return_trace (false);
 
-    hb_position_t mark_x, mark_y, base_x, base_y;
+    float mark_x, mark_y, base_x, base_y;
 
     buffer->unsafe_to_break (glyph_pos, buffer->idx);
     mark_anchor.get_anchor (c, buffer->cur().codepoint, &mark_x, &mark_y);
     glyph_anchor.get_anchor (c, buffer->info[glyph_pos].codepoint, &base_x, &base_y);
 
     hb_glyph_position_t &o = buffer->cur_pos();
-    o.x_offset = base_x - mark_x;
-    o.y_offset = base_y - mark_y;
+    o.x_offset = round (base_x - mark_x);
+    o.y_offset = round (base_y - mark_y);
     o.attach_type() = ATTACH_TYPE_MARK;
     o.attach_chain() = (int) glyph_pos - (int) buffer->idx;
     buffer->scratch_flags |= HB_BUFFER_SCRATCH_FLAG_HAS_GPOS_ATTACHMENT;
@@ -919,7 +919,7 @@ struct CursivePosFormat1
     unsigned int j = skippy_iter.idx;
 
     buffer->unsafe_to_break (i, j);
-    hb_position_t entry_x, entry_y, exit_x, exit_y;
+    float entry_x, entry_y, exit_x, exit_y;
     (this+this_record.exitAnchor).get_anchor (c, buffer->info[i].codepoint, &exit_x, &exit_y);
     (this+next_record.entryAnchor).get_anchor (c, buffer->info[j].codepoint, &entry_x, &entry_y);
 
@@ -929,32 +929,32 @@ struct CursivePosFormat1
     /* Main-direction adjustment */
     switch (c->direction) {
       case HB_DIRECTION_LTR:
-	pos[i].x_advance  =  exit_x + pos[i].x_offset;
+	pos[i].x_advance  = round (exit_x) + pos[i].x_offset;
 
-	d = entry_x + pos[j].x_offset;
+	d = round (entry_x) + pos[j].x_offset;
 	pos[j].x_advance -= d;
 	pos[j].x_offset  -= d;
 	break;
       case HB_DIRECTION_RTL:
-	d = exit_x + pos[i].x_offset;
+	d = round (exit_x) + pos[i].x_offset;
 	pos[i].x_advance -= d;
 	pos[i].x_offset  -= d;
 
-	pos[j].x_advance  =  entry_x + pos[j].x_offset;
+	pos[j].x_advance  = round (entry_x) + pos[j].x_offset;
 	break;
       case HB_DIRECTION_TTB:
-	pos[i].y_advance  =  exit_y + pos[i].y_offset;
+	pos[i].y_advance  = round (exit_y) + pos[i].y_offset;
 
-	d = entry_y + pos[j].y_offset;
+	d = round (entry_y) + pos[j].y_offset;
 	pos[j].y_advance -= d;
 	pos[j].y_offset  -= d;
 	break;
       case HB_DIRECTION_BTT:
-	d = exit_y + pos[i].y_offset;
+	d = round (exit_y) + pos[i].y_offset;
 	pos[i].y_advance -= d;
 	pos[i].y_offset  -= d;
 
-	pos[j].y_advance  =  entry_y;
+	pos[j].y_advance  = round (entry_y);
 	break;
       case HB_DIRECTION_INVALID:
       default:
commit 0b28e1199d62765db4e855756b96022e423dcc17
Author: Behdad Esfahbod <behdad at behdad.org>
Date:   Wed Jan 10 05:02:42 2018 +0100

    [test] Whitelist one more passing test

diff --git a/test/shaping/Makefile.am b/test/shaping/Makefile.am
index 0950bdb3..a73fa2a1 100644
--- a/test/shaping/Makefile.am
+++ b/test/shaping/Makefile.am
@@ -92,6 +92,7 @@ TESTS = \
 	data/text-rendering-tests/tests/GPOS-2.tests \
 	data/text-rendering-tests/tests/GPOS-3.tests \
 	data/text-rendering-tests/tests/GPOS-4.tests \
+	data/text-rendering-tests/tests/GPOS-5.tests \
 	data/text-rendering-tests/tests/GSUB-1.tests \
 	data/text-rendering-tests/tests/GSUB-2.tests \
 	data/text-rendering-tests/tests/GVAR-1.tests \
@@ -112,7 +113,6 @@ TESTS = \
 
 DISABLED_TESTS = \
 	data/text-rendering-tests/tests/CMAP-3.tests # Non-Unicode cmap \
-	data/text-rendering-tests/tests/GPOS-5.tests # Rounding difference \
 	data/text-rendering-tests/tests/MORX-1.tests # Not implemented \
 	data/text-rendering-tests/tests/MORX-2.tests # Not implemented \
 	data/text-rendering-tests/tests/MORX-3.tests # Not implemented \
commit 7cdd6ab068500aa18de9a856bfbe730d0aac9a27
Author: Behdad Esfahbod <behdad at behdad.org>
Date:   Wed Jan 10 04:33:08 2018 +0100

    Round, instead of floor, when applying variations
    
    Hoping this would fix remaining text-rendering-tests failures,
    but so far no luck.

diff --git a/src/hb-font-private.hh b/src/hb-font-private.hh
index d2801fb8..d391f462 100644
--- a/src/hb-font-private.hh
+++ b/src/hb-font-private.hh
@@ -541,7 +541,7 @@ struct hb_font_t {
   }
   inline hb_position_t em_scalef (float v, int scale)
   {
-    return (hb_position_t) (v * scale / face->get_upem ());
+    return (hb_position_t) round (v * scale / face->get_upem ());
   }
 };
 
diff --git a/src/hb-ot-layout-gpos-table.hh b/src/hb-ot-layout-gpos-table.hh
index 743767a5..c8ea6e05 100644
--- a/src/hb-ot-layout-gpos-table.hh
+++ b/src/hb-ot-layout-gpos-table.hh
@@ -333,7 +333,7 @@ struct Anchor
     case 1: u.format1.get_anchor (c, glyph_id, x, y); return;
     case 2: u.format2.get_anchor (c, glyph_id, x, y); return;
     case 3: u.format3.get_anchor (c, glyph_id, x, y); return;
-    default:						 return;
+    default:					      return;
     }
   }
 
diff --git a/src/hb-private.hh b/src/hb-private.hh
index acddd893..9a1f2c51 100644
--- a/src/hb-private.hh
+++ b/src/hb-private.hh
@@ -40,6 +40,7 @@
 #define HB_OT_H_IN
 #endif
 
+#include <math.h>
 #include <stdlib.h>
 #include <stddef.h>
 #include <string.h>
commit 6dc6f0c9f844a006b4518ce789e319fcef6e9680
Author: Behdad Esfahbod <behdad at behdad.org>
Date:   Wed Jan 10 04:12:35 2018 +0100

    [test] Whitelist one passing test

diff --git a/test/shaping/Makefile.am b/test/shaping/Makefile.am
index 53555d6d..0950bdb3 100644
--- a/test/shaping/Makefile.am
+++ b/test/shaping/Makefile.am
@@ -107,6 +107,7 @@ TESTS = \
 	data/text-rendering-tests/tests/HVAR-2.tests \
 	data/text-rendering-tests/tests/KERN-1.tests \
 	data/text-rendering-tests/tests/KERN-2.tests \
+	data/text-rendering-tests/tests/SHKNDA-1.tests \
 	$(NULL)
 
 DISABLED_TESTS = \
@@ -120,7 +121,6 @@ DISABLED_TESTS = \
 	data/text-rendering-tests/tests/SHBALI-1.tests # Rounding difference \
 	data/text-rendering-tests/tests/SHBALI-2.tests # Rounding difference \
 	data/text-rendering-tests/tests/SHBALI-3.tests # Rounding difference \
-	data/text-rendering-tests/tests/SHKNDA-1.tests # Rounding difference \
 	data/text-rendering-tests/tests/SHKNDA-2.tests # Rounding difference \
 	data/text-rendering-tests/tests/SHKNDA-3.tests # Rounding difference \
 	$(NULL)
commit ec939761e4d1b2f825db715290d70e18b1c9dd12
Author: Behdad Esfahbod <behdad at behdad.org>
Date:   Wed Jan 10 03:56:43 2018 +0100

    Minor

diff --git a/test/shaping/Makefile.am b/test/shaping/Makefile.am
index 492b30cf..53555d6d 100644
--- a/test/shaping/Makefile.am
+++ b/test/shaping/Makefile.am
@@ -24,6 +24,7 @@ EXTRA_DIST += \
 	run-tests.py \
 	texts/in-house \
 	data/in-house/fonts \
+	data/text-rendering-tests/extract-tests.py \
 	data/text-rendering-tests/fonts \
 	$(TESTS) \
 	$(NULL)
commit c4eac531dfad55f691557a684b3a6bde83c4bcea
Author: Behdad Esfahbod <behdad at behdad.org>
Date:   Wed Jan 10 03:51:09 2018 +0100

    Minor

diff --git a/test/shaping/Makefile.am b/test/shaping/Makefile.am
index c28892f2..492b30cf 100644
--- a/test/shaping/Makefile.am
+++ b/test/shaping/Makefile.am
@@ -125,7 +125,6 @@ DISABLED_TESTS = \
 	$(NULL)
 
 TEST_EXTENSIONS = .tests
-
 TESTS_LOG_COMPILER = $(srcdir)/run-tests.py $(top_builddir)/util/hb-shape$(EXEEXT)
 
 -include $(top_srcdir)/git.mk


More information about the HarfBuzz mailing list