[HarfBuzz] harfbuzz-ng: Branch 'master' - 8 commits

Behdad Esfahbod behdad at kemper.freedesktop.org
Tue Jul 31 21:23:19 PDT 2012


 TODO                               |   29 -----------------------------
 src/hb-old.cc                      |   24 ++++++++++++++++++++++--
 src/hb-old/harfbuzz-shaper.cpp     |    1 +
 src/hb-ot-layout-gpos-table.hh     |   14 ++++++++------
 src/hb-ot-layout-gsub-table.hh     |    5 ++++-
 src/hb-ot-layout.cc                |    4 ++--
 src/hb-ot-layout.h                 |    3 ++-
 src/hb-ot-shape-complex-arabic.cc  |    1 +
 src/hb-ot-shape-complex-indic.cc   |    1 +
 src/hb-ot-shape-complex-misc.cc    |    2 ++
 src/hb-ot-shape-complex-private.hh |    2 ++
 src/hb-ot-shape.cc                 |   37 +++++++++++++++++++++++++++++++++----
 src/hb-shape.cc                    |    2 ++
 13 files changed, 80 insertions(+), 45 deletions(-)

New commits:
commit 0834d952017a04c6f4599e574cb75ecf3ca27d3b
Author: Behdad Esfahbod <behdad at behdad.org>
Date:   Wed Aug 1 00:21:09 2012 -0400

    [hb-old] Adjust mark positioning parameters
    
    Fallback mark positioning works now...  With hb-ft and hb-view /
    hb-shape at least.

diff --git a/src/hb-old.cc b/src/hb-old.cc
index 1f6bf7f..9d1a005 100644
--- a/src/hb-old.cc
+++ b/src/hb-old.cc
@@ -149,12 +149,12 @@ hb_old_getGlyphMetrics (HB_Font old_font,
 
   hb_font_get_glyph_extents (font, glyph, &extents);
 
-  metrics->xOffset = extents.x_bearing;
-  metrics->yOffset = extents.y_bearing;
+  metrics->x       = extents.x_bearing;
+  metrics->y       = extents.y_bearing;
   metrics->width   = extents.width;
-  metrics->height  = extents.height;
-  metrics->x       = hb_font_get_glyph_h_advance (font, glyph);
-  metrics->y       = 0;
+  metrics->height  = -extents.height;
+  metrics->xOffset = hb_font_get_glyph_h_advance (font, glyph);
+  metrics->yOffset = 0;
 }
 
 static HB_Fixed
diff --git a/src/hb-old/harfbuzz-shaper.cpp b/src/hb-old/harfbuzz-shaper.cpp
index 62886f3..f410780 100644
--- a/src/hb-old/harfbuzz-shaper.cpp
+++ b/src/hb-old/harfbuzz-shaper.cpp
@@ -63,6 +63,7 @@ static inline void positionCluster(HB_ShaperItem *item, int gfrom,  int glast)
         offsetBase += HB_FIXED_CONSTANT(4);
     else
         offsetBase += size;
+    offsetBase = -offsetBase;
     //qreal offsetBase = (size - 4) / 4 + qMin<qreal>(size, 4) + 1;
 //     qDebug("offset = %f", offsetBase);
 
commit 4ca743dfb8e09f9fa525061c7f1144d55f72effb
Author: Behdad Esfahbod <behdad at behdad.org>
Date:   Wed Aug 1 00:03:41 2012 -0400

    [old] Implement fontMetrics

diff --git a/src/hb-old.cc b/src/hb-old.cc
index 84a431c..1f6bf7f 100644
--- a/src/hb-old.cc
+++ b/src/hb-old.cc
@@ -161,7 +161,16 @@ static HB_Fixed
 hb_old_getFontMetric (HB_Font old_font,
 		      HB_FontMetric metric)
 {
-  return 0; // TODO
+  hb_font_t *font = (hb_font_t *) old_font->userData;
+
+  switch (metric)
+  {
+    case HB_FontAscent:
+       return font->y_scale; /* XXX We don't have ascent data yet. */
+
+    default:
+      return 0;
+  }
 }
 
 static const HB_FontClass hb_old_font_class = {
commit 1e7d860613032e40a3f90e2caa2ee5ac44ab8c8c
Author: Behdad Esfahbod <behdad at behdad.org>
Date:   Tue Jul 31 23:41:06 2012 -0400

    [GPOS] Adjust mark advance-width zeroing logic
    
    If there is no GPOS, zero mark advances.
    
    If there *is* GPOS and the shaper requests so, zero mark advances for
    attached marks.
    
    Fixes regression with Tibetan, where the font has GPOS, and marks a
    glyph as mark where it shouldn't get zero advance.

diff --git a/src/hb-ot-layout-gpos-table.hh b/src/hb-ot-layout-gpos-table.hh
index 339749e..2e8a389 100644
--- a/src/hb-ot-layout-gpos-table.hh
+++ b/src/hb-ot-layout-gpos-table.hh
@@ -1587,7 +1587,7 @@ struct GPOS : GSUBGPOS
   { return get_lookup (lookup_index).apply_string (c); }
 
   static inline void position_start (hb_font_t *font, hb_buffer_t *buffer);
-  static inline void position_finish (hb_font_t *font, hb_buffer_t *buffer);
+  static inline void position_finish (hb_font_t *font, hb_buffer_t *buffer, hb_bool_t zero_width_attahced_marks);
 
   inline bool sanitize (hb_sanitize_context_t *c) {
     TRACE_SANITIZE ();
@@ -1620,15 +1620,17 @@ fix_cursive_minor_offset (hb_glyph_position_t *pos, unsigned int i, hb_direction
 }
 
 static void
-fix_mark_attachment (hb_glyph_position_t *pos, unsigned int i, hb_direction_t direction)
+fix_mark_attachment (hb_glyph_position_t *pos, unsigned int i, hb_direction_t direction, hb_bool_t zero_width_attached_marks)
 {
   if (likely (!(pos[i].attach_lookback())))
     return;
 
   unsigned int j = i - pos[i].attach_lookback();
 
-//  pos[i].x_advance = 0;
-//  pos[i].y_advance = 0;
+  if (zero_width_attached_marks) {
+    pos[i].x_advance = 0;
+    pos[i].y_advance = 0;
+  }
   pos[i].x_offset += pos[j].x_offset;
   pos[i].y_offset += pos[j].y_offset;
 
@@ -1655,7 +1657,7 @@ GPOS::position_start (hb_font_t *font HB_UNUSED, hb_buffer_t *buffer)
 }
 
 void
-GPOS::position_finish (hb_font_t *font HB_UNUSED, hb_buffer_t *buffer)
+GPOS::position_finish (hb_font_t *font HB_UNUSED, hb_buffer_t *buffer, hb_bool_t zero_width_attached_marks)
 {
   unsigned int len;
   hb_glyph_position_t *pos = hb_buffer_get_glyph_positions (buffer, &len);
@@ -1667,7 +1669,7 @@ GPOS::position_finish (hb_font_t *font HB_UNUSED, hb_buffer_t *buffer)
 
   /* Handle attachments */
   for (unsigned int i = 0; i < len; i++)
-    fix_mark_attachment (pos, i, direction);
+    fix_mark_attachment (pos, i, direction, zero_width_attached_marks);
 
   HB_BUFFER_DEALLOCATE_VAR (buffer, syllable);
   HB_BUFFER_DEALLOCATE_VAR (buffer, lig_props);
diff --git a/src/hb-ot-layout.cc b/src/hb-ot-layout.cc
index 28c2f83..0d0dfa0 100644
--- a/src/hb-ot-layout.cc
+++ b/src/hb-ot-layout.cc
@@ -478,9 +478,9 @@ hb_ot_layout_position_lookup_fast (hb_font_t    *font,
 }
 
 void
-hb_ot_layout_position_finish (hb_font_t *font, hb_buffer_t *buffer)
+hb_ot_layout_position_finish (hb_font_t *font, hb_buffer_t *buffer, hb_bool_t zero_width_attached_marks)
 {
-  GPOS::position_finish (font, buffer);
+  GPOS::position_finish (font, buffer, zero_width_attached_marks);
 }
 
 
diff --git a/src/hb-ot-layout.h b/src/hb-ot-layout.h
index 4e205d7..d663ab0 100644
--- a/src/hb-ot-layout.h
+++ b/src/hb-ot-layout.h
@@ -219,7 +219,8 @@ hb_ot_layout_position_lookup (hb_font_t    *font,
 /* Should be called after all the position_lookup's are done */
 void
 hb_ot_layout_position_finish (hb_font_t    *font,
-			      hb_buffer_t  *buffer);
+			      hb_buffer_t  *buffer,
+			      hb_bool_t     zero_width_attached_marks);
 
 
 HB_END_DECLS
diff --git a/src/hb-ot-shape-complex-arabic.cc b/src/hb-ot-shape-complex-arabic.cc
index 2cff581..39b25c3 100644
--- a/src/hb-ot-shape-complex-arabic.cc
+++ b/src/hb-ot-shape-complex-arabic.cc
@@ -299,5 +299,5 @@ const hb_ot_complex_shaper_t _hb_ot_complex_shaper_arabic =
   NULL, /* override_features */
   NULL, /* normalization_preference */
   setup_masks_arabic,
-  true, /* zero_width_marks */
+  true, /* zero_width_attached_marks */
 };
diff --git a/src/hb-ot-shape-complex-indic.cc b/src/hb-ot-shape-complex-indic.cc
index ba51821..15af692 100644
--- a/src/hb-ot-shape-complex-indic.cc
+++ b/src/hb-ot-shape-complex-indic.cc
@@ -1245,5 +1245,5 @@ const hb_ot_complex_shaper_t _hb_ot_complex_shaper_indic =
   override_features_indic,
   NULL, /* normalization_preference */
   setup_masks_indic,
-  false, /* zero_width_marks */
+  false, /* zero_width_attached_marks */
 };
diff --git a/src/hb-ot-shape-complex-misc.cc b/src/hb-ot-shape-complex-misc.cc
index 015ee08..a9dda94 100644
--- a/src/hb-ot-shape-complex-misc.cc
+++ b/src/hb-ot-shape-complex-misc.cc
@@ -93,7 +93,7 @@ const hb_ot_complex_shaper_t _hb_ot_complex_shaper_default =
   NULL, /* override_features */
   normalization_preference_default,
   NULL, /* setup_masks */
-  true, /* zero_width_marks */
+  true, /* zero_width_attached_marks */
 };
 
 
@@ -202,5 +202,5 @@ const hb_ot_complex_shaper_t _hb_ot_complex_shaper_thai =
   NULL, /* override_features */
   NULL, /* normalization_preference */
   setup_masks_thai,
-  true, /* zero_width_marks */
+  true, /* zero_width_attached_marks */
 };
diff --git a/src/hb-ot-shape-complex-private.hh b/src/hb-ot-shape-complex-private.hh
index 8ef41e8..9cdafff 100644
--- a/src/hb-ot-shape-complex-private.hh
+++ b/src/hb-ot-shape-complex-private.hh
@@ -94,7 +94,7 @@ struct hb_ot_complex_shaper_t
 		       hb_buffer_t                  *buffer,
 		       hb_font_t                    *font);
 
-  bool zero_width_marks;
+  bool zero_width_attached_marks;
 };
 
 #define HB_COMPLEX_SHAPER_IMPLEMENT(name) extern HB_INTERNAL const hb_ot_complex_shaper_t _hb_ot_complex_shaper_##name;
diff --git a/src/hb-ot-shape.cc b/src/hb-ot-shape.cc
index ac15b2a..11bc74f 100644
--- a/src/hb-ot-shape.cc
+++ b/src/hb-ot-shape.cc
@@ -439,12 +439,10 @@ hb_ot_position_complex (hb_ot_shape_context_t *c)
     }
 
     c->applied_position_complex = true;
-  }
-
-  if (c->plan->shaper->zero_width_marks)
+  } else
     hb_zero_mark_advances (c);
 
-  hb_ot_layout_position_finish (c->font, c->buffer);
+  hb_ot_layout_position_finish (c->font, c->buffer, c->plan->shaper->zero_width_attached_marks);
 
   return;
 }
commit a8842e4a448efb30f3f2f3c628d6dc4824829726
Author: Behdad Esfahbod <behdad at behdad.org>
Date:   Tue Jul 31 23:10:11 2012 -0400

    Remove some TODO items

diff --git a/TODO b/TODO
index da8f75d..bf13d07 100644
--- a/TODO
+++ b/TODO
@@ -3,15 +3,9 @@ General fixes:
 
 - mask propagation (when ligation, "or" the masks).
 
-- fail_shaper that always fails.
-
-- Make map in setup_masks() const, etc.
-
 - Warn at compile time (and runtime with HB_DEBUG?) if no Unicode / font
   funcs found / set.
 
-- In hb_shape(), assert if direction is INVALID.
-
 - Fix TT 'kern' on/off and GPOS interaction (move kerning before GPOS).
 
 - Do proper rounding when scaling from font space?  May be a non-issue.
@@ -20,23 +14,12 @@ General fixes:
   * init/medi/fina/isol for non-cursive scripts
   * vkna,hkna etc for kana, etc
 
-- Move non-native direction and normalization handling to the generic non-OT
-  layer, such that other backends can use (Uniscribe doesn't need this).
-
-- Convert NBSP into space glyph.
-
 - Add Pango backend?
 
 - Add ICUlayout backend?
 
 - Add ICUlayout API?
 
-- Add Old HarfBuzz backend?
-
-- Add Old HarfBuzz API?
-
-- Add namespace to avoid type clashes with Windows
-
 
 API issues to fix before 1.0:
 ============================
@@ -111,13 +94,3 @@ Tests to write:
 - hb_set_t
 
 - hb_cache_t and relatives
-
-
-Optimizations:
-=============
-
-- Avoid allocating blob objects internally for for_data() faces?
-
-- Add caching layer to hb-ft?
-
-- Cache feature-less shape plans internally on the face.
diff --git a/src/hb-shape.cc b/src/hb-shape.cc
index 5aa587b..b3d373b 100644
--- a/src/hb-shape.cc
+++ b/src/hb-shape.cc
@@ -87,6 +87,8 @@ hb_shape_full (hb_font_t          *font,
 
   buffer->guess_properties ();
 
+  assert (buffer->props.direction != HB_DIRECTION_INVALID);
+
   hb_shape_plan_t *shape_plan = hb_shape_plan_create_cached (font->face, &buffer->props, features, num_features, shaper_list);
   hb_bool_t res = hb_shape_plan_execute (shape_plan, font, buffer, features, num_features);
   hb_shape_plan_destroy (shape_plan);
commit 2bc3b9a616cedbc56ff4a915f9e3439ff3a6bf13
Author: Behdad Esfahbod <behdad at behdad.org>
Date:   Tue Jul 31 23:08:25 2012 -0400

    [OT] Zero mark advances if the shaper desires so
    
    Enabled for all shapers except for Indic.

diff --git a/src/hb-ot-shape-complex-arabic.cc b/src/hb-ot-shape-complex-arabic.cc
index 0f73d6d..2cff581 100644
--- a/src/hb-ot-shape-complex-arabic.cc
+++ b/src/hb-ot-shape-complex-arabic.cc
@@ -299,4 +299,5 @@ const hb_ot_complex_shaper_t _hb_ot_complex_shaper_arabic =
   NULL, /* override_features */
   NULL, /* normalization_preference */
   setup_masks_arabic,
+  true, /* zero_width_marks */
 };
diff --git a/src/hb-ot-shape-complex-indic.cc b/src/hb-ot-shape-complex-indic.cc
index 55eedab..ba51821 100644
--- a/src/hb-ot-shape-complex-indic.cc
+++ b/src/hb-ot-shape-complex-indic.cc
@@ -1245,4 +1245,5 @@ const hb_ot_complex_shaper_t _hb_ot_complex_shaper_indic =
   override_features_indic,
   NULL, /* normalization_preference */
   setup_masks_indic,
+  false, /* zero_width_marks */
 };
diff --git a/src/hb-ot-shape-complex-misc.cc b/src/hb-ot-shape-complex-misc.cc
index 1815366..015ee08 100644
--- a/src/hb-ot-shape-complex-misc.cc
+++ b/src/hb-ot-shape-complex-misc.cc
@@ -93,6 +93,7 @@ const hb_ot_complex_shaper_t _hb_ot_complex_shaper_default =
   NULL, /* override_features */
   normalization_preference_default,
   NULL, /* setup_masks */
+  true, /* zero_width_marks */
 };
 
 
@@ -201,4 +202,5 @@ const hb_ot_complex_shaper_t _hb_ot_complex_shaper_thai =
   NULL, /* override_features */
   NULL, /* normalization_preference */
   setup_masks_thai,
+  true, /* zero_width_marks */
 };
diff --git a/src/hb-ot-shape-complex-private.hh b/src/hb-ot-shape-complex-private.hh
index c0864fe..8ef41e8 100644
--- a/src/hb-ot-shape-complex-private.hh
+++ b/src/hb-ot-shape-complex-private.hh
@@ -93,6 +93,8 @@ struct hb_ot_complex_shaper_t
 		       const hb_ot_map_t            *map,
 		       hb_buffer_t                  *buffer,
 		       hb_font_t                    *font);
+
+  bool zero_width_marks;
 };
 
 #define HB_COMPLEX_SHAPER_IMPLEMENT(name) extern HB_INTERNAL const hb_ot_complex_shaper_t _hb_ot_complex_shaper_##name;
diff --git a/src/hb-ot-shape.cc b/src/hb-ot-shape.cc
index 843a543..ac15b2a 100644
--- a/src/hb-ot-shape.cc
+++ b/src/hb-ot-shape.cc
@@ -402,6 +402,18 @@ hb_position_default (hb_ot_shape_context_t *c)
 }
 
 static void
+hb_zero_mark_advances (hb_ot_shape_context_t *c)
+{
+  unsigned int count = c->buffer->len;
+  for (unsigned int i = 0; i < count; i++)
+    if (c->buffer->info[i].glyph_props() & HB_OT_LAYOUT_GLYPH_CLASS_MARK)
+    {
+      c->buffer->pos[i].x_advance = 0;
+      c->buffer->pos[i].y_advance = 0;
+    }
+}
+
+static void
 hb_ot_position_complex (hb_ot_shape_context_t *c)
 {
 
@@ -429,6 +441,9 @@ hb_ot_position_complex (hb_ot_shape_context_t *c)
     c->applied_position_complex = true;
   }
 
+  if (c->plan->shaper->zero_width_marks)
+    hb_zero_mark_advances (c);
+
   hb_ot_layout_position_finish (c->font, c->buffer);
 
   return;
commit 5fecd8b0355894ceda14b3d3c654f20c3d5e77f4
Author: Behdad Esfahbod <behdad at behdad.org>
Date:   Tue Jul 31 22:48:38 2012 -0400

    [OT] Synthesize glyph classes

diff --git a/TODO b/TODO
index be381e3..da8f75d 100644
--- a/TODO
+++ b/TODO
@@ -25,8 +25,6 @@ General fixes:
 
 - Convert NBSP into space glyph.
 
-- Synthetic GDEF.
-
 - Add Pango backend?
 
 - Add ICUlayout backend?
diff --git a/src/hb-ot-shape.cc b/src/hb-ot-shape.cc
index 8df8251..843a543 100644
--- a/src/hb-ot-shape.cc
+++ b/src/hb-ot-shape.cc
@@ -351,13 +351,29 @@ hb_substitute_default (hb_ot_shape_context_t *c)
 }
 
 static void
+hb_synthesize_glyph_classes (hb_ot_shape_context_t *c)
+{
+  unsigned int count = c->buffer->len;
+  for (unsigned int i = 0; i < count; i++)
+    c->buffer->info[i].glyph_props() = FLAG (_hb_glyph_info_get_general_category (&c->buffer->info[i])) &
+				       (FLAG (HB_UNICODE_GENERAL_CATEGORY_SPACING_MARK) |
+					FLAG (HB_UNICODE_GENERAL_CATEGORY_ENCLOSING_MARK) |
+					FLAG (HB_UNICODE_GENERAL_CATEGORY_NON_SPACING_MARK)) ?
+				       HB_OT_LAYOUT_GLYPH_CLASS_MARK :
+				       HB_OT_LAYOUT_GLYPH_CLASS_BASE_GLYPH;
+}
+
+
+static void
 hb_ot_substitute_complex (hb_ot_shape_context_t *c)
 {
   hb_ot_layout_substitute_start (c->face, c->buffer);
 
-  if (hb_ot_layout_has_substitution (c->face)) {
+  if (!hb_ot_layout_has_glyph_classes (c->face))
+    hb_synthesize_glyph_classes (c);
+
+  if (hb_ot_layout_has_substitution (c->face))
     c->plan->map.substitute (c->face, c->buffer);
-  }
 
   hb_ot_layout_substitute_finish (c->face, c->buffer);
 
commit 03b09214c073ce37eeb8af5218942c85b2d393df
Author: Behdad Esfahbod <behdad at behdad.org>
Date:   Tue Jul 31 22:43:58 2012 -0400

    [GSUB] Minor

diff --git a/src/hb-ot-layout-gsub-table.hh b/src/hb-ot-layout-gsub-table.hh
index 05caee9..605ddb5 100644
--- a/src/hb-ot-layout-gsub-table.hh
+++ b/src/hb-ot-layout-gsub-table.hh
@@ -1315,7 +1315,10 @@ GSUB::substitute_start (hb_face_t *face, hb_buffer_t *buffer)
   HB_BUFFER_ALLOCATE_VAR (buffer, lig_props);
   HB_BUFFER_ALLOCATE_VAR (buffer, syllable);
 
-  const GDEF &gdef = *hb_ot_layout_from_face (face)->gdef;
+  /* TODO This pattern is duplicated from gsubgpos-private.h.  Do something about it. */
+  const GDEF &gdef = hb_ot_layout_from_face (face) &&
+		     !HB_SHAPER_DATA_IS_INVALID (hb_ot_layout_from_face (face)) ?
+		     *hb_ot_layout_from_face (face)->gdef : Null(GDEF);
   unsigned int count = buffer->len;
   for (unsigned int i = 0; i < count; i++) {
     buffer->info[i].lig_props() = buffer->info[i].syllable() = 0;
commit f0fc1df8fc949739b68d55948741016081b69c3a
Author: Behdad Esfahbod <behdad at behdad.org>
Date:   Tue Jul 31 22:43:32 2012 -0400

    [hb-old] Implement getGlyphMetrics()
    
    Still working on it.

diff --git a/src/hb-old.cc b/src/hb-old.cc
index 5285b7f..84a431c 100644
--- a/src/hb-old.cc
+++ b/src/hb-old.cc
@@ -143,7 +143,18 @@ hb_old_getGlyphMetrics (HB_Font old_font,
 			HB_Glyph glyph,
 			HB_GlyphMetrics *metrics)
 {
-  // TODO
+  hb_font_t *font = (hb_font_t *) old_font->userData;
+
+  hb_glyph_extents_t extents;
+
+  hb_font_get_glyph_extents (font, glyph, &extents);
+
+  metrics->xOffset = extents.x_bearing;
+  metrics->yOffset = extents.y_bearing;
+  metrics->width   = extents.width;
+  metrics->height  = extents.height;
+  metrics->x       = hb_font_get_glyph_h_advance (font, glyph);
+  metrics->y       = 0;
 }
 
 static HB_Fixed



More information about the HarfBuzz mailing list