[HarfBuzz] harfbuzz-ng: Branch 'master'

Behdad Esfahbod behdad at kemper.freedesktop.org
Tue Apr 10 15:03:19 PDT 2012


 src/hb-ot-shape-complex-arabic.cc  |   12 +++++++-----
 src/hb-ot-shape-complex-indic.cc   |    2 +-
 src/hb-ot-shape-complex-misc.cc    |    6 +++---
 src/hb-ot-shape-complex-private.hh |    7 ++++---
 src/hb-ot-shape.cc                 |    2 +-
 5 files changed, 16 insertions(+), 13 deletions(-)

New commits:
commit acd88e659fdb2fa1cbf7171f0a1c7fbc81b9f298
Author: Behdad Esfahbod <behdad at behdad.org>
Date:   Tue Apr 10 18:02:20 2012 -0400

    In Arabic fallback shaping, check that the font has glyph for new char

diff --git a/src/hb-ot-shape-complex-arabic.cc b/src/hb-ot-shape-complex-arabic.cc
index c44c27c..4b6f54d 100644
--- a/src/hb-ot-shape-complex-arabic.cc
+++ b/src/hb-ot-shape-complex-arabic.cc
@@ -205,20 +205,22 @@ _hb_ot_shape_complex_normalization_preference_arabic (void)
 
 
 static void
-arabic_fallback_shape (hb_buffer_t *buffer)
+arabic_fallback_shape (hb_font_t *font, hb_buffer_t *buffer)
 {
   unsigned int count = buffer->len;
+  hb_codepoint_t glyph;
 
   /* Shape to presentation forms */
   for (unsigned int i = 0; i < count; i++)
-    buffer->info[i].codepoint = get_arabic_shape (buffer->info[i].codepoint, buffer->info[i].arabic_shaping_action());
+    if (hb_font_get_glyph (font, buffer->info[i].codepoint, 0, &glyph))
+      buffer->info[i].codepoint = get_arabic_shape (buffer->info[i].codepoint, buffer->info[i].arabic_shaping_action());
 
   /* Mandatory ligatures */
   buffer->clear_output ();
   for (buffer->idx = 0; buffer->idx + 1 < count;) {
     uint16_t ligature = get_ligature (buffer->info[buffer->idx].codepoint,
 				      buffer->info[buffer->idx + 1].codepoint);
-    if (likely (!ligature)) {
+    if (likely (!ligature) || !(hb_font_get_glyph (font, ligature, 0, &glyph))) {
       buffer->next_glyph ();
       continue;
     }
@@ -234,7 +236,7 @@ arabic_fallback_shape (hb_buffer_t *buffer)
 }
 
 void
-_hb_ot_shape_complex_setup_masks_arabic (hb_ot_map_t *map, hb_buffer_t *buffer)
+_hb_ot_shape_complex_setup_masks_arabic (hb_ot_map_t *map, hb_buffer_t *buffer, hb_font_t *font)
 {
   unsigned int count = buffer->len;
   unsigned int prev = 0, state = 0;
@@ -281,7 +283,7 @@ _hb_ot_shape_complex_setup_masks_arabic (hb_ot_map_t *map, hb_buffer_t *buffer)
      *   Most probably it's safe to assume that init/medi/fina/isol
      *   still mean Arabic shaping, although they do not have to.
      */
-    arabic_fallback_shape (buffer);
+    arabic_fallback_shape (font, buffer);
   }
 
   HB_BUFFER_DEALLOCATE_VAR (buffer, arabic_shaping_action);
diff --git a/src/hb-ot-shape-complex-indic.cc b/src/hb-ot-shape-complex-indic.cc
index 9dcba81..afac95b 100644
--- a/src/hb-ot-shape-complex-indic.cc
+++ b/src/hb-ot-shape-complex-indic.cc
@@ -378,7 +378,7 @@ _hb_ot_shape_complex_normalization_preference_indic (void)
 
 
 void
-_hb_ot_shape_complex_setup_masks_indic (hb_ot_map_t *map, hb_buffer_t *buffer)
+_hb_ot_shape_complex_setup_masks_indic (hb_ot_map_t *map, hb_buffer_t *buffer, hb_font_t *font)
 {
   HB_BUFFER_ALLOCATE_VAR (buffer, indic_category);
   HB_BUFFER_ALLOCATE_VAR (buffer, indic_position);
diff --git a/src/hb-ot-shape-complex-misc.cc b/src/hb-ot-shape-complex-misc.cc
index 23a5b52..5880e32 100644
--- a/src/hb-ot-shape-complex-misc.cc
+++ b/src/hb-ot-shape-complex-misc.cc
@@ -48,7 +48,7 @@ _hb_ot_shape_complex_normalization_preference_default (void)
 }
 
 void
-_hb_ot_shape_complex_setup_masks_default (hb_ot_map_t *map, hb_buffer_t *buffer)
+_hb_ot_shape_complex_setup_masks_default (hb_ot_map_t *map, hb_buffer_t *buffer, hb_font_t *font)
 {
 }
 
@@ -68,7 +68,7 @@ _hb_ot_shape_complex_normalization_preference_hangul (void)
 }
 
 void
-_hb_ot_shape_complex_setup_masks_hangul (hb_ot_map_t *map, hb_buffer_t *buffer)
+_hb_ot_shape_complex_setup_masks_hangul (hb_ot_map_t *map, hb_buffer_t *buffer, hb_font_t *font)
 {
 }
 
@@ -88,7 +88,7 @@ _hb_ot_shape_complex_normalization_preference_thai (void)
 }
 
 void
-_hb_ot_shape_complex_setup_masks_thai (hb_ot_map_t *map, hb_buffer_t *buffer)
+_hb_ot_shape_complex_setup_masks_thai (hb_ot_map_t *map, hb_buffer_t *buffer, hb_font_t *font)
 {
   /* The following is NOT specified in the MS OT Thai spec, however, it seems
    * to be what Uniscribe and other engines implement.  According to Eric Muller:
diff --git a/src/hb-ot-shape-complex-private.hh b/src/hb-ot-shape-complex-private.hh
index 75948c0..6a868d9 100644
--- a/src/hb-ot-shape-complex-private.hh
+++ b/src/hb-ot-shape-complex-private.hh
@@ -280,7 +280,7 @@ hb_ot_shape_complex_normalization_preference (hb_ot_complex_shaper_t shaper)
  * Shapers should use map to get feature masks and set on buffer.
  */
 
-typedef void hb_ot_shape_complex_setup_masks_func_t (hb_ot_map_t *map, hb_buffer_t *buffer);
+typedef void hb_ot_shape_complex_setup_masks_func_t (hb_ot_map_t *map, hb_buffer_t *buffer, hb_font_t *font);
 #define HB_COMPLEX_SHAPER_IMPLEMENT(name) \
   HB_INTERNAL hb_ot_shape_complex_setup_masks_func_t _hb_ot_shape_complex_setup_masks_##name;
   HB_COMPLEX_SHAPERS_IMPLEMENT_SHAPERS
@@ -289,12 +289,13 @@ typedef void hb_ot_shape_complex_setup_masks_func_t (hb_ot_map_t *map, hb_buffer
 static inline void
 hb_ot_shape_complex_setup_masks (hb_ot_complex_shaper_t shaper,
 				 hb_ot_map_t *map,
-				 hb_buffer_t *buffer)
+				 hb_buffer_t *buffer,
+				 hb_font_t *font)
 {
   switch (shaper) {
     default:
 #define HB_COMPLEX_SHAPER_IMPLEMENT(name) \
-    case hb_ot_complex_shaper_##name:	_hb_ot_shape_complex_setup_masks_##name (map, buffer); return;
+    case hb_ot_complex_shaper_##name:	_hb_ot_shape_complex_setup_masks_##name (map, buffer, font); return;
     HB_COMPLEX_SHAPERS_IMPLEMENT_SHAPERS
 #undef HB_COMPLEX_SHAPER_IMPLEMENT
   }
diff --git a/src/hb-ot-shape.cc b/src/hb-ot-shape.cc
index 8b3a334..34c0d52 100644
--- a/src/hb-ot-shape.cc
+++ b/src/hb-ot-shape.cc
@@ -114,7 +114,7 @@ hb_ot_shape_setup_masks (hb_ot_shape_context_t *c)
   hb_mask_t global_mask = c->plan->map.get_global_mask ();
   c->buffer->reset_masks (global_mask);
 
-  hb_ot_shape_complex_setup_masks (c->plan->shaper, &c->plan->map, c->buffer);
+  hb_ot_shape_complex_setup_masks (c->plan->shaper, &c->plan->map, c->buffer, c->font);
 
   for (unsigned int i = 0; i < c->num_user_features; i++)
   {



More information about the HarfBuzz mailing list