[HarfBuzz] harfbuzz-ng: Branch 'master' - 5 commits
Behdad Esfahbod
behdad at kemper.freedesktop.org
Thu Aug 2 02:41:57 PDT 2012
src/hb-ot-layout-gpos-table.hh | 2
src/hb-ot-layout-gsub-table.hh | 5 -
src/hb-ot-layout-gsubgpos-private.hh | 10 +-
src/hb-ot-layout-private.hh | 3
src/hb-ot-layout.cc | 34 +++----
src/hb-ot-map-private.hh | 85 +++++++++++------
src/hb-ot-map.cc | 18 +--
src/hb-ot-shape-complex-indic-private.hh | 16 ---
src/hb-ot-shape-complex-indic.cc | 149 ++++++++++++++++++-------------
9 files changed, 184 insertions(+), 138 deletions(-)
New commits:
commit 610e5e8f713bb2a68939b72cb2b801a7aaede4f9
Author: Behdad Esfahbod <behdad at behdad.org>
Date: Thu Aug 2 05:27:46 2012 -0400
[Indic] Streamline feature would_apply()
Comes with some 10% speedup for Devanagari even!
diff --git a/src/hb-ot-map-private.hh b/src/hb-ot-map-private.hh
index 2ba0f76..5e3c967 100644
--- a/src/hb-ot-map-private.hh
+++ b/src/hb-ot-map-private.hh
@@ -42,6 +42,38 @@ struct hb_ot_map_t
public:
+ struct feature_map_t {
+ hb_tag_t tag; /* should be first for our bsearch to work */
+ unsigned int index[2]; /* GSUB/GPOS */
+ unsigned int stage[2]; /* GSUB/GPOS */
+ unsigned int shift;
+ hb_mask_t mask;
+ hb_mask_t _1_mask; /* mask for value=1, for quick access */
+
+ static int cmp (const feature_map_t *a, const feature_map_t *b)
+ { return a->tag < b->tag ? -1 : a->tag > b->tag ? 1 : 0; }
+ };
+
+ struct lookup_map_t {
+ unsigned int index;
+ hb_mask_t mask;
+
+ static int cmp (const lookup_map_t *a, const lookup_map_t *b)
+ { return a->index < b->index ? -1 : a->index > b->index ? 1 : 0; }
+ };
+
+ typedef void (*pause_func_t) (const hb_ot_map_t *map, void *face_or_font, hb_buffer_t *buffer, void *user_data);
+ typedef struct {
+ pause_func_t func;
+ void *user_data;
+ } pause_callback_t;
+
+ struct pause_map_t {
+ unsigned int num_lookups; /* Cumulative */
+ pause_callback_t callback;
+ };
+
+
hb_ot_map_t (void) { memset (this, 0, sizeof (*this)); }
typedef void (*gsub_pause_func_t) (const hb_ot_map_t *map, hb_face_t *face, hb_buffer_t *buffer, void *user_data);
@@ -60,11 +92,30 @@ struct hb_ot_map_t
return map ? map->_1_mask : 0;
}
- inline hb_mask_t get_feature_index (unsigned int table_index, hb_tag_t feature_tag) const {
+ inline unsigned int get_feature_index (unsigned int table_index, hb_tag_t feature_tag) const {
const feature_map_t *map = features.bsearch (&feature_tag);
return map ? map->index[table_index] : HB_OT_LAYOUT_NO_FEATURE_INDEX;
}
+ inline unsigned int get_feature_stage (unsigned int table_index, hb_tag_t feature_tag) const {
+ const feature_map_t *map = features.bsearch (&feature_tag);
+ return map ? map->stage[table_index] : (unsigned int) -1;
+ }
+
+ inline void get_stage_lookups (unsigned int table_index, unsigned int stage,
+ const struct lookup_map_t **plookups, unsigned int *lookup_count) const {
+ if (unlikely (stage == (unsigned int) -1)) {
+ *plookups = NULL;
+ *lookup_count = 0;
+ return;
+ }
+ assert (stage <= pauses[table_index].len);
+ unsigned int start = stage ? pauses[table_index][stage - 1].num_lookups : 0;
+ unsigned int end = stage < pauses[table_index].len ? pauses[table_index][stage].num_lookups : lookups[table_index].len;
+ *plookups = &lookups[table_index][start];
+ *lookup_count = end - start;
+ }
+
inline hb_tag_t get_chosen_script (unsigned int table_index) const
{ return chosen_script[table_index]; }
@@ -80,38 +131,8 @@ struct hb_ot_map_t
pauses[1].finish ();
}
- private:
-
- struct feature_map_t {
- hb_tag_t tag; /* should be first for our bsearch to work */
- unsigned int index[2]; /* GSUB/GPOS */
- unsigned int stage[2]; /* GSUB/GPOS */
- unsigned int shift;
- hb_mask_t mask;
- hb_mask_t _1_mask; /* mask for value=1, for quick access */
-
- static int cmp (const feature_map_t *a, const feature_map_t *b)
- { return a->tag < b->tag ? -1 : a->tag > b->tag ? 1 : 0; }
- };
-
- struct lookup_map_t {
- unsigned int index;
- hb_mask_t mask;
-
- static int cmp (const lookup_map_t *a, const lookup_map_t *b)
- { return a->index < b->index ? -1 : a->index > b->index ? 1 : 0; }
- };
- typedef void (*pause_func_t) (const hb_ot_map_t *map, void *face_or_font, hb_buffer_t *buffer, void *user_data);
- typedef struct {
- pause_func_t func;
- void *user_data;
- } pause_callback_t;
-
- struct pause_map_t {
- unsigned int num_lookups; /* Cumulative */
- pause_callback_t callback;
- };
+ private:
HB_INTERNAL void add_lookups (hb_face_t *face,
unsigned int table_index,
diff --git a/src/hb-ot-map.cc b/src/hb-ot-map.cc
index 20e8e6f..ae0cb61 100644
--- a/src/hb-ot-map.cc
+++ b/src/hb-ot-map.cc
@@ -89,7 +89,8 @@ void hb_ot_map_t::substitute (hb_face_t *face, hb_buffer_t *buffer) const
buffer->clear_output ();
- pause->callback.func (this, face, buffer, pause->callback.user_data);
+ if (pause->callback.func)
+ pause->callback.func (this, face, buffer, pause->callback.user_data);
}
for (; i < lookups[table_index].len; i++)
@@ -106,7 +107,8 @@ void hb_ot_map_t::position (hb_font_t *font, hb_buffer_t *buffer) const
for (; i < pause->num_lookups; i++)
hb_ot_layout_position_lookup_fast (font, buffer, lookups[table_index][i].index, lookups[table_index][i].mask);
- pause->callback.func (this, font, buffer, pause->callback.user_data);
+ if (pause->callback.func)
+ pause->callback.func (this, font, buffer, pause->callback.user_data);
}
for (; i < lookups[table_index].len; i++)
@@ -131,13 +133,11 @@ void hb_ot_map_t::substitute_closure (hb_face_t *face,
void hb_ot_map_builder_t::add_pause (unsigned int table_index, hb_ot_map_t::pause_func_t pause_func, void *user_data)
{
- if (pause_func) {
- pause_info_t *p = pauses[table_index].push ();
- if (likely (p)) {
- p->stage = current_stage[table_index];
- p->callback.func = pause_func;
- p->callback.user_data = user_data;
- }
+ pause_info_t *p = pauses[table_index].push ();
+ if (likely (p)) {
+ p->stage = current_stage[table_index];
+ p->callback.func = pause_func;
+ p->callback.user_data = user_data;
}
current_stage[table_index]++;
diff --git a/src/hb-ot-shape-complex-indic.cc b/src/hb-ot-shape-complex-indic.cc
index ba4fb4d..8e3f3e6 100644
--- a/src/hb-ot-shape-complex-indic.cc
+++ b/src/hb-ot-shape-complex-indic.cc
@@ -106,39 +106,48 @@ compare_codepoint (const void *pa, const void *pb)
return a < b ? -1 : a == b ? 0 : +1;
}
-static bool
-would_substitute (hb_codepoint_t *glyphs,
- unsigned int glyphs_count,
- hb_tag_t feature_tag,
- const hb_ot_map_t *map,
- hb_face_t *face)
+struct consonant_position_closure_t
{
- unsigned int lookup_indices[32];
- unsigned int offset, len;
-
- offset = 0;
- do {
- len = ARRAY_LENGTH (lookup_indices);
- hb_ot_layout_feature_get_lookup_indexes (face, HB_OT_TAG_GSUB,
- map->get_feature_index (0/*GSUB*/, feature_tag),
- offset,
- &len,
- lookup_indices);
-
- for (unsigned int i = 0; i < len; i++)
- if (hb_ot_layout_would_substitute_lookup_fast (face, glyphs, glyphs_count, lookup_indices[i]))
- return true;
-
- offset += len;
- } while (len == ARRAY_LENGTH (lookup_indices));
-
- return false;
-}
+ struct feature_t
+ {
+ feature_t (const hb_ot_map_t *map, hb_tag_t feature_tag)
+ {
+ map->get_stage_lookups (0/*GSUB*/,
+ map->get_feature_stage (0/*GSUB*/, feature_tag),
+ &lookups, &count);
+ }
+
+ inline bool would_substitute (hb_codepoint_t *glyphs,
+ unsigned int glyphs_count,
+ hb_face_t *face) const
+ {
+ for (unsigned int i = 0; i < count; i++)
+ if (hb_ot_layout_would_substitute_lookup_fast (face, glyphs, glyphs_count, lookups[i].index))
+ return true;
+ return false;
+ }
+
+ private:
+ const hb_ot_map_t::lookup_map_t *lookups;
+ unsigned int count;
+ };
+
+ consonant_position_closure_t (const hb_ot_map_t *map_) :
+ map (map_),
+ pref (map_, HB_TAG('p','r','e','f')),
+ blwf (map_, HB_TAG('b','l','w','f')),
+ pstf (map_, HB_TAG('p','s','t','f')) {}
+
+ const hb_ot_map_t *map;
+ feature_t pref;
+ feature_t blwf;
+ feature_t pstf;
+};
static indic_position_t
-consonant_position (hb_codepoint_t u,
- const hb_ot_map_t *map,
- hb_font_t *font)
+consonant_position (hb_codepoint_t u,
+ const consonant_position_closure_t *closure,
+ hb_font_t *font)
{
if ((u & ~0x007F) == 0x1780)
return POS_BELOW_C; /* In Khmer coeng model, post and below forms should not be reordered. */
@@ -148,14 +157,14 @@ consonant_position (hb_codepoint_t u,
if ((u & ~0x007F) == 0x1780) virama = 0x17D2; /* Khmaer */
hb_codepoint_t glyphs[2];
- unsigned int virama_pos = IS_OLD_INDIC_TAG (map->get_chosen_script (0)) ? 1 : 0;
+ unsigned int virama_pos = IS_OLD_INDIC_TAG (closure->map->get_chosen_script (0)) ? 1 : 0;
font->get_glyph (virama, 0, &glyphs[virama_pos]);
font->get_glyph (u, 0, &glyphs[1-virama_pos]);
hb_face_t *face = font->face;
- if (would_substitute (glyphs, ARRAY_LENGTH (glyphs), HB_TAG('p','r','e','f'), map, face)) return POS_BELOW_C;
- if (would_substitute (glyphs, ARRAY_LENGTH (glyphs), HB_TAG('b','l','w','f'), map, face)) return POS_BELOW_C;
- if (would_substitute (glyphs, ARRAY_LENGTH (glyphs), HB_TAG('p','s','t','f'), map, face)) return POS_POST_C;
+ if (closure->pref.would_substitute (glyphs, ARRAY_LENGTH (glyphs), face)) return POS_BELOW_C;
+ if (closure->blwf.would_substitute (glyphs, ARRAY_LENGTH (glyphs), face)) return POS_BELOW_C;
+ if (closure->pstf.would_substitute (glyphs, ARRAY_LENGTH (glyphs), face)) return POS_POST_C;
return POS_BASE_C;
}
@@ -260,7 +269,7 @@ is_halant_or_coeng (const hb_glyph_info_t &info)
static inline void
set_indic_properties (hb_glyph_info_t &info,
- const hb_ot_map_t *map,
+ const consonant_position_closure_t *closure,
hb_font_t *font)
{
hb_codepoint_t u = info.codepoint;
@@ -322,7 +331,7 @@ set_indic_properties (hb_glyph_info_t &info,
if ((FLAG (cat) & CONSONANT_FLAGS))
{
- pos = consonant_position (u, map, font);
+ pos = consonant_position (u, closure, font);
if (is_ra (u))
cat = OT_Ra;
}
@@ -462,9 +471,11 @@ setup_masks_indic (const hb_ot_complex_shaper_t *shaper,
/* We cannot setup masks here. We save information about characters
* and setup masks later on in a pause-callback. */
+ consonant_position_closure_t closure (map);
+
unsigned int count = buffer->len;
for (unsigned int i = 0; i < count; i++)
- set_indic_properties (buffer->info[i], map, font);
+ set_indic_properties (buffer->info[i], &closure, font);
}
static int
commit 1d002048d5afcd45abbb09fdf0419f13b2e2265c
Author: Behdad Esfahbod <behdad at behdad.org>
Date: Thu Aug 2 05:01:11 2012 -0400
[Indic] Minor
diff --git a/src/hb-ot-shape-complex-indic-private.hh b/src/hb-ot-shape-complex-indic-private.hh
index 7767ae7..ce9a184 100644
--- a/src/hb-ot-shape-complex-indic-private.hh
+++ b/src/hb-ot-shape-complex-indic-private.hh
@@ -38,22 +38,6 @@
#define indic_position() complex_var_persistent_u8_1() /* indic_matra_category_t */
-
-#define IN_HALF_BLOCK(u, Base) (((u) & ~0x7F) == (Base))
-
-#define IS_DEVA(u) (IN_HALF_BLOCK (u, 0x900))
-#define IS_BENG(u) (IN_HALF_BLOCK (u, 0x980))
-#define IS_GURM(u) (IN_HALF_BLOCK (u, 0xA00))
-#define IS_GUJA(u) (IN_HALF_BLOCK (u, 0xA80))
-#define IS_ORYA(u) (IN_HALF_BLOCK (u, 0xB00))
-#define IS_TAML(u) (IN_HALF_BLOCK (u, 0xB80))
-#define IS_TELU(u) (IN_HALF_BLOCK (u, 0xC00))
-#define IS_KNDA(u) (IN_HALF_BLOCK (u, 0xC80))
-#define IS_MLYM(u) (IN_HALF_BLOCK (u, 0xD00))
-#define IS_SINH(u) (IN_HALF_BLOCK (u, 0xD80))
-
-
-
#define INDIC_TABLE_ELEMENT_TYPE uint8_t
/* Cateories used in the OpenType spec:
diff --git a/src/hb-ot-shape-complex-indic.cc b/src/hb-ot-shape-complex-indic.cc
index 255e00e..ba4fb4d 100644
--- a/src/hb-ot-shape-complex-indic.cc
+++ b/src/hb-ot-shape-complex-indic.cc
@@ -28,18 +28,36 @@
#include "hb-ot-shape-private.hh"
#include "hb-ot-layout-private.hh"
+
+#define IN_HALF_BLOCK(u, Base) (((u) & ~0x7F) == (Base))
+
+#define IS_DEVA(u) (IN_HALF_BLOCK (u, 0x0900))
+#define IS_BENG(u) (IN_HALF_BLOCK (u, 0x0980))
+#define IS_GURM(u) (IN_HALF_BLOCK (u, 0x0A00))
+#define IS_GUJA(u) (IN_HALF_BLOCK (u, 0x0A80))
+#define IS_ORYA(u) (IN_HALF_BLOCK (u, 0x0B00))
+#define IS_TAML(u) (IN_HALF_BLOCK (u, 0x0B80))
+#define IS_TELU(u) (IN_HALF_BLOCK (u, 0x0C00))
+#define IS_KNDA(u) (IN_HALF_BLOCK (u, 0x0C80))
+#define IS_MLYM(u) (IN_HALF_BLOCK (u, 0x0D00))
+#define IS_SINH(u) (IN_HALF_BLOCK (u, 0x0D80))
+#define IS_KHMR(u) (IN_HALF_BLOCK (u, 0x1780))
+
+
#define OLD_INDIC_TAG(script) (((hb_tag_t) script) | 0x20000000)
#define IS_OLD_INDIC_TAG(tag) ( \
- (tag) == OLD_INDIC_TAG (HB_SCRIPT_BENGALI) || \
- (tag) == OLD_INDIC_TAG (HB_SCRIPT_DEVANAGARI) || \
- (tag) == OLD_INDIC_TAG (HB_SCRIPT_GUJARATI) || \
- (tag) == OLD_INDIC_TAG (HB_SCRIPT_GURMUKHI) || \
- (tag) == OLD_INDIC_TAG (HB_SCRIPT_KANNADA) || \
- (tag) == OLD_INDIC_TAG (HB_SCRIPT_MALAYALAM) || \
- (tag) == OLD_INDIC_TAG (HB_SCRIPT_ORIYA) || \
- (tag) == OLD_INDIC_TAG (HB_SCRIPT_TAMIL) || \
- (tag) == OLD_INDIC_TAG (HB_SCRIPT_TELUGU) \
- )
+ (tag) == OLD_INDIC_TAG (HB_SCRIPT_BENGALI) || \
+ (tag) == OLD_INDIC_TAG (HB_SCRIPT_DEVANAGARI) || \
+ (tag) == OLD_INDIC_TAG (HB_SCRIPT_GUJARATI) || \
+ (tag) == OLD_INDIC_TAG (HB_SCRIPT_GURMUKHI) || \
+ (tag) == OLD_INDIC_TAG (HB_SCRIPT_KANNADA) || \
+ (tag) == OLD_INDIC_TAG (HB_SCRIPT_MALAYALAM) || \
+ (tag) == OLD_INDIC_TAG (HB_SCRIPT_ORIYA) || \
+ (tag) == OLD_INDIC_TAG (HB_SCRIPT_TAMIL) || \
+ (tag) == OLD_INDIC_TAG (HB_SCRIPT_TELUGU) || \
+ 0)
+
+
struct indic_options_t
{
int initialized : 1;
@@ -123,10 +141,11 @@ consonant_position (hb_codepoint_t u,
hb_font_t *font)
{
if ((u & ~0x007F) == 0x1780)
- return POS_BELOW_C; /* In Khmer coeng model, all are subjoining. */
+ return POS_BELOW_C; /* In Khmer coeng model, post and below forms should not be reordered. */
hb_codepoint_t virama = (u & ~0x007F) | 0x004D;
if ((u & ~0x007F) == 0x0D80) virama = 0x0DCA; /* Sinahla */
+ if ((u & ~0x007F) == 0x1780) virama = 0x17D2; /* Khmaer */
hb_codepoint_t glyphs[2];
unsigned int virama_pos = IS_OLD_INDIC_TAG (map->get_chosen_script (0)) ? 1 : 0;
@@ -142,27 +161,29 @@ consonant_position (hb_codepoint_t u,
#define MATRA_POS_LEFT(u) POS_PRE_M
#define MATRA_POS_RIGHT(u) ( \
- IS_DEVA(u) ? POS_AFTER_SUB : \
- IS_BENG(u) ? POS_AFTER_POST : \
- IS_GURM(u) ? POS_AFTER_POST : \
- IS_GUJA(u) ? POS_AFTER_POST : \
- IS_ORYA(u) ? POS_AFTER_POST : \
- IS_TAML(u) ? POS_AFTER_POST : \
+ IS_DEVA(u) ? POS_AFTER_SUB : \
+ IS_BENG(u) ? POS_AFTER_POST : \
+ IS_GURM(u) ? POS_AFTER_POST : \
+ IS_GUJA(u) ? POS_AFTER_POST : \
+ IS_ORYA(u) ? POS_AFTER_POST : \
+ IS_TAML(u) ? POS_AFTER_POST : \
IS_TELU(u) ? (u <= 0x0C42 ? POS_BEFORE_SUB : POS_AFTER_SUB) : \
IS_KNDA(u) ? (u < 0x0CC3 || u > 0xCD6 ? POS_BEFORE_SUB : POS_AFTER_SUB) : \
- IS_MLYM(u) ? POS_AFTER_POST : \
- IS_SINH(u) ? POS_AFTER_SUB : \
- /*default*/ POS_AFTER_SUB \
+ IS_MLYM(u) ? POS_AFTER_POST : \
+ IS_SINH(u) ? POS_AFTER_SUB : \
+ IS_KHMR(u) ? POS_AFTER_POST : \
+ /*default*/ POS_AFTER_SUB \
)
#define MATRA_POS_TOP(u) ( /* BENG and MLYM don't have top matras. */ \
IS_DEVA(u) ? POS_AFTER_SUB : \
- IS_GURM(u) ? POS_AFTER_POST : /* Deviate from spec */ \
+ IS_GURM(u) ? POS_AFTER_POST : /* Deviate from spec */ \
IS_GUJA(u) ? POS_AFTER_SUB : \
IS_ORYA(u) ? POS_AFTER_MAIN : \
IS_TAML(u) ? POS_AFTER_SUB : \
IS_TELU(u) ? POS_BEFORE_SUB : \
IS_KNDA(u) ? POS_BEFORE_SUB : \
IS_SINH(u) ? POS_AFTER_SUB : \
+ IS_KHMR(u) ? POS_AFTER_POST : \
/*default*/ POS_AFTER_SUB \
)
#define MATRA_POS_BOTTOM(u) ( \
@@ -176,6 +197,7 @@ consonant_position (hb_codepoint_t u,
IS_KNDA(u) ? POS_BEFORE_SUB : \
IS_MLYM(u) ? POS_AFTER_POST : \
IS_SINH(u) ? POS_AFTER_SUB : \
+ IS_KHMR(u) ? POS_AFTER_POST : \
/*default*/ POS_AFTER_SUB \
)
commit 6f7611375521c6d285a9aa763f2ea5cb44cd0d39
Author: Behdad Esfahbod <behdad at behdad.org>
Date: Thu Aug 2 04:00:31 2012 -0400
[GSUB/GPOS] Check array size before accessing digests
diff --git a/src/hb-ot-layout-private.hh b/src/hb-ot-layout-private.hh
index d87a138..ea2e64d 100644
--- a/src/hb-ot-layout-private.hh
+++ b/src/hb-ot-layout-private.hh
@@ -170,6 +170,9 @@ struct hb_ot_layout_t
const struct GSUB *gsub;
const struct GPOS *gpos;
+ unsigned int gsub_lookup_count;
+ unsigned int gpos_lookup_count;
+
hb_set_digest_t *gsub_digests;
hb_set_digest_t *gpos_digests;
};
diff --git a/src/hb-ot-layout.cc b/src/hb-ot-layout.cc
index c8f4d69..63f3095 100644
--- a/src/hb-ot-layout.cc
+++ b/src/hb-ot-layout.cc
@@ -58,22 +58,22 @@ _hb_ot_layout_create (hb_face_t *face)
layout->gpos_blob = Sanitizer<GPOS>::sanitize (hb_face_reference_table (face, HB_OT_TAG_GPOS));
layout->gpos = Sanitizer<GPOS>::lock_instance (layout->gpos_blob);
+ layout->gsub_lookup_count = layout->gsub->get_lookup_count ();
+ layout->gpos_lookup_count = layout->gpos->get_lookup_count ();
+
layout->gsub_digests = (hb_set_digest_t *) calloc (layout->gsub->get_lookup_count (), sizeof (hb_set_digest_t));
layout->gpos_digests = (hb_set_digest_t *) calloc (layout->gpos->get_lookup_count (), sizeof (hb_set_digest_t));
- if (unlikely ((layout->gsub->get_lookup_count() && !layout->gsub_digests) ||
- (layout->gpos->get_lookup_count() && !layout->gpos_digests)))
+ if (unlikely ((layout->gsub_lookup_count && !layout->gsub_digests) ||
+ (layout->gpos_lookup_count && !layout->gpos_digests)))
{
_hb_ot_layout_destroy (layout);
return NULL;
}
- unsigned int count;
- count = layout->gsub->get_lookup_count();
- for (unsigned int i = 0; i < count; i++)
+ for (unsigned int i = 0; i < layout->gsub_lookup_count; i++)
layout->gsub->add_coverage (&layout->gsub_digests[i], i);
- count = layout->gpos->get_lookup_count();
- for (unsigned int i = 0; i < count; i++)
+ for (unsigned int i = 0; i < layout->gpos_lookup_count; i++)
layout->gpos->add_coverage (&layout->gpos_digests[i], i);
return layout;
@@ -405,9 +405,8 @@ hb_ot_layout_would_substitute_lookup (hb_face_t *face,
unsigned int glyphs_length,
unsigned int lookup_index)
{
- if (unlikely (glyphs_length < 1 || glyphs_length > 2)) return false;
- hb_would_apply_context_t c (face, glyphs[0], glyphs_length == 2 ? glyphs[1] : -1, NULL);
- return _get_gsub (face).would_substitute_lookup (&c, lookup_index);
+ if (unlikely (!hb_ot_shaper_face_data_ensure (face))) return false;
+ return hb_ot_layout_would_substitute_lookup_fast (face, glyphs, glyphs_length, lookup_index);
}
hb_bool_t
@@ -417,6 +416,7 @@ hb_ot_layout_would_substitute_lookup_fast (hb_face_t *face,
unsigned int lookup_index)
{
if (unlikely (glyphs_length < 1 || glyphs_length > 2)) return false;
+ if (unlikely (lookup_index >= hb_ot_layout_from_face (face)->gsub_lookup_count)) return false;
hb_would_apply_context_t c (face, glyphs[0], glyphs_length == 2 ? glyphs[1] : -1, &hb_ot_layout_from_face (face)->gsub_digests[lookup_index]);
return hb_ot_layout_from_face (face)->gsub->would_substitute_lookup (&c, lookup_index);
}
@@ -433,8 +433,8 @@ hb_ot_layout_substitute_lookup (hb_face_t *face,
unsigned int lookup_index,
hb_mask_t mask)
{
- hb_apply_context_t c (NULL, face, buffer, mask, NULL);
- return _get_gsub (face).substitute_lookup (&c, lookup_index);
+ if (unlikely (!hb_ot_shaper_face_data_ensure (face))) return false;
+ return hb_ot_layout_substitute_lookup_fast (face, buffer, lookup_index, mask);
}
hb_bool_t
@@ -443,6 +443,7 @@ hb_ot_layout_substitute_lookup_fast (hb_face_t *face,
unsigned int lookup_index,
hb_mask_t mask)
{
+ if (unlikely (lookup_index >= hb_ot_layout_from_face (face)->gsub_lookup_count)) return false;
hb_apply_context_t c (NULL, face, buffer, mask, &hb_ot_layout_from_face (face)->gsub_digests[lookup_index]);
return hb_ot_layout_from_face (face)->gsub->substitute_lookup (&c, lookup_index);
}
@@ -484,8 +485,8 @@ hb_ot_layout_position_lookup (hb_font_t *font,
unsigned int lookup_index,
hb_mask_t mask)
{
- hb_apply_context_t c (font, font->face, buffer, mask, NULL);
- return _get_gpos (font->face).position_lookup (&c, lookup_index);
+ if (unlikely (!hb_ot_shaper_face_data_ensure (font->face))) return false;
+ return hb_ot_layout_position_lookup_fast (font, buffer, lookup_index, mask);
}
hb_bool_t
@@ -494,6 +495,7 @@ hb_ot_layout_position_lookup_fast (hb_font_t *font,
unsigned int lookup_index,
hb_mask_t mask)
{
+ if (unlikely (lookup_index >= hb_ot_layout_from_face (font->face)->gpos_lookup_count)) return false;
hb_apply_context_t c (font, font->face, buffer, mask, &hb_ot_layout_from_face (font->face)->gpos_digests[lookup_index]);
return hb_ot_layout_from_face (font->face)->gpos->position_lookup (&c, lookup_index);
}
@@ -503,5 +505,3 @@ hb_ot_layout_position_finish (hb_font_t *font, hb_buffer_t *buffer, hb_bool_t ze
{
GPOS::position_finish (font, buffer, zero_width_attached_marks);
}
-
-
commit 22148b8c4af3ed296d96e969cdd47bac97b32307
Author: Behdad Esfahbod <behdad at behdad.org>
Date: Thu Aug 2 03:51:51 2012 -0400
Use Coverage digests in would_apply
diff --git a/src/hb-ot-layout-gsub-table.hh b/src/hb-ot-layout-gsub-table.hh
index d91f926..77ff3d9 100644
--- a/src/hb-ot-layout-gsub-table.hh
+++ b/src/hb-ot-layout-gsub-table.hh
@@ -1170,6 +1170,7 @@ struct SubstLookup : Lookup
inline bool would_apply (hb_would_apply_context_t *c) const
{
+ if (!c->digest.may_have (c->first)) return false;
unsigned int lookup_type = get_type ();
unsigned int count = get_subtable_count ();
for (unsigned int i = 0; i < count; i++)
diff --git a/src/hb-ot-layout-gsubgpos-private.hh b/src/hb-ot-layout-gsubgpos-private.hh
index bb43ade..15a0b0c 100644
--- a/src/hb-ot-layout-gsubgpos-private.hh
+++ b/src/hb-ot-layout-gsubgpos-private.hh
@@ -77,14 +77,18 @@ struct hb_would_apply_context_t
hb_face_t *face;
hb_codepoint_t first;
hb_codepoint_t second;
+ const hb_set_digest_t digest;
unsigned int len;
unsigned int debug_depth;
hb_would_apply_context_t (hb_face_t *face_,
hb_codepoint_t first_,
- hb_codepoint_t second_ = -1) :
+ hb_codepoint_t second_,
+ const hb_set_digest_t *digest_
+ ) :
face (face_),
first (first_), second (second_), len (second == (hb_codepoint_t) -1 ? 1 : 2),
+ digest (*digest_),
debug_depth (0) {};
};
diff --git a/src/hb-ot-layout.cc b/src/hb-ot-layout.cc
index b680d9c..c8f4d69 100644
--- a/src/hb-ot-layout.cc
+++ b/src/hb-ot-layout.cc
@@ -406,7 +406,7 @@ hb_ot_layout_would_substitute_lookup (hb_face_t *face,
unsigned int lookup_index)
{
if (unlikely (glyphs_length < 1 || glyphs_length > 2)) return false;
- hb_would_apply_context_t c (face, glyphs[0], glyphs_length == 2 ? glyphs[1] : -1);
+ hb_would_apply_context_t c (face, glyphs[0], glyphs_length == 2 ? glyphs[1] : -1, NULL);
return _get_gsub (face).would_substitute_lookup (&c, lookup_index);
}
@@ -417,7 +417,7 @@ hb_ot_layout_would_substitute_lookup_fast (hb_face_t *face,
unsigned int lookup_index)
{
if (unlikely (glyphs_length < 1 || glyphs_length > 2)) return false;
- hb_would_apply_context_t c (face, glyphs[0], glyphs_length == 2 ? glyphs[1] : -1);
+ hb_would_apply_context_t c (face, glyphs[0], glyphs_length == 2 ? glyphs[1] : -1, &hb_ot_layout_from_face (face)->gsub_digests[lookup_index]);
return hb_ot_layout_from_face (face)->gsub->would_substitute_lookup (&c, lookup_index);
}
commit 6c459c8fef85bc44f45d7b58c28a34abfb2c33fc
Author: Behdad Esfahbod <behdad at behdad.org>
Date: Thu Aug 2 03:45:53 2012 -0400
Minor
diff --git a/src/hb-ot-layout-gpos-table.hh b/src/hb-ot-layout-gpos-table.hh
index c9afd31..41168b2 100644
--- a/src/hb-ot-layout-gpos-table.hh
+++ b/src/hb-ot-layout-gpos-table.hh
@@ -1543,7 +1543,7 @@ struct PosLookup : Lookup
while (c->buffer->idx < c->buffer->len)
{
if ((c->buffer->cur().mask & c->lookup_mask) &&
- c->digest->may_have (c->buffer->cur().codepoint) &&
+ c->digest.may_have (c->buffer->cur().codepoint) &&
apply_once (c))
ret = true;
else
diff --git a/src/hb-ot-layout-gsub-table.hh b/src/hb-ot-layout-gsub-table.hh
index b836df9..d91f926 100644
--- a/src/hb-ot-layout-gsub-table.hh
+++ b/src/hb-ot-layout-gsub-table.hh
@@ -1211,7 +1211,7 @@ struct SubstLookup : Lookup
while (c->buffer->idx < c->buffer->len)
{
if ((c->buffer->cur().mask & c->lookup_mask) &&
- c->digest->may_have (c->buffer->cur().codepoint) &&
+ c->digest.may_have (c->buffer->cur().codepoint) &&
apply_once (c))
ret = true;
else
@@ -1227,7 +1227,7 @@ struct SubstLookup : Lookup
do
{
if ((c->buffer->cur().mask & c->lookup_mask) &&
- c->digest->may_have (c->buffer->cur().codepoint) &&
+ c->digest.may_have (c->buffer->cur().codepoint) &&
apply_once (c))
ret = true;
else
diff --git a/src/hb-ot-layout-gsubgpos-private.hh b/src/hb-ot-layout-gsubgpos-private.hh
index 7a3f32e..bb43ade 100644
--- a/src/hb-ot-layout-gsubgpos-private.hh
+++ b/src/hb-ot-layout-gsubgpos-private.hh
@@ -110,7 +110,7 @@ struct hb_apply_context_t
unsigned int debug_depth;
const GDEF &gdef;
bool has_glyph_classes;
- const hb_set_digest_t *digest;
+ const hb_set_digest_t digest;
hb_apply_context_t (hb_font_t *font_,
@@ -127,7 +127,7 @@ struct hb_apply_context_t
!HB_SHAPER_DATA_IS_INVALID (hb_ot_layout_from_face (face_)) ?
*hb_ot_layout_from_face (face_)->gdef : Null(GDEF)),
has_glyph_classes (gdef.has_glyph_classes ()),
- digest (digest_) {}
+ digest (*digest_) {}
void set_lookup (const Lookup &l) {
lookup_props = l.get_props ();
More information about the HarfBuzz
mailing list