| Index: third_party/harfbuzz-ng/src/hb-ot-layout-common-private.hh
|
| diff --git a/third_party/harfbuzz-ng/src/hb-ot-layout-common-private.hh b/third_party/harfbuzz-ng/src/hb-ot-layout-common-private.hh
|
| index 2943a7f672c3ec99a3e8ec2c6cb7e993895eac45..f5a067aec9d21315b6a39afa0a7ccc15a3e36e86 100644
|
| --- a/third_party/harfbuzz-ng/src/hb-ot-layout-common-private.hh
|
| +++ b/third_party/harfbuzz-ng/src/hb-ot-layout-common-private.hh
|
| @@ -34,7 +34,10 @@
|
| #include "hb-set-private.hh"
|
|
|
|
|
| -#define NOT_COVERED ((unsigned int) 0x110000)
|
| +namespace OT {
|
| +
|
| +
|
| +#define NOT_COVERED ((unsigned int) -1)
|
| #define MAX_NESTING_LEVEL 8
|
|
|
|
|
| @@ -134,6 +137,11 @@ struct RangeRecord
|
| return glyphs->intersects (start, end);
|
| }
|
|
|
| + template <typename set_t>
|
| + inline void add_coverage (set_t *glyphs) const {
|
| + glyphs->add_range (start, end);
|
| + }
|
| +
|
| GlyphID start; /* First GlyphID in the range */
|
| GlyphID end; /* Last GlyphID in the range */
|
| USHORT value; /* Value */
|
| @@ -227,7 +235,7 @@ struct Script
|
| return TRACE_RETURN (defaultLangSys.sanitize (c, this) && langSys.sanitize (c, this));
|
| }
|
|
|
| - private:
|
| + protected:
|
| OffsetTo<LangSys>
|
| defaultLangSys; /* Offset to DefaultLangSys table--from
|
| * beginning of Script table--may be Null */
|
| @@ -305,11 +313,29 @@ struct Lookup
|
| return flag;
|
| }
|
|
|
| + inline bool serialize (hb_serialize_context_t *c,
|
| + unsigned int lookup_type,
|
| + uint32_t lookup_props,
|
| + unsigned int num_subtables)
|
| + {
|
| + TRACE_SERIALIZE ();
|
| + if (unlikely (!c->extend_min (*this))) return TRACE_RETURN (false);
|
| + lookupType.set (lookup_type);
|
| + lookupFlag.set (lookup_props & 0xFFFF);
|
| + if (unlikely (!subTable.serialize (c, num_subtables))) return TRACE_RETURN (false);
|
| + if (lookupFlag & LookupFlag::UseMarkFilteringSet)
|
| + {
|
| + USHORT &markFilteringSet = StructAfter<USHORT> (subTable);
|
| + markFilteringSet.set (lookup_props >> 16);
|
| + }
|
| + return TRACE_RETURN (true);
|
| + }
|
| +
|
| inline bool sanitize (hb_sanitize_context_t *c) {
|
| TRACE_SANITIZE ();
|
| /* Real sanitize of the subtables is done by GSUB/GPOS/... */
|
| if (!(c->check_struct (this) && subTable.sanitize (c))) return TRACE_RETURN (false);
|
| - if (unlikely (lookupFlag & LookupFlag::UseMarkFilteringSet))
|
| + if (lookupFlag & LookupFlag::UseMarkFilteringSet)
|
| {
|
| USHORT &markFilteringSet = StructAfter<USHORT> (subTable);
|
| if (!markFilteringSet.sanitize (c)) return TRACE_RETURN (false);
|
| @@ -343,9 +369,22 @@ struct CoverageFormat1
|
| inline unsigned int get_coverage (hb_codepoint_t glyph_id) const
|
| {
|
| int i = glyphArray.search (glyph_id);
|
| - if (i != -1)
|
| - return i;
|
| - return NOT_COVERED;
|
| + ASSERT_STATIC (((unsigned int) -1) == NOT_COVERED);
|
| + return i;
|
| + }
|
| +
|
| + inline bool serialize (hb_serialize_context_t *c,
|
| + Supplier<GlyphID> &glyphs,
|
| + unsigned int num_glyphs)
|
| + {
|
| + TRACE_SERIALIZE ();
|
| + if (unlikely (!c->extend_min (*this))) return TRACE_RETURN (false);
|
| + glyphArray.len.set (num_glyphs);
|
| + if (unlikely (!c->extend (glyphArray))) return TRACE_RETURN (false);
|
| + for (unsigned int i = 0; i < num_glyphs; i++)
|
| + glyphArray[i] = glyphs[i];
|
| + glyphs.advance (num_glyphs);
|
| + return TRACE_RETURN (true);
|
| }
|
|
|
| inline bool sanitize (hb_sanitize_context_t *c) {
|
| @@ -357,6 +396,13 @@ struct CoverageFormat1
|
| return glyphs->has (glyphArray[index]);
|
| }
|
|
|
| + template <typename set_t>
|
| + inline void add_coverage (set_t *glyphs) const {
|
| + unsigned int count = glyphArray.len;
|
| + for (unsigned int i = 0; i < count; i++)
|
| + glyphs->add (glyphArray[i]);
|
| + }
|
| +
|
| struct Iter {
|
| inline void init (const struct CoverageFormat1 &c_) { c = &c_; i = 0; };
|
| inline bool more (void) { return i < c->glyphArray.len; }
|
| @@ -369,7 +415,7 @@ struct CoverageFormat1
|
| unsigned int i;
|
| };
|
|
|
| - private:
|
| + protected:
|
| USHORT coverageFormat; /* Format identifier--format = 1 */
|
| SortedArrayOf<GlyphID>
|
| glyphArray; /* Array of GlyphIDs--in numerical order */
|
| @@ -392,6 +438,38 @@ struct CoverageFormat2
|
| return NOT_COVERED;
|
| }
|
|
|
| + inline bool serialize (hb_serialize_context_t *c,
|
| + Supplier<GlyphID> &glyphs,
|
| + unsigned int num_glyphs)
|
| + {
|
| + TRACE_SERIALIZE ();
|
| + if (unlikely (!c->extend_min (*this))) return TRACE_RETURN (false);
|
| +
|
| + if (unlikely (!num_glyphs)) return TRACE_RETURN (true);
|
| +
|
| + unsigned int num_ranges = 1;
|
| + for (unsigned int i = 1; i < num_glyphs; i++)
|
| + if (glyphs[i - 1] + 1 != glyphs[i])
|
| + num_ranges++;
|
| + rangeRecord.len.set (num_ranges);
|
| + if (unlikely (!c->extend (rangeRecord))) return TRACE_RETURN (false);
|
| +
|
| + unsigned int range = 0;
|
| + rangeRecord[range].start = glyphs[0];
|
| + rangeRecord[range].value.set (0);
|
| + for (unsigned int i = 1; i < num_glyphs; i++)
|
| + if (glyphs[i - 1] + 1 != glyphs[i]) {
|
| + range++;
|
| + rangeRecord[range].start = glyphs[i];
|
| + rangeRecord[range].value.set (i);
|
| + rangeRecord[range].end = glyphs[i];
|
| + } else {
|
| + rangeRecord[range].end = glyphs[i];
|
| + }
|
| + glyphs.advance (num_glyphs);
|
| + return TRACE_RETURN (true);
|
| + }
|
| +
|
| inline bool sanitize (hb_sanitize_context_t *c) {
|
| TRACE_SANITIZE ();
|
| return TRACE_RETURN (rangeRecord.sanitize (c));
|
| @@ -412,6 +490,13 @@ struct CoverageFormat2
|
| return false;
|
| }
|
|
|
| + template <typename set_t>
|
| + inline void add_coverage (set_t *glyphs) const {
|
| + unsigned int count = rangeRecord.len;
|
| + for (unsigned int i = 0; i < count; i++)
|
| + rangeRecord[i].add_coverage (glyphs);
|
| + }
|
| +
|
| struct Iter {
|
| inline void init (const CoverageFormat2 &c_) {
|
| c = &c_;
|
| @@ -438,7 +523,7 @@ struct CoverageFormat2
|
| unsigned int i, j, coverage;
|
| };
|
|
|
| - private:
|
| + protected:
|
| USHORT coverageFormat; /* Format identifier--format = 2 */
|
| SortedArrayOf<RangeRecord>
|
| rangeRecord; /* Array of glyph ranges--ordered by
|
| @@ -461,6 +546,24 @@ struct Coverage
|
| }
|
| }
|
|
|
| + inline bool serialize (hb_serialize_context_t *c,
|
| + Supplier<GlyphID> &glyphs,
|
| + unsigned int num_glyphs)
|
| + {
|
| + TRACE_SERIALIZE ();
|
| + if (unlikely (!c->extend_min (*this))) return TRACE_RETURN (false);
|
| + unsigned int num_ranges = 1;
|
| + for (unsigned int i = 1; i < num_glyphs; i++)
|
| + if (glyphs[i - 1] + 1 != glyphs[i])
|
| + num_ranges++;
|
| + u.format.set (num_glyphs * 2 < num_ranges * 3 ? 1 : 2);
|
| + switch (u.format) {
|
| + case 1: return TRACE_RETURN (u.format1.serialize (c, glyphs, num_glyphs));
|
| + case 2: return TRACE_RETURN (u.format2.serialize (c, glyphs, num_glyphs));
|
| + default:return TRACE_RETURN (false);
|
| + }
|
| + }
|
| +
|
| inline bool sanitize (hb_sanitize_context_t *c) {
|
| TRACE_SANITIZE ();
|
| if (!u.format.sanitize (c)) return TRACE_RETURN (false);
|
| @@ -489,6 +592,15 @@ struct Coverage
|
| }
|
| }
|
|
|
| + template <typename set_t>
|
| + inline void add_coverage (set_t *glyphs) const {
|
| + switch (u.format) {
|
| + case 1: u.format1.add_coverage (glyphs); break;
|
| + case 2: u.format2.add_coverage (glyphs); break;
|
| + default: break;
|
| + }
|
| + }
|
| +
|
| struct Iter {
|
| Iter (void) : format (0) {};
|
| inline void init (const Coverage &c_) {
|
| @@ -536,7 +648,7 @@ struct Coverage
|
| } u;
|
| };
|
|
|
| - private:
|
| + protected:
|
| union {
|
| USHORT format; /* Format identifier */
|
| CoverageFormat1 format1;
|
| @@ -558,7 +670,7 @@ struct ClassDefFormat1
|
| private:
|
| inline unsigned int get_class (hb_codepoint_t glyph_id) const
|
| {
|
| - if ((unsigned int) (glyph_id - startGlyph) < classValue.len)
|
| + if (unlikely ((unsigned int) (glyph_id - startGlyph) < classValue.len))
|
| return classValue[glyph_id - startGlyph];
|
| return 0;
|
| }
|
| @@ -576,6 +688,7 @@ struct ClassDefFormat1
|
| return false;
|
| }
|
|
|
| + protected:
|
| USHORT classFormat; /* Format identifier--format = 1 */
|
| GlyphID startGlyph; /* First GlyphID of the classValueArray */
|
| ArrayOf<USHORT>
|
| @@ -610,6 +723,7 @@ struct ClassDefFormat2
|
| return false;
|
| }
|
|
|
| + protected:
|
| USHORT classFormat; /* Format identifier--format = 2 */
|
| SortedArrayOf<RangeRecord>
|
| rangeRecord; /* Array of glyph ranges--ordered by
|
| @@ -649,7 +763,7 @@ struct ClassDef
|
| }
|
| }
|
|
|
| - private:
|
| + protected:
|
| union {
|
| USHORT format; /* Format identifier */
|
| ClassDefFormat1 format1;
|
| @@ -720,7 +834,7 @@ struct Device
|
| return TRACE_RETURN (c->check_struct (this) && c->check_range (this, this->get_size ()));
|
| }
|
|
|
| - private:
|
| + protected:
|
| USHORT startSize; /* Smallest size to correct--in ppem */
|
| USHORT endSize; /* Largest size to correct--in ppem */
|
| USHORT deltaFormat; /* Format of DeltaValue array data: 1, 2, or 3
|
| @@ -734,5 +848,7 @@ struct Device
|
| };
|
|
|
|
|
| +} // namespace OT
|
| +
|
|
|
| #endif /* HB_OT_LAYOUT_COMMON_PRIVATE_HH */
|
|
|