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

Behdad Esfahbod behdad at kemper.freedesktop.org
Tue Oct 23 10:11:35 UTC 2018


 src/hb-aat-layout-trak-table.hh                 |    4 ++++
 src/hb-common.cc                                |    2 +-
 src/hb-ot-shape.cc                              |   15 +++++++++++----
 src/hb-ot-shape.hh                              |    5 ++++-
 test/shaping/data/in-house/tests/aat-trak.tests |    3 +++
 5 files changed, 23 insertions(+), 6 deletions(-)

New commits:
commit cf92d6579e91d326598dcff93457fe85dfa962c2
Author: Behdad Esfahbod <behdad at behdad.org>
Date:   Tue Oct 23 03:10:56 2018 -0700

    [trak] Allow disabling tracking for ranges of text
    
    Fixes https://github.com/harfbuzz/harfbuzz/issues/1303

diff --git a/src/hb-aat-layout-trak-table.hh b/src/hb-aat-layout-trak-table.hh
index 8cfc8bc3..de2071ad 100644
--- a/src/hb-aat-layout-trak-table.hh
+++ b/src/hb-aat-layout-trak-table.hh
@@ -184,6 +184,8 @@ struct trak
   {
     TRACE_APPLY (this);
 
+    hb_mask_t trak_mask = c->plan->trak_mask;
+
     const float ptem = c->font->ptem;
     if (unlikely (ptem <= 0.f))
       return_trace (false);
@@ -197,6 +199,7 @@ struct trak
       hb_position_t advance_to_add = c->font->em_scalef_x (tracking);
       foreach_grapheme (buffer, start, end)
       {
+        if (!(buffer->info[start].mask & trak_mask)) continue;
 	buffer->pos[start].x_advance += advance_to_add;
 	buffer->pos[start].x_offset += offset_to_add;
       }
@@ -209,6 +212,7 @@ struct trak
       hb_position_t advance_to_add = c->font->em_scalef_y (tracking);
       foreach_grapheme (buffer, start, end)
       {
+        if (!(buffer->info[start].mask & trak_mask)) continue;
 	buffer->pos[start].y_advance += advance_to_add;
 	buffer->pos[start].y_offset += offset_to_add;
       }
diff --git a/src/hb-ot-shape.cc b/src/hb-ot-shape.cc
index 8de66f3d..e05a6770 100644
--- a/src/hb-ot-shape.cc
+++ b/src/hb-ot-shape.cc
@@ -62,16 +62,18 @@ hb_ot_shape_planner_t::compile (hb_ot_shape_plan_t &plan,
   plan.shaper = shaper;
   map.compile (plan.map, coords, num_coords);
 
-  plan.rtlm_mask = plan.map.get_1_mask (HB_TAG ('r','t','l','m'));
   plan.frac_mask = plan.map.get_1_mask (HB_TAG ('f','r','a','c'));
   plan.numr_mask = plan.map.get_1_mask (HB_TAG ('n','u','m','r'));
   plan.dnom_mask = plan.map.get_1_mask (HB_TAG ('d','n','o','m'));
   plan.has_frac = plan.frac_mask || (plan.numr_mask && plan.dnom_mask);
+  plan.rtlm_mask = plan.map.get_1_mask (HB_TAG ('r','t','l','m'));
   hb_tag_t kern_tag = HB_DIRECTION_IS_HORIZONTAL (plan.props.direction) ?
 		      HB_TAG ('k','e','r','n') : HB_TAG ('v','k','r','n');
   plan.kern_mask = plan.map.get_mask (kern_tag);
+  plan.trak_mask = plan.map.get_mask (HB_TAG ('t','r','a','k'));
 
   plan.requested_kerning = !!plan.kern_mask;
+  plan.requested_tracking = !!plan.trak_mask;
   bool has_gpos_kern = plan.map.get_feature_index (1, kern_tag) != HB_OT_LAYOUT_NO_FEATURE_INDEX;
   bool disable_gpos = plan.shaper->gpos_tag &&
 		      plan.shaper->gpos_tag != plan.map.chosen_script[1];
@@ -116,8 +118,7 @@ hb_ot_shape_planner_t::compile (hb_ot_shape_plan_t &plan,
     plan.fallback_mark_positioning = true;
 
   /* Currently we always apply trak. */
-  plan.apply_trak = hb_aat_layout_has_tracking (face) &&
-		    plan.map.needs_fallback (HB_TAG ('t','r','a','k'));
+  plan.apply_trak = plan.requested_tracking && hb_aat_layout_has_tracking (face);
 }
 
 
@@ -178,7 +179,9 @@ hb_ot_shape_collect_features (hb_ot_shape_planner_t          *planner,
   /* Random! */
   map->enable_feature (HB_TAG ('r','a','n','d'), F_RANDOM, HB_OT_MAP_MAX_VALUE);
 
-  /* Tracking. */
+  /* Tracking.  We enable dummy feature here just to allow disabling
+   * AAT 'trak' table using features.
+   * https://github.com/harfbuzz/harfbuzz/issues/1303 */
   map->enable_feature (HB_TAG ('t','r','a','k'), F_HAS_FALLBACK);
 
   map->enable_feature (HB_TAG ('H','A','R','F'));
diff --git a/src/hb-ot-shape.hh b/src/hb-ot-shape.hh
index c9c0d3e0..93fce2d9 100644
--- a/src/hb-ot-shape.hh
+++ b/src/hb-ot-shape.hh
@@ -40,10 +40,13 @@ struct hb_ot_shape_plan_t
   const struct hb_ot_complex_shaper_t *shaper;
   hb_ot_map_t map;
   const void *data;
-  hb_mask_t rtlm_mask, frac_mask, numr_mask, dnom_mask;
+  hb_mask_t frac_mask, numr_mask, dnom_mask;
+  hb_mask_t rtlm_mask;
   hb_mask_t kern_mask;
+  hb_mask_t trak_mask;
 
   bool requested_kerning : 1;
+  bool requested_tracking : 1;
   bool has_frac : 1;
   bool has_gpos_mark : 1;
   bool fallback_glyph_classes : 1;
diff --git a/test/shaping/data/in-house/tests/aat-trak.tests b/test/shaping/data/in-house/tests/aat-trak.tests
index c8f10fbc..3c558e60 100644
--- a/test/shaping/data/in-house/tests/aat-trak.tests
+++ b/test/shaping/data/in-house/tests/aat-trak.tests
@@ -8,3 +8,4 @@
 ../fonts/TestTRAK.ttf:--font-ptem=144:U+0041,U+0042,U+0043:[A.alt=0 at -107,0+786|B=1 at -107,0+786|C.alt=2 at -107,0+786]
 ../fonts/TestTRAK.ttf:--font-ptem=144:U+0041,U+0042,U+0043:[A.alt=0 at -107,0+786|B=1 at -107,0+786|C.alt=2 at -107,0+786]
 ../fonts/TestTRAK.ttf:--font-ptem=144 --features=-trak:U+0041,U+0042,U+0043:[A.alt=0+1000|B=1+1000|C.alt=2+1000]
+../fonts/TestTRAK.ttf:--font-ptem=144 --features=-trak[1;3]:U+0041,U+0042,U+0043,U+0041,U+0042,U+0043:[A.alt=0 at -107,0+786|B=1+1000|C.alt=2+1000|A.alt=3 at -107,0+786|B=4 at -107,0+786|C.alt=5 at -107,0+786]
commit 8869436cb8a338b46c138305966a4b7b2c3ee374
Author: Behdad Esfahbod <behdad at behdad.org>
Date:   Tue Oct 23 03:07:48 2018 -0700

    When parsing feature ranges, accept ';' instead of ':'

diff --git a/src/hb-common.cc b/src/hb-common.cc
index ccdb4dd9..86d07cf1 100644
--- a/src/hb-common.cc
+++ b/src/hb-common.cc
@@ -911,7 +911,7 @@ parse_feature_indices (const char **pp, const char *end, hb_feature_t *feature)
 
   has_start = parse_uint (pp, end, &feature->start);
 
-  if (parse_char (pp, end, ':')) {
+  if (parse_char (pp, end, ':') || parse_char (pp, end, ';')) {
     parse_uint (pp, end, &feature->end);
   } else {
     if (has_start)
commit 22ecefd88e1ea1841f363057b948aa792ac871a6
Author: Ebrahim Byagowi <ebrahim at gnu.org>
Date:   Tue Oct 23 00:52:05 2018 +0330

    Make tracking optout possible using 'trak' ot feature
    
    So '--features=-trak' or 'font-feature-settings: 'trak' 0;' can prevent
    applying of tracking if used.

diff --git a/src/hb-ot-shape.cc b/src/hb-ot-shape.cc
index a5538871..8de66f3d 100644
--- a/src/hb-ot-shape.cc
+++ b/src/hb-ot-shape.cc
@@ -116,7 +116,8 @@ hb_ot_shape_planner_t::compile (hb_ot_shape_plan_t &plan,
     plan.fallback_mark_positioning = true;
 
   /* Currently we always apply trak. */
-  plan.apply_trak = hb_aat_layout_has_tracking (face);
+  plan.apply_trak = hb_aat_layout_has_tracking (face) &&
+		    plan.map.needs_fallback (HB_TAG ('t','r','a','k'));
 }
 
 
@@ -177,12 +178,15 @@ hb_ot_shape_collect_features (hb_ot_shape_planner_t          *planner,
   /* Random! */
   map->enable_feature (HB_TAG ('r','a','n','d'), F_RANDOM, HB_OT_MAP_MAX_VALUE);
 
-  map->enable_feature (HB_TAG('H','A','R','F'));
+  /* Tracking. */
+  map->enable_feature (HB_TAG ('t','r','a','k'), F_HAS_FALLBACK);
+
+  map->enable_feature (HB_TAG ('H','A','R','F'));
 
   if (planner->shaper->collect_features)
     planner->shaper->collect_features (planner);
 
-  map->enable_feature (HB_TAG('B','U','Z','Z'));
+  map->enable_feature (HB_TAG ('B','U','Z','Z'));
 
   for (unsigned int i = 0; i < ARRAY_LENGTH (common_features); i++)
     map->add_feature (common_features[i]);
diff --git a/test/shaping/data/in-house/tests/aat-trak.tests b/test/shaping/data/in-house/tests/aat-trak.tests
index 48b224f3..c8f10fbc 100644
--- a/test/shaping/data/in-house/tests/aat-trak.tests
+++ b/test/shaping/data/in-house/tests/aat-trak.tests
@@ -6,3 +6,5 @@
 ../fonts/TestTRAK.ttf:--font-ptem=24:U+0041,U+0042,U+0043:[A.alt=0 at -12,0+976|B=1 at -12,0+976|C.alt=2 at -12,0+976]
 ../fonts/TestTRAK.ttf:--font-ptem=72:U+0041,U+0042,U+0043:[A.alt=0 at -50,0+900|B=1 at -50,0+900|C.alt=2 at -50,0+900]
 ../fonts/TestTRAK.ttf:--font-ptem=144:U+0041,U+0042,U+0043:[A.alt=0 at -107,0+786|B=1 at -107,0+786|C.alt=2 at -107,0+786]
+../fonts/TestTRAK.ttf:--font-ptem=144:U+0041,U+0042,U+0043:[A.alt=0 at -107,0+786|B=1 at -107,0+786|C.alt=2 at -107,0+786]
+../fonts/TestTRAK.ttf:--font-ptem=144 --features=-trak:U+0041,U+0042,U+0043:[A.alt=0+1000|B=1+1000|C.alt=2+1000]


More information about the HarfBuzz mailing list