diff options
Diffstat (limited to 'Build/source/libs/harfbuzz/harfbuzz-src/src/hb-aat-layout-kerx-table.hh')
-rw-r--r-- | Build/source/libs/harfbuzz/harfbuzz-src/src/hb-aat-layout-kerx-table.hh | 45 |
1 files changed, 33 insertions, 12 deletions
diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-aat-layout-kerx-table.hh b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-aat-layout-kerx-table.hh index c09a6d31075..6425780910b 100644 --- a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-aat-layout-kerx-table.hh +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-aat-layout-kerx-table.hh @@ -45,6 +45,21 @@ namespace AAT { using namespace OT; +static inline int +kerxTupleKern (int value, + unsigned int tupleCount, + const void *base, + hb_aat_apply_context_t *c) +{ + if (likely (!tupleCount)) return value; + + unsigned int offset = value; + const FWORD *pv = &StructAtOffset<FWORD> (base, offset); + if (unlikely (!pv->sanitize (&c->sanitizer))) return 0; + return *pv; +} + + struct KerxSubTableHeader { inline bool sanitize (hb_sanitize_context_t *c) const @@ -65,6 +80,7 @@ struct KerxSubTableFormat0 { inline int get_kerning (hb_codepoint_t left, hb_codepoint_t right) const { + if (header.tupleCount) return 0; /* TODO kerxTupleKern */ hb_glyph_pair_t pair = {left, right}; int i = pairs.bsearch (pair); return i == -1 ? 0 : pairs[i].get_kerning (); @@ -143,12 +159,12 @@ struct KerxSubTableFormat1 if (flags & Reset) { - depth = 0; + depth = 0; } if (flags & Push) { - if (likely (depth < ARRAY_LENGTH (stack))) + if (likely (depth < ARRAY_LENGTH (stack))) stack[depth++] = buffer->idx; else depth = 0; /* Probably not what CoreText does, but better? */ @@ -157,14 +173,14 @@ struct KerxSubTableFormat1 if (entry->data.kernActionIndex != 0xFFFF) { const FWORD *actions = &kernAction[entry->data.kernActionIndex]; - if (!c->sanitizer.check_array (actions, depth)) + if (!c->sanitizer.check_array (actions, depth)) { depth = 0; return false; } hb_mask_t kern_mask = c->plan->kern_mask; - for (unsigned int i = 0; i < depth; i++) + for (unsigned int i = 0; i < depth; i++) { /* Apparently, when spec says "Each pops one glyph from the kerning stack * and applies the kerning value to it.", it doesn't mean it in that order. @@ -201,6 +217,9 @@ struct KerxSubTableFormat1 if (!c->plan->requested_kerning) return false; + if (header.tupleCount) + return_trace (false); /* TODO kerxTupleKern */ + driver_context_t dc (this, c); StateTableDriver<EntryData> driver (machine, c->buffer, c->font->face); @@ -236,7 +255,7 @@ struct KerxSubTableFormat2 unsigned int offset = l + r; const FWORD *v = &StructAtOffset<FWORD> (&(this+array), offset); if (unlikely (!v->sanitize (&c->sanitizer))) return 0; - return *v; + return kerxTupleKern (*v, header.tupleCount, this, c); } inline bool apply (hb_aat_apply_context_t *c) const @@ -482,7 +501,7 @@ struct KerxSubTableFormat6 if (unlikely (hb_unsigned_mul_overflows (offset, sizeof (FWORD32)))) return 0; const FWORD32 *v = &StructAtOffset<FWORD32> (&(this+t.array), offset * sizeof (FWORD32)); if (unlikely (!v->sanitize (&c->sanitizer))) return 0; - return *v; + return kerxTupleKern (*v, header.tupleCount, &(this+vector), c); } else { @@ -492,7 +511,7 @@ struct KerxSubTableFormat6 unsigned int offset = l + r; const FWORD *v = &StructAtOffset<FWORD> (&(this+t.array), offset * sizeof (FWORD)); if (unlikely (!v->sanitize (&c->sanitizer))) return 0; - return *v; + return kerxTupleKern (*v, header.tupleCount, &(this+vector), c); } } @@ -523,7 +542,9 @@ struct KerxSubTableFormat6 u.s.rowIndexTable.sanitize (c, this) && u.s.columnIndexTable.sanitize (c, this) && c->check_range (this, u.s.array) - )))); + )) && + (header.tupleCount == 0 || + c->check_range (this, vector)))); } struct accelerator_t @@ -559,8 +580,9 @@ struct KerxSubTableFormat6 LOffsetTo<UnsizedArrayOf<FWORD>, false> array; } s; } u; + LOffsetTo<UnsizedArrayOf<FWORD>, false> vector; public: - DEFINE_SIZE_STATIC (32); + DEFINE_SIZE_STATIC (36); }; struct KerxTable @@ -642,9 +664,8 @@ struct kerx { bool reverse; - if (table->u.header.coverage & (KerxTable::CrossStream | KerxTable::Variation) || - table->u.header.tupleCount) - goto skip; /* We do NOT handle cross-stream or variation kerning. */ + if (table->u.header.coverage & (KerxTable::CrossStream)) + goto skip; /* We do NOT handle cross-stream. */ if (HB_DIRECTION_IS_VERTICAL (c->buffer->props.direction) != bool (table->u.header.coverage & KerxTable::Vertical)) |