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

Behdad Esfahbod behdad at kemper.freedesktop.org
Thu Nov 22 20:54:17 UTC 2018


 src/hb-ot-shape-complex-myanmar.cc |   21 --------------------
 src/hb-ot-shape-complex.hh         |   28 +++++++++++++++++----------
 src/hb-ot-shape.cc                 |   38 ++++++++++++++++++++++---------------
 src/hb-ot-shape.hh                 |    3 ++
 4 files changed, 44 insertions(+), 46 deletions(-)

New commits:
commit a201fa74cd67f36a402a5c8093889c9d793e9fd5
Author: Behdad Esfahbod <behdad at behdad.org>
Date:   Thu Nov 22 15:52:29 2018 -0500

    [aat] Tweak fallback positioning logic when applying morx
    
    Such that for Indic-like scripts (eg. Khmer), we don't do any fallback mark
    advance-zeroing / positioning, but we do for Latin, etc.  Reuses preferences
    of our script-specific OpenType shapers for those.
    
    Fixes regression: https://github.com/harfbuzz/harfbuzz/issues/1393
    Which means, fixes again: https://github.com/harfbuzz/harfbuzz/issues/1264
    While not regressing: https://github.com/harfbuzz/harfbuzz/issues/1357

diff --git a/src/hb-ot-shape.cc b/src/hb-ot-shape.cc
index ccee8d34..e87848d2 100644
--- a/src/hb-ot-shape.cc
+++ b/src/hb-ot-shape.cc
@@ -76,10 +76,16 @@ hb_ot_shape_planner_t::hb_ot_shape_planner_t (hb_face_t                     *fac
 						props (*props),
 						map (face, props),
 						aat_map (face, props),
-						apply_morx (_hb_apply_morx (face)),
-						shaper (apply_morx ?
-						        &_hb_ot_complex_shaper_default :
-							hb_ot_shape_complex_categorize (this)) {}
+						apply_morx (_hb_apply_morx (face))
+{
+  shaper = hb_ot_shape_complex_categorize (this);
+
+  script_zero_marks = shaper->zero_width_marks != HB_OT_SHAPE_ZERO_WIDTH_MARKS_NONE;
+  script_fallback_mark_positioning = shaper->fallback_position;
+
+  if (apply_morx)
+    shaper = &_hb_ot_complex_shaper_default;
+}
 
 void
 hb_ot_shape_planner_t::compile (hb_ot_shape_plan_t           &plan,
@@ -141,9 +147,11 @@ hb_ot_shape_planner_t::compile (hb_ot_shape_plan_t           &plan,
   }
 
   bool has_kern_mark = plan.apply_kern && hb_ot_layout_has_cross_kerning (face);
-  plan.zero_marks = !plan.apply_morx && !plan.apply_kerx && !has_kern_mark;
+  plan.zero_marks = script_zero_marks && !plan.apply_kerx && !has_kern_mark;
   plan.has_gpos_mark = !!plan.map.get_1_mask (HB_TAG ('m','a','r','k'));
-  plan.fallback_mark_positioning = !plan.apply_gpos && plan.zero_marks;
+
+  plan.fallback_mark_positioning = script_fallback_mark_positioning && !plan.apply_gpos && !plan.apply_kerx && !has_kern_mark;
+  plan.adjust_mark_positioning_when_zeroing = !plan.apply_gpos && !plan.apply_kerx && !has_kern_mark;
 
   /* Currently we always apply trak. */
   plan.apply_trak = plan.requested_tracking && hb_aat_layout_has_tracking (face);
@@ -158,6 +166,7 @@ hb_ot_shape_plan_t::init0 (hb_face_t                     *face,
 
   hb_ot_shape_planner_t planner (face,
 				 &key->props);
+
   hb_ot_shape_collect_features (&planner,
 				key->user_features,
 				key->num_user_features);
@@ -811,17 +820,16 @@ hb_ot_position_complex (const hb_ot_shape_context_t *c)
   hb_glyph_info_t *info = c->buffer->info;
   hb_glyph_position_t *pos = c->buffer->pos;
 
-  /* If the font has no GPOS, AND, no fallback positioning will
-   * happen, AND, direction is forward, then when zeroing mark
-   * widths, we shift the mark with it, such that the mark
-   * is positioned hanging over the previous glyph.  When
+  /* If the font has no GPOS and direction is forward, then when
+   * zeroing mark widths, we shift the mark with it, such that the
+   * mark is positioned hanging over the previous glyph.  When
    * direction is backward we don't shift and it will end up
    * hanging over the next glyph after the final reordering.
-   * If fallback positinoing happens or GPOS is present, we don't
-   * care.
+   *
+   * Note: If fallback positinoing happens, we don't care about
+   * this as it will be overriden.
    */
-  bool adjust_offsets_when_zeroing = c->plan->fallback_mark_positioning &&
-				     !c->plan->shaper->fallback_position &&
+  bool adjust_offsets_when_zeroing = c->plan->adjust_mark_positioning_when_zeroing &&
 				     HB_DIRECTION_IS_FORWARD (c->buffer->props.direction);
 
   /* We change glyph origin to what GPOS expects (horizontal), apply GPOS, change it back. */
@@ -877,7 +885,7 @@ hb_ot_position_complex (const hb_ot_shape_context_t *c)
 					&pos[i].x_offset,
 					&pos[i].y_offset);
 
-  if (c->plan->fallback_mark_positioning && c->plan->shaper->fallback_position)
+  if (c->plan->fallback_mark_positioning)
     _hb_ot_shape_fallback_mark_position (c->plan, c->font, c->buffer);
 }
 
diff --git a/src/hb-ot-shape.hh b/src/hb-ot-shape.hh
index 397634c2..6e1478d0 100644
--- a/src/hb-ot-shape.hh
+++ b/src/hb-ot-shape.hh
@@ -77,6 +77,7 @@ struct hb_ot_shape_plan_t
   bool zero_marks : 1;
   bool fallback_glyph_classes : 1;
   bool fallback_mark_positioning : 1;
+  bool adjust_mark_positioning_when_zeroing : 1;
 
   bool apply_gpos : 1;
   bool apply_kerx : 1;
@@ -113,6 +114,8 @@ struct hb_ot_shape_planner_t
   hb_ot_map_builder_t map;
   hb_aat_map_builder_t aat_map;
   bool apply_morx : 1;
+  bool script_zero_marks : 1;
+  bool script_fallback_mark_positioning : 1;
   const struct hb_ot_complex_shaper_t *shaper;
 
   HB_INTERNAL hb_ot_shape_planner_t (hb_face_t                     *face,
commit fa0bd8964d110c168a918bc331dcd350c3fed8c1
Author: Behdad Esfahbod <behdad at behdad.org>
Date:   Thu Nov 22 14:46:39 2018 -0500

    [myanmar] Minor move

diff --git a/src/hb-ot-shape-complex.hh b/src/hb-ot-shape-complex.hh
index 75222461..a2499de9 100644
--- a/src/hb-ot-shape-complex.hh
+++ b/src/hb-ot-shape-complex.hh
@@ -283,6 +283,12 @@ hb_ot_shape_complex_categorize (const hb_ot_shape_planner_t *planner)
 	return &_hb_ot_complex_shaper_myanmar;
 
 
+    /* https://github.com/harfbuzz/harfbuzz/issues/1162 */
+    case HB_SCRIPT_MYANMAR_ZAWGYI:
+
+      return &_hb_ot_complex_shaper_myanmar_zawgyi;
+
+
     /* Unicode-2.0 additions */
     case HB_SCRIPT_TIBETAN:
 
@@ -381,12 +387,6 @@ hb_ot_shape_complex_categorize (const hb_ot_shape_planner_t *planner)
 	return &_hb_ot_complex_shaper_default;
       else
 	return &_hb_ot_complex_shaper_use;
-
-
-    /* https://github.com/harfbuzz/harfbuzz/issues/1162 */
-    case HB_SCRIPT_MYANMAR_ZAWGYI:
-
-      return &_hb_ot_complex_shaper_myanmar_zawgyi;
   }
 }
 
commit 7dc561984bdb1f29f09ae0793195b5fbf772522b
Author: Behdad Esfahbod <behdad at behdad.org>
Date:   Thu Nov 22 14:45:46 2018 -0500

    [myanmar] If there's no GSUB table, pick myanmar shaper
    
    Needed for morx+kern mark-zeroing interaction.  All other scripts
    work this way.

diff --git a/src/hb-ot-shape-complex.hh b/src/hb-ot-shape-complex.hh
index e69dce77..75222461 100644
--- a/src/hb-ot-shape-complex.hh
+++ b/src/hb-ot-shape-complex.hh
@@ -268,10 +268,19 @@ hb_ot_shape_complex_categorize (const hb_ot_shape_planner_t *planner)
 	return &_hb_ot_complex_shaper_khmer;
 
     case HB_SCRIPT_MYANMAR:
-      if (planner->map.chosen_script[0] == HB_TAG ('m','y','m','2'))
-	return &_hb_ot_complex_shaper_myanmar;
-      else
+      /* If the designer designed the font for the 'DFLT' script,
+       * (or we ended up arbitrarily pick 'latn'), use the default shaper.
+       * Otherwise, use the specific shaper.
+       *
+       * If designer designed for 'mymr' tag, also send to default
+       * shaper.  That's tag used from before Myanmar shaping spec
+       * was developed.  The shaping spec uses 'mym2' tag. */
+      if (planner->map.chosen_script[0] == HB_TAG ('D','F','L','T') ||
+	  planner->map.chosen_script[0] == HB_TAG ('l','a','t','n') ||
+	  planner->map.chosen_script[0] == HB_TAG ('m','y','m','r'))
 	return &_hb_ot_complex_shaper_default;
+      else
+	return &_hb_ot_complex_shaper_myanmar;
 
 
     /* Unicode-2.0 additions */
@@ -373,6 +382,7 @@ hb_ot_shape_complex_categorize (const hb_ot_shape_planner_t *planner)
       else
 	return &_hb_ot_complex_shaper_use;
 
+
     /* https://github.com/harfbuzz/harfbuzz/issues/1162 */
     case HB_SCRIPT_MYANMAR_ZAWGYI:
 
commit 25f52f58c20715cc0dee2dd2885669078a128b08
Author: Behdad Esfahbod <behdad at behdad.org>
Date:   Thu Nov 22 14:41:01 2018 -0500

    [myanmar] Remove myanmar_old shaper
    
    Over time it has become the same as default shaper.  So, remove.

diff --git a/src/hb-ot-shape-complex-myanmar.cc b/src/hb-ot-shape-complex-myanmar.cc
index ca7b5a9b..8fdf2f4b 100644
--- a/src/hb-ot-shape-complex-myanmar.cc
+++ b/src/hb-ot-shape-complex-myanmar.cc
@@ -391,27 +391,6 @@ const hb_ot_complex_shaper_t _hb_ot_complex_shaper_myanmar =
 };
 
 
-/* Uniscribe seems to have a shaper for 'mymr' that is like the
- * generic shaper, except that it zeros mark advances GDEF_LATE. */
-const hb_ot_complex_shaper_t _hb_ot_complex_shaper_myanmar_old =
-{
-  nullptr, /* collect_features */
-  nullptr, /* override_features */
-  nullptr, /* data_create */
-  nullptr, /* data_destroy */
-  nullptr, /* preprocess_text */
-  nullptr, /* postprocess_glyphs */
-  HB_OT_SHAPE_NORMALIZATION_MODE_DEFAULT,
-  nullptr, /* decompose */
-  nullptr, /* compose */
-  nullptr, /* setup_masks */
-  HB_TAG_NONE, /* gpos_tag */
-  nullptr, /* reorder_marks */
-  HB_OT_SHAPE_ZERO_WIDTH_MARKS_BY_GDEF_LATE,
-  true, /* fallback_position */
-};
-
-
 /* Ugly Zawgyi encoding.
  * Disable all auto processing.
  * https://github.com/harfbuzz/harfbuzz/issues/1162 */
diff --git a/src/hb-ot-shape-complex.hh b/src/hb-ot-shape-complex.hh
index 2944d745..e69dce77 100644
--- a/src/hb-ot-shape-complex.hh
+++ b/src/hb-ot-shape-complex.hh
@@ -57,7 +57,6 @@ enum hb_ot_shape_zero_width_marks_type_t {
   HB_COMPLEX_SHAPER_IMPLEMENT (indic) \
   HB_COMPLEX_SHAPER_IMPLEMENT (khmer) \
   HB_COMPLEX_SHAPER_IMPLEMENT (myanmar) \
-  HB_COMPLEX_SHAPER_IMPLEMENT (myanmar_old) \
   HB_COMPLEX_SHAPER_IMPLEMENT (myanmar_zawgyi) \
   HB_COMPLEX_SHAPER_IMPLEMENT (thai) \
   HB_COMPLEX_SHAPER_IMPLEMENT (use) \
@@ -271,8 +270,6 @@ hb_ot_shape_complex_categorize (const hb_ot_shape_planner_t *planner)
     case HB_SCRIPT_MYANMAR:
       if (planner->map.chosen_script[0] == HB_TAG ('m','y','m','2'))
 	return &_hb_ot_complex_shaper_myanmar;
-      else if (planner->map.chosen_script[0] == HB_TAG ('m','y','m','r'))
-	return &_hb_ot_complex_shaper_myanmar_old;
       else
 	return &_hb_ot_complex_shaper_default;
 
@@ -378,6 +375,7 @@ hb_ot_shape_complex_categorize (const hb_ot_shape_planner_t *planner)
 
     /* https://github.com/harfbuzz/harfbuzz/issues/1162 */
     case HB_SCRIPT_MYANMAR_ZAWGYI:
+
       return &_hb_ot_complex_shaper_myanmar_zawgyi;
   }
 }


More information about the HarfBuzz mailing list