diff options
author | Ebrahim Byagowi <ebrahim@gnu.org> | 2018-11-15 23:10:56 +0330 |
---|---|---|
committer | Ebrahim Byagowi <ebrahim@gnu.org> | 2018-11-16 00:02:47 +0330 |
commit | 11aa0468ac2c62ff734ba6b0f6eb43d1bd6f602b (patch) | |
tree | b4331dc2de9e78cde1b38ec91fd8b434baf609bf | |
parent | d7c50ff0d65192fd2b7b80704e227fa108c06de3 (diff) |
[subset] minor, adjust spaces
-rw-r--r-- | src/hb-open-type.hh | 70 | ||||
-rw-r--r-- | src/hb-ot-cmap-table.hh | 182 | ||||
-rw-r--r-- | src/hb-ot-glyf-table.hh | 242 | ||||
-rw-r--r-- | src/hb-ot-hdmx-table.hh | 20 | ||||
-rw-r--r-- | src/hb-ot-hmtx-table.hh | 14 | ||||
-rw-r--r-- | src/hb-ot-layout-common.hh | 77 | ||||
-rw-r--r-- | src/hb-ot-layout-gpos-table.hh | 16 | ||||
-rw-r--r-- | src/hb-ot-layout-gsub-table.hh | 4 | ||||
-rw-r--r-- | src/hb-ot-layout-gsubgpos.hh | 88 | ||||
-rw-r--r-- | src/hb-ot-os2-table.hh | 24 | ||||
-rw-r--r-- | src/hb-ot-post-table.hh | 26 | ||||
-rw-r--r-- | src/hb-subset-glyf.cc | 182 | ||||
-rw-r--r-- | src/hb-subset-glyf.hh | 6 | ||||
-rw-r--r-- | src/hb-subset-input.cc | 4 | ||||
-rw-r--r-- | src/hb-subset-plan.cc | 32 | ||||
-rw-r--r-- | src/hb-subset-plan.hh | 12 | ||||
-rw-r--r-- | src/hb-subset.cc | 46 | ||||
-rw-r--r-- | src/hb-subset.h | 7 | ||||
-rw-r--r-- | util/hb-subset.cc | 2 |
19 files changed, 510 insertions, 544 deletions
diff --git a/src/hb-open-type.hh b/src/hb-open-type.hh index 3f8e2c08..a14d0f02 100644 --- a/src/hb-open-type.hh +++ b/src/hb-open-type.hh @@ -58,7 +58,7 @@ struct IntType { typedef Type type; inline void set (Type i) { v.set (i); } - inline operator Type(void) const { return v; } + inline operator Type (void) const { return v; } inline bool operator == (const IntType<Type,Size> &o) const { return (Type) v == (Type) o.v; } inline bool operator != (const IntType<Type,Size> &o) const { return !(*this == o); } static inline int cmp (const IntType<Type,Size> *a, const IntType<Type,Size> *b) { return b->cmp (*a); } @@ -173,7 +173,7 @@ struct Offset : Type } public: - DEFINE_SIZE_STATIC (sizeof(Type)); + DEFINE_SIZE_STATIC (sizeof (Type)); }; typedef Offset<HBUINT16> Offset16; @@ -211,7 +211,7 @@ struct CheckSum : HBUINT32 template <typename FixedType=HBUINT16> struct FixedVersion { - inline uint32_t to_int (void) const { return (major << (sizeof(FixedType) * 8)) + minor; } + inline uint32_t to_int (void) const { return (major << (sizeof (FixedType) * 8)) + minor; } inline bool sanitize (hb_sanitize_context_t *c) const { @@ -222,7 +222,7 @@ struct FixedVersion FixedType major; FixedType minor; public: - DEFINE_SIZE_STATIC (2 * sizeof(FixedType)); + DEFINE_SIZE_STATIC (2 * sizeof (FixedType)); }; @@ -241,12 +241,12 @@ struct OffsetTo : Offset<OffsetType, has_null> inline const Type& operator () (const void *base) const { - if (unlikely (this->is_null ())) return Null(Type); + if (unlikely (this->is_null ())) return Null (Type); return StructAtOffset<const Type> (base, *this); } inline Type& operator () (void *base) const { - if (unlikely (this->is_null ())) return Crap(Type); + if (unlikely (this->is_null ())) return Crap (Type); return StructAtOffset<Type> (base, *this); } @@ -258,7 +258,7 @@ struct OffsetTo : Offset<OffsetType, has_null> template <typename T> inline void serialize_subset (hb_subset_context_t *c, const T &src, const void *base) { - if (&src == &Null(T)) + if (&src == &Null (T)) { this->set (0); return; @@ -319,7 +319,7 @@ struct OffsetTo : Offset<OffsetType, has_null> if (!has_null) return false; return c->try_set (this, 0); } - DEFINE_SIZE_STATIC (sizeof(OffsetType)); + DEFINE_SIZE_STATIC (sizeof (OffsetType)); }; template <typename Type, bool has_null=true> struct LOffsetTo : OffsetTo<Type, HBUINT32, has_null> {}; template <typename Base, typename OffsetType, bool has_null, typename Type> @@ -344,7 +344,7 @@ struct UnsizedArrayOf * 1. For UnsizedArrayOf, it's not totally unimaginable to want to look * at items before the start of current array. * 2. Fixes MSVC 2008 "overloads have similar conversions" issue with the - * built-in operator [] that takes int, in expressions like sizeof(array[0])). + * built-in operator [] that takes int, in expressions like sizeof (array[0])). * I suppose I could fix that by replacing 0 with 0u, but like this fix * more now. */ inline const Type& operator [] (int i) const { return arrayZ[i]; } @@ -381,7 +381,7 @@ struct UnsizedArrayOf if (unlikely (!sanitize_shallow (c, count))) return_trace (false); for (unsigned int i = 0; i < count; i++) if (unlikely (!arrayZ[i].sanitize (c, base))) - return_trace (false); + return_trace (false); return_trace (true); } template <typename T> @@ -391,7 +391,7 @@ struct UnsizedArrayOf if (unlikely (!sanitize_shallow (c, count))) return_trace (false); for (unsigned int i = 0; i < count; i++) if (unlikely (!arrayZ[i].sanitize (c, base, user_data))) - return_trace (false); + return_trace (false); return_trace (true); } @@ -455,12 +455,12 @@ struct ArrayOf inline const Type& operator [] (unsigned int i) const { - if (unlikely (i >= len)) return Null(Type); + if (unlikely (i >= len)) return Null (Type); return arrayZ[i]; } inline Type& operator [] (unsigned int i) { - if (unlikely (i >= len)) return Crap(Type); + if (unlikely (i >= len)) return Crap (Type); return arrayZ[i]; } @@ -511,7 +511,7 @@ struct ArrayOf unsigned int count = len; for (unsigned int i = 0; i < count; i++) if (unlikely (!arrayZ[i].sanitize (c, base))) - return_trace (false); + return_trace (false); return_trace (true); } template <typename T> @@ -522,7 +522,7 @@ struct ArrayOf unsigned int count = len; for (unsigned int i = 0; i < count; i++) if (unlikely (!arrayZ[i].sanitize (c, base, user_data))) - return_trace (false); + return_trace (false); return_trace (true); } @@ -532,7 +532,7 @@ struct ArrayOf unsigned int count = len; for (unsigned int i = 0; i < count; i++) if (!this->arrayZ[i].cmp (x)) - return i; + return i; return -1; } @@ -570,12 +570,12 @@ struct OffsetListOf : OffsetArrayOf<Type> { inline const Type& operator [] (unsigned int i) const { - if (unlikely (i >= this->len)) return Null(Type); + if (unlikely (i >= this->len)) return Null (Type); return this+this->arrayZ[i]; } inline const Type& operator [] (unsigned int i) { - if (unlikely (i >= this->len)) return Crap(Type); + if (unlikely (i >= this->len)) return Crap (Type); return this+this->arrayZ[i]; } @@ -613,12 +613,12 @@ struct HeadlessArrayOf inline const Type& operator [] (unsigned int i) const { - if (unlikely (i >= lenP1 || !i)) return Null(Type); + if (unlikely (i >= lenP1 || !i)) return Null (Type); return arrayZ[i-1]; } inline Type& operator [] (unsigned int i) { - if (unlikely (i >= lenP1 || !i)) return Crap(Type); + if (unlikely (i >= lenP1 || !i)) return Crap (Type); return arrayZ[i-1]; } inline unsigned int get_size (void) const @@ -679,12 +679,12 @@ struct ArrayOfM1 inline const Type& operator [] (unsigned int i) const { - if (unlikely (i > lenM1)) return Null(Type); + if (unlikely (i > lenM1)) return Null (Type); return arrayZ[i]; } inline Type& operator [] (unsigned int i) { - if (unlikely (i > lenM1)) return Crap(Type); + if (unlikely (i > lenM1)) return Crap (Type); return arrayZ[i]; } inline unsigned int get_size (void) const @@ -698,7 +698,7 @@ struct ArrayOfM1 unsigned int count = lenM1 + 1; for (unsigned int i = 0; i < count; i++) if (unlikely (!arrayZ[i].sanitize (c, base, user_data))) - return_trace (false); + return_trace (false); return_trace (true); } @@ -731,12 +731,9 @@ struct SortedArrayOf : ArrayOf<Type, LenType> { int mid = ((unsigned int) min + (unsigned int) max) / 2; int c = arr[mid].cmp (x); - if (c < 0) - max = mid - 1; - else if (c > 0) - min = mid + 1; - else - return mid; + if (c < 0) max = mid - 1; + else if (c > 0) min = mid + 1; + else return mid; } return -1; } @@ -813,7 +810,7 @@ struct VarSizedBinSearchArrayOf inline const Type& operator [] (unsigned int i) const { - if (unlikely (i >= header.nUnits)) return Null(Type); + if (unlikely (i >= header.nUnits)) return Null (Type); return StructAtOffset<Type> (&bytesZ, i * header.unitSize); } inline Type& operator [] (unsigned int i) @@ -846,7 +843,7 @@ struct VarSizedBinSearchArrayOf unsigned int count = header.nUnits; for (unsigned int i = 0; i < count; i++) if (unlikely (!(*this)[i].sanitize (c, base))) - return_trace (false); + return_trace (false); return_trace (true); } template <typename T> @@ -857,7 +854,7 @@ struct VarSizedBinSearchArrayOf unsigned int count = header.nUnits; for (unsigned int i = 0; i < count; i++) if (unlikely (!(*this)[i].sanitize (c, base, user_data))) - return_trace (false); + return_trace (false); return_trace (true); } @@ -871,12 +868,9 @@ struct VarSizedBinSearchArrayOf int mid = ((unsigned int) min + (unsigned int) max) / 2; const Type *p = (const Type *) (((const char *) &bytesZ) + (mid * size)); int c = p->cmp (key); - if (c < 0) - max = mid - 1; - else if (c > 0) - min = mid + 1; - else - return p; + if (c < 0) max = mid - 1; + else if (c > 0) min = mid + 1; + else return p; } return nullptr; } diff --git a/src/hb-ot-cmap-table.hh b/src/hb-ot-cmap-table.hh index 4c24cb99..b7d17018 100644 --- a/src/hb-ot-cmap-table.hh +++ b/src/hb-ot-cmap-table.hh @@ -53,7 +53,7 @@ struct CmapSubtableFormat0 { for (unsigned int i = 0; i < 256; i++) if (glyphIdArray[i]) - out->add (i); + out->add (i); } inline bool sanitize (hb_sanitize_context_t *c) const @@ -82,8 +82,8 @@ struct CmapSubtableFormat4 }; bool serialize (hb_serialize_context_t *c, - const hb_subset_plan_t *plan, - const hb_vector_t<segment_plan> &segments) + const hb_subset_plan_t *plan, + const hb_vector_t<segment_plan> &segments) { TRACE_SERIALIZE (this); @@ -96,8 +96,8 @@ struct CmapSubtableFormat4 this->entrySelector.set (MAX (1u, hb_bit_storage (segments.len)) - 1); this->searchRange.set (2 * (1u << this->entrySelector)); this->rangeShift.set (segments.len * 2 > this->searchRange - ? 2 * segments.len - this->searchRange - : 0); + ? 2 * segments.len - this->searchRange + : 0); HBUINT16 *end_count = c->allocate_size<HBUINT16> (HBUINT16::static_size * segments.len); c->allocate_size<HBUINT16> (HBUINT16::static_size); // 2 bytes of padding. @@ -114,40 +114,40 @@ struct CmapSubtableFormat4 start_count[i].set (segments[i].start_code); if (segments[i].use_delta) { - hb_codepoint_t cp = segments[i].start_code; - hb_codepoint_t start_gid = 0; - if (unlikely (!plan->new_gid_for_codepoint (cp, &start_gid) && cp != 0xFFFF)) - return_trace (false); - id_delta[i].set (start_gid - segments[i].start_code); + hb_codepoint_t cp = segments[i].start_code; + hb_codepoint_t start_gid = 0; + if (unlikely (!plan->new_gid_for_codepoint (cp, &start_gid) && cp != 0xFFFF)) + return_trace (false); + id_delta[i].set (start_gid - segments[i].start_code); } else { - id_delta[i].set (0); - unsigned int num_codepoints = segments[i].end_code - segments[i].start_code + 1; - HBUINT16 *glyph_id_array = c->allocate_size<HBUINT16> (HBUINT16::static_size * num_codepoints); - if (glyph_id_array == nullptr) - return_trace (false); - // From the cmap spec: - // - // id_range_offset[i]/2 - // + (cp - segments[i].start_code) - // + (id_range_offset + i) - // = - // glyph_id_array + (cp - segments[i].start_code) - // - // So, solve for id_range_offset[i]: - // - // id_range_offset[i] - // = - // 2 * (glyph_id_array - id_range_offset - i) - id_range_offset[i].set (2 * ( - glyph_id_array - id_range_offset - i)); - for (unsigned int j = 0; j < num_codepoints; j++) - { - hb_codepoint_t cp = segments[i].start_code + j; - hb_codepoint_t new_gid; - if (unlikely (!plan->new_gid_for_codepoint (cp, &new_gid))) - return_trace (false); - glyph_id_array[j].set (new_gid); - } + id_delta[i].set (0); + unsigned int num_codepoints = segments[i].end_code - segments[i].start_code + 1; + HBUINT16 *glyph_id_array = c->allocate_size<HBUINT16> (HBUINT16::static_size * num_codepoints); + if (glyph_id_array == nullptr) + return_trace (false); + // From the cmap spec: + // + // id_range_offset[i]/2 + // + (cp - segments[i].start_code) + // + (id_range_offset + i) + // = + // glyph_id_array + (cp - segments[i].start_code) + // + // So, solve for id_range_offset[i]: + // + // id_range_offset[i] + // = + // 2 * (glyph_id_array - id_range_offset - i) + id_range_offset[i].set (2 * ( + glyph_id_array - id_range_offset - i)); + for (unsigned int j = 0; j < num_codepoints; j++) + { + hb_codepoint_t cp = segments[i].start_code + j; + hb_codepoint_t new_gid; + if (unlikely (!plan->new_gid_for_codepoint (cp, &new_gid))) + return_trace (false); + glyph_id_array[j].set (new_gid); + } } } @@ -161,23 +161,23 @@ struct CmapSubtableFormat4 { // Parallel array entries segment_size += - 2 // end count - + 2 // start count - + 2 // delta - + 2; // range offset + 2 // end count + + 2 // start count + + 2 // delta + + 2; // range offset if (!segments[i].use_delta) - // Add bytes for the glyph index array entries for this segment. - segment_size += (segments[i].end_code - segments[i].start_code + 1) * 2; + // Add bytes for the glyph index array entries for this segment. + segment_size += (segments[i].end_code - segments[i].start_code + 1) * 2; } return min_size - + 2 // Padding - + segment_size; + + 2 // Padding + + segment_size; } static inline bool create_sub_table_plan (const hb_subset_plan_t *plan, - hb_vector_t<segment_plan> *segments) + hb_vector_t<segment_plan> *segments) { segment_plan *segment = nullptr; hb_codepoint_t last_gid = 0; @@ -191,24 +191,22 @@ struct CmapSubtableFormat4 return false; } - if (cp > 0xFFFF) { - // We are now outside of unicode BMP, stop adding to this cmap. - break; - } + /* Stop adding to cmap if we are now outside of unicode BMP. */ + if (cp > 0xFFFF) break; - if (!segment - || cp != segment->end_code + 1u) + if (!segment || + cp != segment->end_code + 1u) { - segment = segments->push (); - segment->start_code.set (cp); - segment->end_code.set (cp); - segment->use_delta = true; + segment = segments->push (); + segment->start_code.set (cp); + segment->end_code.set (cp); + segment->use_delta = true; } else { - segment->end_code.set (cp); - if (last_gid + 1u != new_gid) - // gid's are not consecutive in this segment so delta - // cannot be used. - segment->use_delta = false; + segment->end_code.set (cp); + if (last_gid + 1u != new_gid) + // gid's are not consecutive in this segment so delta + // cannot be used. + segment->use_delta = false; } last_gid = new_gid; @@ -253,7 +251,7 @@ struct CmapSubtableFormat4 unsigned int i; while (min <= max) { - int mid = ((unsigned int) min + (unsigned int) max) / 2; + int mid = ((unsigned int) min + (unsigned int) max) / 2; if (codepoint < startCount[mid]) max = mid - 1; else if (codepoint > endCount[mid]) @@ -296,7 +294,7 @@ struct CmapSubtableFormat4 { unsigned int count = this->segCount; if (count && this->startCount[count - 1] == 0xFFFFu) - count--; /* Skip sentinel segment. */ + count--; /* Skip sentinel segment. */ for (unsigned int i = 0; i < count; i++) { unsigned int rangeOffset = this->idRangeOffset[i]; @@ -438,7 +436,7 @@ struct CmapSubtableTrimmed unsigned int count = glyphIdArray.len; for (unsigned int i = 0; i < count; i++) if (glyphIdArray[i]) - out->add (start + i); + out->add (start + i); } inline bool sanitize (hb_sanitize_context_t *c) const @@ -495,7 +493,7 @@ struct CmapSubtableLongSegmented } inline bool serialize (hb_serialize_context_t *c, - const hb_vector_t<CmapSubtableLongGroup> &group_data) + const hb_vector_t<CmapSubtableLongGroup> &group_data) { TRACE_SERIALIZE (this); if (unlikely (!c->extend_min (*this))) return_trace (false); @@ -523,7 +521,7 @@ struct CmapSubtableFormat12 : CmapSubtableLongSegmented<CmapSubtableFormat12> bool serialize (hb_serialize_context_t *c, - const hb_vector_t<CmapSubtableLongGroup> &groups) + const hb_vector_t<CmapSubtableLongGroup> &groups) { if (unlikely (!c->extend_min (*this))) return false; @@ -540,7 +538,7 @@ struct CmapSubtableFormat12 : CmapSubtableLongSegmented<CmapSubtableFormat12> } static inline bool create_sub_table_plan (const hb_subset_plan_t *plan, - hb_vector_t<CmapSubtableLongGroup> *groups) + hb_vector_t<CmapSubtableLongGroup> *groups) { CmapSubtableLongGroup *group = nullptr; @@ -555,14 +553,12 @@ struct CmapSubtableFormat12 : CmapSubtableLongSegmented<CmapSubtableFormat12> if (!group || !_is_gid_consecutive (group, cp, new_gid)) { - group = groups->push (); - group->startCharCode.set (cp); - group->endCharCode.set (cp); - group->glyphID.set (new_gid); - } else - { - group->endCharCode.set (cp); + group = groups->push (); + group->startCharCode.set (cp); + group->endCharCode.set (cp); + group->glyphID.set (new_gid); } + else group->endCharCode.set (cp); } DEBUG_MSG(SUBSET, nullptr, "cmap"); @@ -855,12 +851,12 @@ struct cmap struct subset_plan { - inline size_t final_size() const + inline size_t final_size () const { return 4 // header - + 8 * 3 // 3 EncodingRecord - + CmapSubtableFormat4::get_sub_table_size (this->format4_segments) - + CmapSubtableFormat12::get_sub_table_size (this->format12_groups); + + 8 * 3 // 3 EncodingRecord + + CmapSubtableFormat4::get_sub_table_size (this->format4_segments) + + CmapSubtableFormat12::get_sub_table_size (this->format12_groups); } hb_vector_t<CmapSubtableFormat4::segment_plan> format4_segments; @@ -876,16 +872,16 @@ struct cmap } inline bool _create_plan (const hb_subset_plan_t *plan, - subset_plan *cmap_plan) const + subset_plan *cmap_plan) const { - if (unlikely( !CmapSubtableFormat4::create_sub_table_plan (plan, &cmap_plan->format4_segments))) + if (unlikely (!CmapSubtableFormat4::create_sub_table_plan (plan, &cmap_plan->format4_segments))) return false; return CmapSubtableFormat12::create_sub_table_plan (plan, &cmap_plan->format12_groups); } inline bool _subset (const hb_subset_plan_t *plan, - const subset_plan &cmap_subset_plan, + const subset_plan &cmap_subset_plan, size_t dest_sz, void *dest) const { @@ -927,7 +923,7 @@ struct cmap CmapSubtableFormat4 &format4 = subtable.u.format4; if (unlikely (!format4.serialize (&c, plan, cmap_subset_plan.format4_segments))) - return false; + return false; } // Write out format 12 sub table. @@ -937,7 +933,7 @@ struct cmap CmapSubtableFormat12 &format12 = subtable.u.format12; if (unlikely (!format12.serialize (&c, cmap_subset_plan.format12_groups))) - return false; + return false; } c.end_serialize (); @@ -956,7 +952,7 @@ struct cmap } // We now know how big our blob needs to be - size_t dest_sz = cmap_subset_plan.final_size(); + size_t dest_sz = cmap_subset_plan.final_size (); void *dest = malloc (dest_sz); if (unlikely (!dest)) { DEBUG_MSG(SUBSET, nullptr, "Unable to alloc %lu for cmap subset output", (unsigned long) dest_sz); @@ -971,11 +967,11 @@ struct cmap } // all done, write the blob into dest - hb_blob_t *cmap_prime = hb_blob_create ((const char *)dest, - dest_sz, - HB_MEMORY_MODE_READONLY, - dest, - free); + hb_blob_t *cmap_prime = hb_blob_create ((const char *) dest, + dest_sz, + HB_MEMORY_MODE_READONLY, + dest, + free); bool result = plan->add_table (HB_OT_TAG_cmap, cmap_prime); hb_blob_destroy (cmap_prime); return result; @@ -1007,17 +1003,17 @@ struct cmap } /* Meh. */ - return &Null(CmapSubtable); + return &Null (CmapSubtable); } struct accelerator_t { inline void init (hb_face_t *face) { - this->table = hb_sanitize_context_t().reference_table<cmap> (face); + this->table = hb_sanitize_context_t ().reference_table<cmap> (face); bool symbol; this->subtable = table->find_best_subtable (&symbol); - this->subtable_uvs = &Null(CmapSubtableFormat14); + this->subtable_uvs = &Null (CmapSubtableFormat14); { const CmapSubtable *st = table->find_subtable (0, 5); if (st && st->u.format == 14) diff --git a/src/hb-ot-glyf-table.hh b/src/hb-ot-glyf-table.hh index 4fdbced4..5d9e7a20 100644 --- a/src/hb-ot-glyf-table.hh +++ b/src/hb-ot-glyf-table.hh @@ -102,7 +102,7 @@ struct glyf static bool _add_head_and_set_loca_version (hb_subset_plan_t *plan, bool use_short_loca) { - hb_blob_t *head_blob = hb_sanitize_context_t().reference_table<head> (plan->source); + hb_blob_t *head_blob = hb_sanitize_context_t ().reference_table<head> (plan->source); hb_blob_t *head_prime_blob = hb_blob_copy_writable_or_fail (head_blob); hb_blob_destroy (head_blob); @@ -120,9 +120,9 @@ struct glyf struct GlyphHeader { HBINT16 numberOfContours; /* If the number of contours is - * greater than or equal to zero, - * this is a simple glyph; if negative, - * this is a composite glyph. */ + * greater than or equal to zero, + * this is a simple glyph; if negative, + * this is a composite glyph. */ FWORD xMin; /* Minimum x for coordinate data. */ FWORD yMin; /* Minimum y for coordinate data. */ FWORD xMax; /* Maximum x for coordinate data. */ @@ -154,23 +154,18 @@ struct glyf inline unsigned int get_size (void) const { unsigned int size = min_size; - if (flags & ARG_1_AND_2_ARE_WORDS) { - // arg1 and 2 are int16 - size += 4; - } else { - // arg1 and 2 are int8 - size += 2; - } - if (flags & WE_HAVE_A_SCALE) { - // One x 16 bit (scale) - size += 2; - } else if (flags & WE_HAVE_AN_X_AND_Y_SCALE) { - // Two x 16 bit (xscale, yscale) - size += 4; - } else if (flags & WE_HAVE_A_TWO_BY_TWO) { - // Four x 16 bit (xscale, scale01, scale10, yscale) - size += 8; - } + // arg1 and 2 are int16 + if (flags & ARG_1_AND_2_ARE_WORDS) size += 4; + // arg1 and 2 are int8 + else size += 2; + + // One x 16 bit (scale) + if (flags & WE_HAVE_A_SCALE) size += 2; + // Two x 16 bit (xscale, yscale) + else if (flags & WE_HAVE_AN_X_AND_Y_SCALE) size += 4; + // Four x 16 bit (xscale, scale01, scale10, yscale) + else if (flags & WE_HAVE_A_TWO_BY_TWO) size += 8; + return size; } @@ -198,7 +193,7 @@ struct glyf { return (const char *) composite >= glyph_start && ((const char *) composite + CompositeGlyphHeader::min_size) <= glyph_end - && ((const char *) composite + composite->get_size()) <= glyph_end; + && ((const char *) composite + composite->get_size ()) <= glyph_end; } }; @@ -212,15 +207,15 @@ struct glyf const GlyphHeader &glyph_header = StructAtOffset<GlyphHeader> (glyph_data, 0); if (glyph_header.numberOfContours < 0) { - const CompositeGlyphHeader *possible = + const CompositeGlyphHeader *possible = &StructAfter<CompositeGlyphHeader, GlyphHeader> (glyph_header); iterator->glyph_start = glyph_data; iterator->glyph_end = (const char *) glyph_data + length; if (!iterator->in_range (possible)) - return false; - iterator->current = possible; - return true; + return false; + iterator->current = possible; + return true; } return false; @@ -241,8 +236,8 @@ struct glyf return; short_offset = 0 == head.indexToLocFormat; - loca_table = hb_sanitize_context_t().reference_table<loca> (face); - glyf_table = hb_sanitize_context_t().reference_table<glyf> (face); + loca_table = hb_sanitize_context_t ().reference_table<loca> (face); + glyf_table = hb_sanitize_context_t ().reference_table<glyf> (face); num_glyphs = MAX (1u, loca_table.get_length () / (short_offset ? 2 : 4)) - 1; } @@ -266,7 +261,7 @@ struct glyf unsigned int start_offset, end_offset; if (!get_offsets (glyph, &start_offset, &end_offset)) - return false; /* glyph not found */ + return false; /* glyph not found */ return CompositeGlyphHeader::get_iterator ((const char *) this->glyf_table + start_offset, end_offset - start_offset, @@ -282,11 +277,10 @@ struct glyf }; /* based on FontTools _g_l_y_f.py::trim */ - inline bool remove_padding(unsigned int start_offset, - unsigned int *end_offset) const + inline bool remove_padding (unsigned int start_offset, + unsigned int *end_offset) const { - if (*end_offset - start_offset < GlyphHeader::static_size) - return true; + if (*end_offset - start_offset < GlyphHeader::static_size) return true; const char *glyph = ((const char *) glyf_table) + start_offset; const char * const glyph_end = glyph + (*end_offset - start_offset); @@ -294,87 +288,83 @@ struct glyf int16_t num_contours = (int16_t) glyph_header.numberOfContours; if (num_contours < 0) - /* Trimming for composites not implemented. - * If removing hints it falls out of that. */ - return true; + /* Trimming for composites not implemented. + * If removing hints it falls out of that. */ + return true; else if (num_contours > 0) { - /* simple glyph w/contours, possibly trimmable */ - glyph += GlyphHeader::static_size + 2 * num_contours; - - if (unlikely (glyph + 2 >= glyph_end)) return false; - uint16_t nCoordinates = (uint16_t) StructAtOffset<HBUINT16>(glyph - 2, 0) + 1; - uint16_t nInstructions = (uint16_t) StructAtOffset<HBUINT16>(glyph, 0); - - glyph += 2 + nInstructions; - if (unlikely (glyph + 2 >= glyph_end)) return false; - - unsigned int coordBytes = 0; - unsigned int coordsWithFlags = 0; - while (glyph < glyph_end) - { - uint8_t flag = (uint8_t) *glyph; - glyph++; - - unsigned int repeat = 1; - if (flag & FLAG_REPEAT) - { - if (glyph >= glyph_end) - { - DEBUG_MSG(SUBSET, nullptr, "Bad flag"); - return false; - } - repeat = ((uint8_t) *glyph) + 1; - glyph++; - } - - unsigned int xBytes, yBytes; - xBytes = yBytes = 0; - if (flag & FLAG_X_SHORT) - xBytes = 1; - else if ((flag & FLAG_X_SAME) == 0) - xBytes = 2; - - if (flag & FLAG_Y_SHORT) - yBytes = 1; - else if ((flag & FLAG_Y_SAME) == 0) - yBytes = 2; - - coordBytes += (xBytes + yBytes) * repeat; - coordsWithFlags += repeat; - if (coordsWithFlags >= nCoordinates) - break; - } - - if (coordsWithFlags != nCoordinates) - { - DEBUG_MSG(SUBSET, nullptr, "Expect %d coords to have flags, got flags for %d", nCoordinates, coordsWithFlags); - return false; - } - glyph += coordBytes; - - if (glyph < glyph_end) - *end_offset -= glyph_end - glyph; + /* simple glyph w/contours, possibly trimmable */ + glyph += GlyphHeader::static_size + 2 * num_contours; + + if (unlikely (glyph + 2 >= glyph_end)) return false; + uint16_t nCoordinates = (uint16_t) StructAtOffset<HBUINT16> (glyph - 2, 0) + 1; + uint16_t nInstructions = (uint16_t) StructAtOffset<HBUINT16> (glyph, 0); + + glyph += 2 + nInstructions; + if (unlikely (glyph + 2 >= glyph_end)) return false; + + unsigned int coordBytes = 0; + unsigned int coordsWithFlags = 0; + while (glyph < glyph_end) + { + uint8_t flag = (uint8_t) *glyph; + glyph++; + + unsigned int repeat = 1; + if (flag & FLAG_REPEAT) + { + if (glyph >= glyph_end) + { + DEBUG_MSG(SUBSET, nullptr, "Bad flag"); + return false; + } + repeat = ((uint8_t) *glyph) + 1; + glyph++; + } + + unsigned int xBytes, yBytes; + xBytes = yBytes = 0; + if (flag & FLAG_X_SHORT) xBytes = 1; + else if ((flag & FLAG_X_SAME) == 0) xBytes = 2; + + if (flag & FLAG_Y_SHORT) yBytes = 1; + else if ((flag & FLAG_Y_SAME) == 0) yBytes = 2; + + coordBytes += (xBytes + yBytes) * repeat; + coordsWithFlags += repeat; + if (coordsWithFlags >= nCoordinates) + break; + } + + if (coordsWithFlags != nCoordinates) + { + DEBUG_MSG(SUBSET, nullptr, "Expect %d coords to have flags, got flags for %d", nCoordinates, coordsWithFlags); + return false; + } + glyph += coordBytes; + + if (glyph < glyph_end) + *end_offset -= glyph_end - glyph; } return true; } inline bool get_offsets (hb_codepoint_t glyph, - unsigned int *start_offset /* OUT */, - unsigned int *end_offset /* OUT */) const + unsigned int *start_offset /* OUT */, + unsigned int *end_offset /* OUT */) const { if (unlikely (glyph >= num_glyphs)) return false; if (short_offset) { - const HBUINT16 *offsets = (const HBUINT16 *) loca_table->dataZ.arrayZ; + const HBUINT16 *offsets = (const HBUINT16 *) loca_table->dataZ.arrayZ; *start_offset = 2 * offsets[glyph]; *end_offset = 2 * offsets[glyph + 1]; } else { - const HBUINT32 *offsets = (const HBUINT32 *) loca_table->dataZ.arrayZ; + const HBUINT32 *offsets = (const HBUINT32 *) loca_table->dataZ.arrayZ; *start_offset = offsets[glyph]; *end_offset = offsets[glyph + 1]; @@ -386,51 +376,51 @@ struct glyf return true; } - inline bool get_instruction_offsets(unsigned int start_offset, - unsigned int end_offset, - unsigned int *instruction_start /* OUT */, - unsigned int *instruction_end /* OUT */) const + inline bool get_instruction_offsets (unsigned int start_offset, + unsigned int end_offset, + unsigned int *instruction_start /* OUT */, + unsigned int *instruction_end /* OUT */) const { if (end_offset - start_offset < GlyphHeader::static_size) { - *instruction_start = 0; - *instruction_end = 0; - return true; /* Empty glyph; no instructions. */ + *instruction_start = 0; + *instruction_end = 0; + return true; /* Empty glyph; no instructions. */ } const GlyphHeader &glyph_header = StructAtOffset<GlyphHeader> (glyf_table, start_offset); int16_t num_contours = (int16_t) glyph_header.numberOfContours; if (num_contours < 0) { - CompositeGlyphHeader::Iterator composite_it; - if (unlikely (!CompositeGlyphHeader::get_iterator ( - (const char*) this->glyf_table + start_offset, - end_offset - start_offset, &composite_it))) return false; - const CompositeGlyphHeader *last; - do { - last = composite_it.current; - } while (composite_it.move_to_next()); - - if ( (uint16_t) last->flags & CompositeGlyphHeader::WE_HAVE_INSTRUCTIONS) - *instruction_start = ((char *) last - (char *) glyf_table->dataZ.arrayZ) + last->get_size(); - else - *instruction_start = end_offset; - *instruction_end = end_offset; - if (unlikely (*instruction_start > *instruction_end)) - { - DEBUG_MSG(SUBSET, nullptr, "Invalid instruction offset, %d is outside [%d, %d]", *instruction_start, start_offset, end_offset); - return false; - } + CompositeGlyphHeader::Iterator composite_it; + if (unlikely (!CompositeGlyphHeader::get_iterator ( + (const char*) this->glyf_table + start_offset, + end_offset - start_offset, &composite_it))) return false; + const CompositeGlyphHeader *last; + do { + last = composite_it.current; + } while (composite_it.move_to_next ()); + + if ((uint16_t) last->flags & CompositeGlyphHeader::WE_HAVE_INSTRUCTIONS) + *instruction_start = ((char *) last - (char *) glyf_table->dataZ.arrayZ) + last->get_size (); + else + *instruction_start = end_offset; + *instruction_end = end_offset; + if (unlikely (*instruction_start > *instruction_end)) + { + DEBUG_MSG(SUBSET, nullptr, "Invalid instruction offset, %d is outside [%d, %d]", *instruction_start, start_offset, end_offset); + return false; + } } else { - unsigned int instruction_length_offset = start_offset + GlyphHeader::static_size + 2 * num_contours; + unsigned int instruction_length_offset = start_offset + GlyphHeader::static_size + 2 * num_contours; if (unlikely (instruction_length_offset + 2 > end_offset)) { DEBUG_MSG(SUBSET, nullptr, "Glyph size is too short, missing field instructionLength."); return false; } - const HBUINT16 &instruction_length = StructAtOffset<HBUINT16> (glyf_table, instruction_length_offset); + const HBUINT16 &instruction_length = StructAtOffset<HBUINT16> (glyf_table, instruction_length_offset); unsigned int start = instruction_length_offset + 2; unsigned int end = start + (uint16_t) instruction_length; if (unlikely (end > end_offset)) // Out of bounds of the current glyph @@ -440,7 +430,7 @@ struct glyf } *instruction_start = start; - *instruction_end = end; + *instruction_end = end; } return true; } @@ -450,7 +440,7 @@ struct glyf { unsigned int start_offset, end_offset; if (!get_offsets (glyph, &start_offset, &end_offset)) - return false; + return false; if (end_offset - start_offset < GlyphHeader::static_size) return true; /* Empty glyph; zero extents. */ diff --git a/src/hb-ot-hdmx-table.hh b/src/hb-ot-hdmx-table.hh index 9a5f9453..9cfce68a 100644 --- a/src/hb-ot-hdmx-table.hh +++ b/src/hb-ot-hdmx-table.hh @@ -47,9 +47,9 @@ struct DeviceRecord unsigned int sizeDeviceRecord; hb_subset_plan_t *subset_plan; - inline void init(const DeviceRecord *source_device_record, - unsigned int sizeDeviceRecord, - hb_subset_plan_t *subset_plan) + inline void init (const DeviceRecord *source_device_record, + unsigned int sizeDeviceRecord, + hb_subset_plan_t *subset_plan) { this->source_device_record = source_device_record; this->sizeDeviceRecord = sizeDeviceRecord; @@ -63,7 +63,7 @@ struct DeviceRecord inline const HBUINT8* operator [] (unsigned int i) const { - if (unlikely (i >= len())) return nullptr; + if (unlikely (i >= len ())) return nullptr; hb_codepoint_t gid = this->subset_plan->glyphs [i]; const HBUINT8* width = &(this->source_device_record->widthsZ[gid]); @@ -84,18 +84,18 @@ struct DeviceRecord { TRACE_SERIALIZE (this); - unsigned int size = get_size (subset_view.len()); + unsigned int size = get_size (subset_view.len ()); if (unlikely (!c->allocate_size<DeviceRecord> (size))) { - DEBUG_MSG (SUBSET, nullptr, "Couldn't allocate enough space for DeviceRecord: %d.", - size); + DEBUG_MSG(SUBSET, nullptr, "Couldn't allocate enough space for DeviceRecord: %d.", + size); return_trace (false); } this->pixelSize.set (subset_view.source_device_record->pixelSize); this->maxWidth.set (subset_view.source_device_record->maxWidth); - for (unsigned int i = 0; i < subset_view.len(); i++) + for (unsigned int i = 0; i < subset_view.len (); i++) { const HBUINT8 *width = subset_view[i]; if (!width) @@ -135,7 +135,7 @@ struct hdmx inline const DeviceRecord& operator [] (unsigned int i) const { - if (unlikely (i >= numRecords)) return Null(DeviceRecord); + if (unlikely (i >= numRecords)) return Null (DeviceRecord); return StructAtOffset<DeviceRecord> (&this->dataZ, i * sizeDeviceRecord); } @@ -203,7 +203,7 @@ struct hdmx return_trace (c->check_struct (this) && version == 0 && !hb_unsigned_mul_overflows (numRecords, sizeDeviceRecord) && sizeDeviceRecord >= DeviceRecord::min_size && - c->check_range (this, get_size())); + c->check_range (this, get_size ())); } protected: diff --git a/src/hb-ot-hmtx-table.hh b/src/hb-ot-hmtx-table.hh index e2f55579..091b6011 100644 --- a/src/hb-ot-hmtx-table.hh +++ b/src/hb-ot-hmtx-table.hh @@ -66,10 +66,10 @@ struct hmtxvmtx inline bool subset_update_header (hb_subset_plan_t *plan, - unsigned int num_hmetrics) const + unsigned int num_hmetrics) const { - hb_blob_t *src_blob = hb_sanitize_context_t().reference_table<H> (plan->source, H::tableTag); - hb_blob_t *dest_blob = hb_blob_copy_writable_or_fail(src_blob); + hb_blob_t *src_blob = hb_sanitize_context_t ().reference_table<H> (plan->source, H::tableTag); + hb_blob_t *dest_blob = hb_blob_copy_writable_or_fail (src_blob); hb_blob_destroy (src_blob); if (unlikely (!dest_blob)) { @@ -96,15 +96,15 @@ struct hmtxvmtx hb_vector_t<hb_codepoint_t> &gids = plan->glyphs; unsigned int num_advances = gids.len; unsigned int last_advance = _mtx.get_advance (gids[num_advances - 1]); - while (num_advances > 1 - && last_advance == _mtx.get_advance (gids[num_advances - 2])) + while (num_advances > 1 && + last_advance == _mtx.get_advance (gids[num_advances - 2])) { num_advances--; } /* alloc the new table */ size_t dest_sz = num_advances * 4 - + (gids.len - num_advances) * 2; + + (gids.len - num_advances) * 2; void *dest = (void *) malloc (dest_sz); if (unlikely (!dest)) { @@ -277,7 +277,7 @@ struct hmtxvmtx hb_font_t *font) const { unsigned int advance = get_advance (glyph); - if (likely(glyph < num_metrics)) + if (likely (glyph < num_metrics)) { advance += (font->num_coords ? var_table->get_advance_var (glyph, font->coords, font->num_coords) : 0); // TODO Optimize?! } diff --git a/src/hb-ot-layout-common.hh b/src/hb-ot-layout-common.hh index 2ffb7c26..55b05b51 100644 --- a/src/hb-ot-layout-common.hh +++ b/src/hb-ot-layout-common.hh @@ -131,8 +131,8 @@ struct RecordArrayOf : SortedArrayOf<Record<Type> > /* If we want to allow non-sorted data, we can lsearch(). */ int i = this->/*lsearch*/bsearch (tag); if (i != -1) { - if (index) *index = i; - return true; + if (index) *index = i; + return true; } else { if (index) *index = Index::NOT_FOUND_INDEX; return false; @@ -526,21 +526,21 @@ struct FeatureParams { if (tag == HB_TAG ('s','i','z','e')) return u.size; - return Null(FeatureParamsSize); + return Null (FeatureParamsSize); } inline const FeatureParamsStylisticSet& get_stylistic_set_params (hb_tag_t tag) const { if ((tag & 0xFFFF0000u) == HB_TAG ('s','s','\0','\0')) /* ssXX */ return u.stylisticSet; - return Null(FeatureParamsStylisticSet); + return Null (FeatureParamsStylisticSet); } inline const FeatureParamsCharacterVariants& get_character_variants_params (hb_tag_t tag) const { if ((tag & 0xFFFF0000u) == HB_TAG ('c','v','\0','\0')) /* cvXX */ return u.characterVariants; - return Null(FeatureParamsCharacterVariants); + return Null (FeatureParamsCharacterVariants); } private: @@ -704,7 +704,7 @@ struct Lookup for (unsigned int i = 0; i < count; i++) { typename context_t::return_t r = get_subtable<TSubTable> (i).dispatch (c, lookup_type); if (c->stop_sublookup_iteration (r)) - return_trace (r); + return_trace (r); } return_trace (c->default_return_value ()); } @@ -790,7 +790,7 @@ struct Lookup unsigned int type = get_subtable<TSubTable> (0).u.extension.get_type (); unsigned int count = get_subtable_count (); for (unsigned int i = 1; i < count; i++) - if (get_subtable<TSubTable> (i).u.extension.get_type () != type) + if (get_subtable<TSubTable> (i).u.extension.get_type () != type) return_trace (false); } return_trace (true); @@ -854,7 +854,7 @@ struct CoverageFormat1 unsigned int count = glyphArray.len; for (unsigned int i = 0; i < count; i++) if (glyphs->has (glyphArray[i])) - return true; + return true; return false; } inline bool intersects_coverage (const hb_set_t *glyphs, unsigned int index) const @@ -920,7 +920,7 @@ struct CoverageFormat2 unsigned int num_ranges = 1; for (unsigned int i = 1; i < num_glyphs; i++) if (glyphs[i - 1] + 1 != glyphs[i]) - num_ranges++; + num_ranges++; rangeRecord.len.set (num_ranges); if (unlikely (!c->extend (rangeRecord))) return_trace (false); @@ -932,9 +932,9 @@ struct CoverageFormat2 range++; rangeRecord[range].start = glyphs[i]; rangeRecord[range].value.set (i); - rangeRecord[range].end = glyphs[i]; + rangeRecord[range].end = glyphs[i]; } else { - rangeRecord[range].end = glyphs[i]; + rangeRecord[range].end = glyphs[i]; } glyphs += num_glyphs; return_trace (true); @@ -952,7 +952,7 @@ struct CoverageFormat2 unsigned int count = rangeRecord.len; for (unsigned int i = 0; i < count; i++) if (rangeRecord[i].intersects (glyphs)) - return true; + return true; return false; } inline bool intersects_coverage (const hb_set_t *glyphs, unsigned int index) const @@ -964,9 +964,9 @@ struct CoverageFormat2 if (range.value <= index && index < (unsigned int) range.value + (range.end - range.start) && range.intersects (glyphs)) - return true; + return true; else if (index < range.value) - return false; + return false; } return false; } @@ -976,7 +976,7 @@ struct CoverageFormat2 unsigned int count = rangeRecord.len; for (unsigned int i = 0; i < count; i++) if (unlikely (!rangeRecord[i].add_coverage (glyphs))) - return false; + return false; return true; } @@ -992,8 +992,8 @@ struct CoverageFormat2 j = c->rangeRecord.len ? c->rangeRecord[0].start : 0; if (unlikely (c->rangeRecord[0].start > c->rangeRecord[0].end)) { - /* Broken table. Skip. */ - i = c->rangeRecord.len; + /* Broken table. Skip. */ + i = c->rangeRecord.len; } } inline void fini (void) {} @@ -1002,7 +1002,7 @@ struct CoverageFormat2 { if (j >= c->rangeRecord[i].end) { - i++; + i++; if (more ()) { hb_codepoint_t old = j; @@ -1060,7 +1060,7 @@ struct Coverage unsigned int num_ranges = 1; for (unsigned int i = 1; i < num_glyphs; i++) if (glyphs[i - 1] + 1 != glyphs[i]) - num_ranges++; + num_ranges++; u.format.set (num_glyphs * 2 < num_ranges * 3 ? 1 : 2); switch (u.format) { @@ -1213,7 +1213,7 @@ struct ClassDefFormat1 for (unsigned int i = 0; i < count; i++) { if (classValue[i]) - continue; + continue; if (start != i) if (unlikely (!glyphs->add_range (startGlyph + start, startGlyph + i))) @@ -1232,10 +1232,7 @@ struct ClassDefFormat1 inline bool add_class (set_t *glyphs, unsigned int klass) const { unsigned int count = classValue.len; for (unsigned int i = 0; i < count; i++) - { - if (classValue[i] == klass) - glyphs->add (startGlyph + i); - } + if (classValue[i] == klass) glyphs->add (startGlyph + i); return true; } @@ -1246,8 +1243,7 @@ struct ClassDefFormat1 hb_codepoint_t end = startGlyph + classValue.len; for (hb_codepoint_t iter = startGlyph - 1; hb_set_next (glyphs, &iter) && iter < end;) - if (classValue[iter - start]) - return true; + if (classValue[iter - start]) return true; return false; } inline bool intersects_class (const hb_set_t *glyphs, unsigned int klass) const { @@ -1256,18 +1252,15 @@ struct ClassDefFormat1 { /* Match if there's any glyph that is not listed! */ hb_codepoint_t g = HB_SET_VALUE_INVALID; - if (!hb_set_next (glyphs, &g)) - return false; - if (g < startGlyph) - return true; + if (!hb_set_next (glyphs, &g)) return false; + if (g < startGlyph) return true; g = startGlyph + count - 1; - if (hb_set_next (glyphs, &g)) - return true; + if (hb_set_next (glyphs, &g)) return true; /* Fall through. */ } for (unsigned int i = 0; i < count; i++) if (classValue[i] == klass && glyphs->has (startGlyph + i)) - return true; + return true; return false; } @@ -1317,7 +1310,7 @@ struct ClassDefFormat2 for (unsigned int i = 0; i < count; i++) { if (rangeRecord[i].value == klass) - if (unlikely (!rangeRecord[i].add_coverage (glyphs))) + if (unlikely (!rangeRecord[i].add_coverage (glyphs))) return false; } return true; @@ -1329,7 +1322,7 @@ struct ClassDefFormat2 unsigned int count = rangeRecord.len; for (unsigned int i = 0; i < count; i++) if (rangeRecord[i].intersects (glyphs)) - return true; + return true; return false; } inline bool intersects_class (const hb_set_t *glyphs, unsigned int klass) const @@ -1348,12 +1341,12 @@ struct ClassDefFormat2 g = rangeRecord[i].end; } if (g != HB_SET_VALUE_INVALID && hb_set_next (glyphs, &g)) - return true; + return true; /* Fall through. */ } for (unsigned int i = 0; i < count; i++) if (rangeRecord[i].value == klass && rangeRecord[i].intersects (glyphs)) - return true; + return true; return false; } @@ -1498,7 +1491,7 @@ struct VarRegionList int coord = i < coord_len ? coords[i] : 0; float factor = axes[i].evaluate (coord); if (factor == 0.f) - return 0.; + return 0.; v *= factor; } return v; @@ -1564,7 +1557,7 @@ struct VarData { TRACE_SANITIZE (this); return_trace (c->check_struct (this) && - regionIndices.sanitize(c) && + regionIndices.sanitize (c) && shortCount <= regionIndices.len && c->check_range (&StructAfter<HBUINT8> (regionIndices), itemCount, @@ -1684,7 +1677,7 @@ struct ConditionSet unsigned int count = conditions.len; for (unsigned int i = 0; i < count; i++) if (!(this+conditions.arrayZ[i]).evaluate (coords, coord_len)) - return false; + return false; return true; } @@ -1942,7 +1935,7 @@ struct DeviceHeader struct Device { - inline hb_position_t get_x_delta (hb_font_t *font, const VariationStore &store=Null(VariationStore)) const + inline hb_position_t get_x_delta (hb_font_t *font, const VariationStore &store=Null (VariationStore)) const { switch (u.b.format) { @@ -1954,7 +1947,7 @@ struct Device return 0; } } - inline hb_position_t get_y_delta (hb_font_t *font, const VariationStore &store=Null(VariationStore)) const + inline hb_position_t get_y_delta (hb_font_t *font, const VariationStore &store=Null (VariationStore)) const { switch (u.b.format) { diff --git a/src/hb-ot-layout-gpos-table.hh b/src/hb-ot-layout-gpos-table.hh index fb6f6d0f..907fd463 100644 --- a/src/hb-ot-layout-gpos-table.hh +++ b/src/hb-ot-layout-gpos-table.hh @@ -213,7 +213,7 @@ struct ValueFormat : HBUINT16 for (unsigned int i = 0; i < count; i++) { if (!sanitize_value_devices (c, base, values)) - return_trace (false); + return_trace (false); values += len; } @@ -229,7 +229,7 @@ struct ValueFormat : HBUINT16 for (unsigned int i = 0; i < count; i++) { if (!sanitize_value_devices (c, base, values)) - return_trace (false); + return_trace (false); values += stride; } @@ -634,7 +634,7 @@ struct PairSet for (unsigned int i = 0; i < count; i++) { if (glyphs->has (record->secondGlyph)) - return true; + return true; record = &StructAtOffset<const PairValueRecord> (record, record_size); } return false; @@ -675,9 +675,9 @@ struct PairSet const PairValueRecord *record = &StructAtOffset<PairValueRecord> (&firstPairValueRecord, record_size * mid); hb_codepoint_t mid_x = record->secondGlyph; if (x < mid_x) - max = mid - 1; + max = mid - 1; else if (x > mid_x) - min = mid + 1; + min = mid + 1; else { /* Note the intentional use of "|" instead of short-circuit "||". */ @@ -734,10 +734,10 @@ struct PairPosFormat1 for (Coverage::Iter iter (this+coverage); iter.more (); iter.next ()) { if (unlikely (iter.get_coverage () >= count)) - break; /* Work around malicious fonts. https://github.com/harfbuzz/harfbuzz/issues/363 */ + break; /* Work around malicious fonts. https://github.com/harfbuzz/harfbuzz/issues/363 */ if (glyphs->has (iter.get_glyph ()) && (this+pairSet[iter.get_coverage ()]).intersects (glyphs, valueFormat)) - return true; + return true; } return false; } @@ -1421,7 +1421,7 @@ struct MarkMarkPosFormat1 if (id1 == 0) /* Marks belonging to the same base. */ goto good; else if (comp1 == comp2) /* Marks belonging to the same ligature component. */ - goto good; + goto good; } else { /* If ligature ids don't match, it may be the case that one of the marks * itself is a ligature. In which case match. */ diff --git a/src/hb-ot-layout-gsub-table.hh b/src/hb-ot-layout-gsub-table.hh index cef64218..715317b5 100644 --- a/src/hb-ot-layout-gsub-table.hh +++ b/src/hb-ot-layout-gsub-table.hh @@ -588,7 +588,7 @@ struct AlternateSubstFormat1 for (Coverage::Iter iter (this+coverage); iter.more (); iter.next ()) { if (unlikely (iter.get_coverage () >= count)) - break; /* Work around malicious fonts. https://github.com/harfbuzz/harfbuzz/issues/363 */ + break; /* Work around malicious fonts. https://github.com/harfbuzz/harfbuzz/issues/363 */ if (c->glyphs->has (iter.get_glyph ())) (this+alternateSet[iter.get_coverage ()]).closure (c); } @@ -602,7 +602,7 @@ struct AlternateSubstFormat1 for (Coverage::Iter iter (this+coverage); iter.more (); iter.next ()) { if (unlikely (iter.get_coverage () >= count)) - break; /* Work around malicious fonts. https://github.com/harfbuzz/harfbuzz/issues/363 */ + break; /* Work around malicious fonts. https://github.com/harfbuzz/harfbuzz/issues/363 */ (this+alternateSet[iter.get_coverage ()]).collect_glyphs (c); } } diff --git a/src/hb-ot-layout-gsubgpos.hh b/src/hb-ot-layout-gsubgpos.hh index 1335601a..82648680 100644 --- a/src/hb-ot-layout-gsubgpos.hh +++ b/src/hb-ot-layout-gsubgpos.hh @@ -100,14 +100,14 @@ struct hb_closure_context_t : hb_closure_context_t (hb_face_t *face_, hb_set_t *glyphs_, - hb_map_t *done_lookups_, - unsigned int nesting_level_left_ = HB_MAX_NESTING_LEVEL) : + hb_map_t *done_lookups_, + unsigned int nesting_level_left_ = HB_MAX_NESTING_LEVEL) : face (face_), glyphs (glyphs_), recurse_func (nullptr), nesting_level_left (nesting_level_left_), debug_depth (0), - done_lookups (done_lookups_) {} + done_lookups (done_lookups_) {} ~hb_closure_context_t (void) { @@ -291,14 +291,14 @@ struct hb_ot_apply_context_t : }; inline may_match_t may_match (const hb_glyph_info_t &info, - const HBUINT16 *glyph_data) const + const HBUINT16 *glyph_data) const { if (!(info.mask & mask) || (syllable && syllable != info.syllable ())) return MATCH_NO; if (match_func) - return match_func (info.codepoint, *glyph_data, match_data) ? MATCH_YES : MATCH_NO; + return match_func (info.codepoint, *glyph_data, match_data) ? MATCH_YES : MATCH_NO; return MATCH_MAYBE; } @@ -852,9 +852,9 @@ static inline bool match_input (hb_ot_apply_context_t *c, * component, otherwise we shouldn't ligate them... */ if (first_lig_id != this_lig_id || first_lig_comp != this_lig_comp) { - /* ...unless, we are attached to a base ligature and that base + /* ...unless, we are attached to a base ligature and that base * ligature is ignorable. */ - if (ligbase == LIGBASE_NOT_CHECKED) + if (ligbase == LIGBASE_NOT_CHECKED) { bool found = false; const hb_glyph_info_t *out = buffer->out_info; @@ -876,7 +876,7 @@ static inline bool match_input (hb_ot_apply_context_t *c, ligbase = LIGBASE_MAY_NOT_SKIP; } - if (ligbase == LIGBASE_MAY_NOT_SKIP) + if (ligbase == LIGBASE_MAY_NOT_SKIP) return_trace (false); } } @@ -977,7 +977,7 @@ static inline bool ligate_input (hb_ot_apply_context_t *c, { if (is_ligature) { - unsigned int this_comp = _hb_glyph_info_get_lig_comp (&buffer->cur()); + unsigned int this_comp = _hb_glyph_info_get_lig_comp (&buffer->cur()); if (this_comp == 0) this_comp = last_num_components; unsigned int new_lig_comp = components_so_far - last_num_components + @@ -999,7 +999,7 @@ static inline bool ligate_input (hb_ot_apply_context_t *c, /* Re-adjust components for any marks following. */ for (unsigned int i = buffer->idx; i < buffer->len; i++) { if (last_lig_id == _hb_glyph_info_get_lig_id (&buffer->info[i])) { - unsigned int this_comp = _hb_glyph_info_get_lig_comp (&buffer->info[i]); + unsigned int this_comp = _hb_glyph_info_get_lig_comp (&buffer->info[i]); if (!this_comp) break; unsigned int new_lig_comp = components_so_far - last_num_components + @@ -1133,7 +1133,7 @@ static inline bool apply_lookup (hb_ot_apply_context_t *c, int delta = new_len - orig_len; if (!delta) - continue; + continue; /* Recursed lookup changed buffer len. Adjust. * @@ -1376,7 +1376,7 @@ struct RuleSet unsigned int num_rules = rule.len; for (unsigned int i = 0; i < num_rules; i++) if ((this+rule[i]).intersects (glyphs, lookup_context)) - return true; + return true; return false; } @@ -1403,7 +1403,7 @@ struct RuleSet for (unsigned int i = 0; i < num_rules; i++) { if ((this+rule[i]).would_apply (c, lookup_context)) - return_trace (true); + return_trace (true); } return_trace (false); } @@ -1415,7 +1415,7 @@ struct RuleSet for (unsigned int i = 0; i < num_rules; i++) { if ((this+rule[i]).apply (c, lookup_context)) - return_trace (true); + return_trace (true); } return_trace (false); } @@ -1448,10 +1448,10 @@ struct ContextFormat1 for (Coverage::Iter iter (this+coverage); iter.more (); iter.next ()) { if (unlikely (iter.get_coverage () >= count)) - break; /* Work around malicious fonts. https://github.com/harfbuzz/harfbuzz/issues/363 */ + break; /* Work around malicious fonts. https://github.com/harfbuzz/harfbuzz/issues/363 */ if (glyphs->has (iter.get_glyph ()) && (this+ruleSet[iter.get_coverage ()]).intersects (glyphs, lookup_context)) - return true; + return true; } return false; } @@ -1469,7 +1469,7 @@ struct ContextFormat1 for (Coverage::Iter iter (this+coverage); iter.more (); iter.next ()) { if (unlikely (iter.get_coverage () >= count)) - break; /* Work around malicious fonts. https://github.com/harfbuzz/harfbuzz/issues/363 */ + break; /* Work around malicious fonts. https://github.com/harfbuzz/harfbuzz/issues/363 */ if (c->glyphs->has (iter.get_glyph ())) (this+ruleSet[iter.get_coverage ()]).closure (c, lookup_context); } @@ -1564,7 +1564,7 @@ struct ContextFormat2 for (unsigned int i = 0; i < count; i++) if (class_def.intersects_class (glyphs, i) && (this+ruleSet[i]).intersects (glyphs, lookup_context)) - return true; + return true; return false; } @@ -1868,15 +1868,15 @@ static inline void chain_context_closure_lookup (hb_closure_context_t *c, } static inline void chain_context_collect_glyphs_lookup (hb_collect_glyphs_context_t *c, - unsigned int backtrackCount, - const HBUINT16 backtrack[], - unsigned int inputCount, /* Including the first glyph (not matched) */ - const HBUINT16 input[], /* Array of input values--start with second glyph */ - unsigned int lookaheadCount, - const HBUINT16 lookahead[], - unsigned int lookupCount, - const LookupRecord lookupRecord[], - ChainContextCollectGlyphsLookupContext &lookup_context) + unsigned int backtrackCount, + const HBUINT16 backtrack[], + unsigned int inputCount, /* Including the first glyph (not matched) */ + const HBUINT16 input[], /* Array of input values--start with second glyph */ + unsigned int lookaheadCount, + const HBUINT16 lookahead[], + unsigned int lookupCount, + const LookupRecord lookupRecord[], + ChainContextCollectGlyphsLookupContext &lookup_context) { collect_array (c, c->before, backtrackCount, backtrack, @@ -1934,10 +1934,10 @@ static inline bool chain_context_apply_lookup (hb_ot_apply_context_t *c, lookup_context.funcs.match, lookup_context.match_data[2], match_length, &end_index) && (c->buffer->unsafe_to_break_from_outbuffer (start_index, end_index), - apply_lookup (c, - inputCount, match_positions, - lookupCount, lookupRecord, - match_length)); + apply_lookup (c, + inputCount, match_positions, + lookupCount, lookupRecord, + match_length)); } struct ChainRule @@ -2044,7 +2044,7 @@ struct ChainRuleSet unsigned int num_rules = rule.len; for (unsigned int i = 0; i < num_rules; i++) if ((this+rule[i]).intersects (glyphs, lookup_context)) - return true; + return true; return false; } inline void closure (hb_closure_context_t *c, ChainContextClosureLookupContext &lookup_context) const @@ -2069,7 +2069,7 @@ struct ChainRuleSet unsigned int num_rules = rule.len; for (unsigned int i = 0; i < num_rules; i++) if ((this+rule[i]).would_apply (c, lookup_context)) - return_trace (true); + return_trace (true); return_trace (false); } @@ -2080,7 +2080,7 @@ struct ChainRuleSet unsigned int num_rules = rule.len; for (unsigned int i = 0; i < num_rules; i++) if ((this+rule[i]).apply (c, lookup_context)) - return_trace (true); + return_trace (true); return_trace (false); } @@ -2112,10 +2112,10 @@ struct ChainContextFormat1 for (Coverage::Iter iter (this+coverage); iter.more (); iter.next ()) { if (unlikely (iter.get_coverage () >= count)) - break; /* Work around malicious fonts. https://github.com/harfbuzz/harfbuzz/issues/363 */ + break; /* Work around malicious fonts. https://github.com/harfbuzz/harfbuzz/issues/363 */ if (glyphs->has (iter.get_glyph ()) && (this+ruleSet[iter.get_coverage ()]).intersects (glyphs, lookup_context)) - return true; + return true; } return false; } @@ -2133,7 +2133,7 @@ struct ChainContextFormat1 for (Coverage::Iter iter (this+coverage); iter.more (); iter.next ()) { if (unlikely (iter.get_coverage () >= count)) - break; /* Work around malicious fonts. https://github.com/harfbuzz/harfbuzz/issues/363 */ + break; /* Work around malicious fonts. https://github.com/harfbuzz/harfbuzz/issues/363 */ if (c->glyphs->has (iter.get_glyph ())) (this+ruleSet[iter.get_coverage ()]).closure (c, lookup_context); } @@ -2230,7 +2230,7 @@ struct ChainContextFormat2 for (unsigned int i = 0; i < count; i++) if (input_class_def.intersects_class (glyphs, i) && (this+ruleSet[i]).intersects (glyphs, lookup_context)) - return true; + return true; return false; } @@ -2644,10 +2644,10 @@ struct hb_ot_layout_lookup_accelerator_t inline bool apply (hb_ot_apply_context_t *c) const { - for (unsigned int i = 0; i < subtables.len; i++) - if (subtables[i].apply (c)) - return true; - return false; + for (unsigned int i = 0; i < subtables.len; i++) + if (subtables[i].apply (c)) + return true; + return false; } private: @@ -2702,7 +2702,7 @@ struct GSUBGPOS const Feature *feature = (this+featureVars).find_substitute (variations_index, feature_index); if (feature) - return *feature; + return *feature; } return get_feature (feature_index); } @@ -2758,7 +2758,7 @@ struct GSUBGPOS this->accels = (hb_ot_layout_lookup_accelerator_t *) calloc (this->lookup_count, sizeof (hb_ot_layout_lookup_accelerator_t)); if (unlikely (!this->accels)) - this->lookup_count = 0; + this->lookup_count = 0; for (unsigned int i = 0; i < this->lookup_count; i++) this->accels[i].init (table->get_lookup (i)); diff --git a/src/hb-ot-os2-table.hh b/src/hb-ot-os2-table.hh index b2495128..a5a9c07e 100644 --- a/src/hb-ot-os2-table.hh +++ b/src/hb-ot-os2-table.hh @@ -50,7 +50,7 @@ struct OS2 inline bool subset (hb_subset_plan_t *plan) const { - hb_blob_t *os2_blob = hb_sanitize_context_t().reference_table<OS2> (plan->source); + hb_blob_t *os2_blob = hb_sanitize_context_t ().reference_table<OS2> (plan->source); hb_blob_t *os2_prime_blob = hb_blob_create_sub_blob (os2_blob, 0, -1); // TODO(grieger): move to hb_blob_copy_writable_or_fail hb_blob_destroy (os2_blob); @@ -74,7 +74,7 @@ struct OS2 } inline void _update_unicode_ranges (const hb_set_t *codepoints, - HBUINT32 ulUnicodeRange[4]) const + HBUINT32 ulUnicodeRange[4]) const { for (unsigned int i = 0; i < 4; i++) ulUnicodeRange[i].set (0); @@ -84,24 +84,24 @@ struct OS2 unsigned int bit = _hb_ot_os2_get_unicode_range_bit (cp); if (bit < 128) { - unsigned int block = bit / 32; - unsigned int bit_in_block = bit % 32; - unsigned int mask = 1 << bit_in_block; - ulUnicodeRange[block].set (ulUnicodeRange[block] | mask); + unsigned int block = bit / 32; + unsigned int bit_in_block = bit % 32; + unsigned int mask = 1 << bit_in_block; + ulUnicodeRange[block].set (ulUnicodeRange[block] | mask); } if (cp >= 0x10000 && cp <= 0x110000) { - /* the spec says that bit 57 ("Non Plane 0") implies that there's - at least one codepoint beyond the BMP; so I also include all - the non-BMP codepoints here */ - ulUnicodeRange[1].set (ulUnicodeRange[1] | (1 << 25)); + /* the spec says that bit 57 ("Non Plane 0") implies that there's + at least one codepoint beyond the BMP; so I also include all + the non-BMP codepoints here */ + ulUnicodeRange[1].set (ulUnicodeRange[1] | (1 << 25)); } } } static inline void find_min_and_max_codepoint (const hb_set_t *codepoints, - uint16_t *min_cp, /* OUT */ - uint16_t *max_cp /* OUT */) + uint16_t *min_cp, /* OUT */ + uint16_t *max_cp /* OUT */) { *min_cp = codepoints->get_min (); *max_cp = codepoints->get_max (); diff --git a/src/hb-ot-post-table.hh b/src/hb-ot-post-table.hh index 557fefad..f80303cc 100644 --- a/src/hb-ot-post-table.hh +++ b/src/hb-ot-post-table.hh @@ -76,7 +76,7 @@ struct post inline bool subset (hb_subset_plan_t *plan) const { unsigned int post_prime_length; - hb_blob_t *post_blob = hb_sanitize_context_t().reference_table<post>(plan->source); + hb_blob_t *post_blob = hb_sanitize_context_t ().reference_table<post>(plan->source); hb_blob_t *post_prime_blob = hb_blob_create_sub_blob (post_blob, 0, post::min_size); post *post_prime = (post *) hb_blob_get_data_writable (post_prime_blob, &post_prime_length); hb_blob_destroy (post_blob); @@ -101,12 +101,11 @@ struct post { index_to_offset.init (); - table = hb_sanitize_context_t().reference_table<post> (face); + table = hb_sanitize_context_t ().reference_table<post> (face); unsigned int table_length = table.get_length (); version = table->version.to_int (); - if (version != 0x00020000) - return; + if (version != 0x00020000) return; const postV2Tail &v2 = table->v2; @@ -130,10 +129,8 @@ struct post char *buf, unsigned int buf_len) const { hb_bytes_t s = find_glyph_name (glyph); - if (!s.len) - return false; - if (!buf_len) - return true; + if (!s.len) return false; + if (!buf_len) return true; unsigned int len = MIN (buf_len - 1, s.len); strncpy (buf, s.arrayZ, len); buf[len] = '\0'; @@ -144,14 +141,11 @@ struct post hb_codepoint_t *glyph) const { unsigned int count = get_glyph_count (); - if (unlikely (!count)) - return false; + if (unlikely (!count)) return false; - if (len < 0) - len = strlen (name); + if (len < 0) len = strlen (name); - if (unlikely (!len)) - return false; + if (unlikely (!len)) return false; retry: uint16_t *gids = gids_sorted_by_name.get (); @@ -189,10 +183,10 @@ struct post inline unsigned int get_glyph_count (void) const { if (version == 0x00010000) - return NUM_FORMAT1_NAMES; + return NUM_FORMAT1_NAMES; if (version == 0x00020000) - return glyphNameIndex->len; + return glyphNameIndex->len; return 0; } diff --git a/src/hb-subset-glyf.cc b/src/hb-subset-glyf.cc index 499380a9..2219d379 100644 --- a/src/hb-subset-glyf.cc +++ b/src/hb-subset-glyf.cc @@ -31,12 +31,12 @@ static bool _calculate_glyf_and_loca_prime_size (const OT::glyf::accelerator_t &glyf, - hb_vector_t<hb_codepoint_t> &glyph_ids, - hb_bool_t drop_hints, - bool *use_short_loca /* OUT */, - unsigned int *glyf_size /* OUT */, - unsigned int *loca_size /* OUT */, - hb_vector_t<unsigned int> *instruction_ranges /* OUT */) + hb_vector_t<hb_codepoint_t> &glyph_ids, + hb_bool_t drop_hints, + bool *use_short_loca /* OUT */, + unsigned int *glyf_size /* OUT */, + unsigned int *loca_size /* OUT */, + hb_vector_t<unsigned int> *instruction_ranges /* OUT */) { unsigned int total = 0; for (unsigned int i = 0; i < glyph_ids.len; i++) @@ -53,8 +53,8 @@ _calculate_glyf_and_loca_prime_size (const OT::glyf::accelerator_t &glyf, *instruction_end = 0; unsigned int start_offset, end_offset; - if (unlikely (!(glyf.get_offsets(next_glyph, &start_offset, &end_offset) - && glyf.remove_padding(start_offset, &end_offset)))) + if (unlikely (!(glyf.get_offsets (next_glyph, &start_offset, &end_offset) && + glyf.remove_padding (start_offset, &end_offset)))) { DEBUG_MSG(SUBSET, nullptr, "Invalid gid %d", next_glyph); continue; @@ -64,11 +64,11 @@ _calculate_glyf_and_loca_prime_size (const OT::glyf::accelerator_t &glyf, if (drop_hints) { - if (unlikely (!glyf.get_instruction_offsets(start_offset, end_offset, - instruction_start, instruction_end))) + if (unlikely (!glyf.get_instruction_offsets (start_offset, end_offset, + instruction_start, instruction_end))) { - DEBUG_MSG(SUBSET, nullptr, "Unable to get instruction offsets for %d", next_glyph); - return false; + DEBUG_MSG(SUBSET, nullptr, "Unable to get instruction offsets for %d", next_glyph); + return false; } } @@ -80,21 +80,21 @@ _calculate_glyf_and_loca_prime_size (const OT::glyf::accelerator_t &glyf, *glyf_size = total; *use_short_loca = (total <= 131070); *loca_size = (glyph_ids.len + 1) - * (*use_short_loca ? sizeof(OT::HBUINT16) : sizeof(OT::HBUINT32)); + * (*use_short_loca ? sizeof (OT::HBUINT16) : sizeof (OT::HBUINT32)); DEBUG_MSG(SUBSET, nullptr, "preparing to subset glyf: final size %d, loca size %d, using %s loca", - total, - *loca_size, - *use_short_loca ? "short" : "long"); + total, + *loca_size, + *use_short_loca ? "short" : "long"); return true; } static bool _write_loca_entry (unsigned int id, - unsigned int offset, - bool is_short, - void *loca_prime, - unsigned int loca_size) + unsigned int offset, + bool is_short, + void *loca_prime, + unsigned int loca_size) { unsigned int entry_size = is_short ? sizeof (OT::HBUINT16) : sizeof (OT::HBUINT32); if ((id + 1) * entry_size <= loca_size) @@ -108,11 +108,11 @@ _write_loca_entry (unsigned int id, } // Offset was not written because the write is out of bounds. - DEBUG_MSG (SUBSET, - nullptr, - "WARNING: Attempted to write an out of bounds loca entry at index %d. Loca size is %d.", - id, - loca_size); + DEBUG_MSG(SUBSET, + nullptr, + "WARNING: Attempted to write an out of bounds loca entry at index %d. Loca size is %d.", + id, + loca_size); return false; } @@ -130,15 +130,15 @@ _update_components (hb_subset_plan_t * plan, { hb_codepoint_t new_gid; if (!plan->new_gid_for_old_gid (iterator.current->glyphIndex, - &new_gid)) + &new_gid)) continue; ((OT::glyf::CompositeGlyphHeader *) iterator.current)->glyphIndex.set (new_gid); - } while (iterator.move_to_next()); + } while (iterator.move_to_next ()); } } -static bool _remove_composite_instruction_flag(char *glyf_prime, unsigned int length) +static bool _remove_composite_instruction_flag (char *glyf_prime, unsigned int length) { /* remove WE_HAVE_INSTRUCTIONS from flags in dest */ OT::glyf::CompositeGlyphHeader::Iterator composite_it; @@ -148,20 +148,20 @@ static bool _remove_composite_instruction_flag(char *glyf_prime, unsigned int le glyph = composite_it.current; OT::HBUINT16 *flags = const_cast<OT::HBUINT16 *> (&glyph->flags); flags->set ( (uint16_t) *flags & ~OT::glyf::CompositeGlyphHeader::WE_HAVE_INSTRUCTIONS); - } while (composite_it.move_to_next()); + } while (composite_it.move_to_next ()); return true; } static bool _write_glyf_and_loca_prime (hb_subset_plan_t *plan, const OT::glyf::accelerator_t &glyf, - const char *glyf_data, - bool use_short_loca, - hb_vector_t<unsigned int> &instruction_ranges, - unsigned int glyf_prime_size, - char *glyf_prime_data /* OUT */, - unsigned int loca_prime_size, - char *loca_prime_data /* OUT */) + const char *glyf_data, + bool use_short_loca, + hb_vector_t<unsigned int> &instruction_ranges, + unsigned int glyf_prime_size, + char *glyf_prime_data /* OUT */, + unsigned int loca_prime_size, + char *loca_prime_data /* OUT */) { hb_vector_t<hb_codepoint_t> &glyph_ids = plan->glyphs; char *glyf_prime_data_next = glyf_prime_data; @@ -170,8 +170,8 @@ _write_glyf_and_loca_prime (hb_subset_plan_t *plan, for (unsigned int i = 0; i < glyph_ids.len; i++) { unsigned int start_offset, end_offset; - if (unlikely (!(glyf.get_offsets (glyph_ids[i], &start_offset, &end_offset) - && glyf.remove_padding(start_offset, &end_offset)))) + if (unlikely (!(glyf.get_offsets (glyph_ids[i], &start_offset, &end_offset) && + glyf.remove_padding (start_offset, &end_offset)))) end_offset = start_offset = 0; unsigned int instruction_start = instruction_ranges[i * 2]; @@ -181,10 +181,10 @@ _write_glyf_and_loca_prime (hb_subset_plan_t *plan, if (glyf_prime_data_next + length > glyf_prime_data + glyf_prime_size) { - DEBUG_MSG (SUBSET, - nullptr, - "WARNING: Attempted to write an out of bounds glyph entry for gid %d (length %d)", - i, length); + DEBUG_MSG(SUBSET, + nullptr, + "WARNING: Attempted to write an out of bounds glyph entry for gid %d (length %d)", + i, length); return false; } @@ -197,18 +197,18 @@ _write_glyf_and_loca_prime (hb_subset_plan_t *plan, /* if the instructions end at the end this was a composite glyph, else simple */ if (instruction_end == end_offset) { - if (unlikely (!_remove_composite_instruction_flag (glyf_prime_data_next, length))) return false; + if (unlikely (!_remove_composite_instruction_flag (glyf_prime_data_next, length))) return false; } else - /* zero instruction length, which is just before instruction_start */ - memset (glyf_prime_data_next + instruction_start - start_offset - 2, 0, 2); + /* zero instruction length, which is just before instruction_start */ + memset (glyf_prime_data_next + instruction_start - start_offset - 2, 0, 2); } success = success && _write_loca_entry (i, - glyf_prime_data_next - glyf_prime_data, - use_short_loca, - loca_prime_data, - loca_prime_size); + glyf_prime_data_next - glyf_prime_data, + use_short_loca, + loca_prime_data, + loca_prime_size); _update_components (plan, glyf_prime_data_next, length); // TODO: don't align to two bytes if using long loca. @@ -216,20 +216,20 @@ _write_glyf_and_loca_prime (hb_subset_plan_t *plan, } success = success && _write_loca_entry (glyph_ids.len, - glyf_prime_data_next - glyf_prime_data, - use_short_loca, - loca_prime_data, - loca_prime_size); + glyf_prime_data_next - glyf_prime_data, + use_short_loca, + loca_prime_data, + loca_prime_size); return success; } static bool _hb_subset_glyf_and_loca (const OT::glyf::accelerator_t &glyf, - const char *glyf_data, - hb_subset_plan_t *plan, - bool *use_short_loca, - hb_blob_t **glyf_prime /* OUT */, - hb_blob_t **loca_prime /* OUT */) + const char *glyf_data, + hb_subset_plan_t *plan, + bool *use_short_loca, + hb_blob_t **glyf_prime /* OUT */, + hb_blob_t **loca_prime /* OUT */) { // TODO(grieger): Sanity check allocation size for the new table. hb_vector_t<hb_codepoint_t> &glyphs_to_retain = plan->glyphs; @@ -237,43 +237,43 @@ _hb_subset_glyf_and_loca (const OT::glyf::accelerator_t &glyf, unsigned int glyf_prime_size; unsigned int loca_prime_size; hb_vector_t<unsigned int> instruction_ranges; - instruction_ranges.init(); + instruction_ranges.init (); if (unlikely (!_calculate_glyf_and_loca_prime_size (glyf, - glyphs_to_retain, - plan->drop_hints, - use_short_loca, - &glyf_prime_size, - &loca_prime_size, - &instruction_ranges))) { - instruction_ranges.fini(); + glyphs_to_retain, + plan->drop_hints, + use_short_loca, + &glyf_prime_size, + &loca_prime_size, + &instruction_ranges))) { + instruction_ranges.fini (); return false; } char *glyf_prime_data = (char *) calloc (1, glyf_prime_size); char *loca_prime_data = (char *) calloc (1, loca_prime_size); if (unlikely (!_write_glyf_and_loca_prime (plan, glyf, glyf_data, - *use_short_loca, - instruction_ranges, - glyf_prime_size, glyf_prime_data, - loca_prime_size, loca_prime_data))) { + *use_short_loca, + instruction_ranges, + glyf_prime_size, glyf_prime_data, + loca_prime_size, loca_prime_data))) { free (glyf_prime_data); free (loca_prime_data); - instruction_ranges.fini(); + instruction_ranges.fini (); return false; } - instruction_ranges.fini(); + instruction_ranges.fini (); *glyf_prime = hb_blob_create (glyf_prime_data, - glyf_prime_size, - HB_MEMORY_MODE_READONLY, - glyf_prime_data, - free); + glyf_prime_size, + HB_MEMORY_MODE_READONLY, + glyf_prime_data, + free); *loca_prime = hb_blob_create (loca_prime_data, - loca_prime_size, - HB_MEMORY_MODE_READONLY, - loca_prime_data, - free); + loca_prime_size, + HB_MEMORY_MODE_READONLY, + loca_prime_data, + free); return true; } @@ -287,24 +287,24 @@ _hb_subset_glyf_and_loca (const OT::glyf::accelerator_t &glyf, **/ bool hb_subset_glyf_and_loca (hb_subset_plan_t *plan, - bool *use_short_loca, /* OUT */ - hb_blob_t **glyf_prime, /* OUT */ - hb_blob_t **loca_prime /* OUT */) + bool *use_short_loca, /* OUT */ + hb_blob_t **glyf_prime, /* OUT */ + hb_blob_t **loca_prime /* OUT */) { hb_blob_t *glyf_blob = hb_sanitize_context_t ().reference_table<OT::glyf> (plan->source); - const char *glyf_data = hb_blob_get_data(glyf_blob, nullptr); + const char *glyf_data = hb_blob_get_data (glyf_blob, nullptr); OT::glyf::accelerator_t glyf; - glyf.init(plan->source); + glyf.init (plan->source); bool result = _hb_subset_glyf_and_loca (glyf, - glyf_data, - plan, - use_short_loca, - glyf_prime, - loca_prime); + glyf_data, + plan, + use_short_loca, + glyf_prime, + loca_prime); hb_blob_destroy (glyf_blob); - glyf.fini(); + glyf.fini (); return result; } diff --git a/src/hb-subset-glyf.hh b/src/hb-subset-glyf.hh index 3109ecb6..99cf8f07 100644 --- a/src/hb-subset-glyf.hh +++ b/src/hb-subset-glyf.hh @@ -33,8 +33,8 @@ HB_INTERNAL bool hb_subset_glyf_and_loca (hb_subset_plan_t *plan, - bool *use_short_loca, /* OUT */ - hb_blob_t **glyf_prime /* OUT */, - hb_blob_t **loca_prime /* OUT */); + bool *use_short_loca, /* OUT */ + hb_blob_t **glyf_prime /* OUT */, + hb_blob_t **loca_prime /* OUT */); #endif /* HB_SUBSET_GLYF_HH */ diff --git a/src/hb-subset-input.cc b/src/hb-subset-input.cc index d59b5bae..aafd31b9 100644 --- a/src/hb-subset-input.cc +++ b/src/hb-subset-input.cc @@ -72,7 +72,7 @@ hb_subset_input_reference (hb_subset_input_t *subset_input) * Since: 1.8.0 **/ void -hb_subset_input_destroy(hb_subset_input_t *subset_input) +hb_subset_input_destroy (hb_subset_input_t *subset_input) { if (!hb_object_destroy (subset_input)) return; @@ -121,7 +121,7 @@ hb_subset_input_get_drop_hints (hb_subset_input_t *subset_input) HB_EXTERN void hb_subset_input_set_drop_layout (hb_subset_input_t *subset_input, - hb_bool_t drop_layout) + hb_bool_t drop_layout) { subset_input->drop_layout = drop_layout; } diff --git a/src/hb-subset-plan.cc b/src/hb-subset-plan.cc index 64c8ad79..6b526222 100644 --- a/src/hb-subset-plan.cc +++ b/src/hb-subset-plan.cc @@ -57,24 +57,24 @@ _gsub_closure (hb_face_t *face, hb_set_t *gids_to_retain) { hb_set_t lookup_indices; hb_ot_layout_collect_lookups (face, - HB_OT_TAG_GSUB, - nullptr, - nullptr, - nullptr, - &lookup_indices); + HB_OT_TAG_GSUB, + nullptr, + nullptr, + nullptr, + &lookup_indices); hb_ot_layout_lookups_substitute_closure (face, - &lookup_indices, - gids_to_retain); + &lookup_indices, + gids_to_retain); } static hb_set_t * _populate_gids_to_retain (hb_face_t *face, - const hb_set_t *unicodes, - bool close_over_gsub, - hb_set_t *unicodes_to_retain, - hb_map_t *codepoint_to_glyph, - hb_vector_t<hb_codepoint_t> *glyphs) + const hb_set_t *unicodes, + bool close_over_gsub, + hb_set_t *unicodes_to_retain, + hb_map_t *codepoint_to_glyph, + hb_vector_t<hb_codepoint_t> *glyphs) { OT::cmap::accelerator_t cmap; OT::glyf::accelerator_t glyf; @@ -125,7 +125,7 @@ _populate_gids_to_retain (hb_face_t *face, static void _create_old_gid_to_new_gid_map (const hb_vector_t<hb_codepoint_t> &glyphs, - hb_map_t *glyph_map) + hb_map_t *glyph_map) { for (unsigned int i = 0; i < glyphs.len; i++) { glyph_map->set (glyphs[i], i); @@ -144,7 +144,7 @@ _create_old_gid_to_new_gid_map (const hb_vector_t<hb_codepoint_t> &glyphs, **/ hb_subset_plan_t * hb_subset_plan_create (hb_face_t *face, - hb_subset_input_t *input) + hb_subset_input_t *input) { hb_subset_plan_t *plan = hb_object_create<hb_subset_plan_t> (); @@ -163,7 +163,7 @@ hb_subset_plan_create (hb_face_t *face, plan->codepoint_to_glyph, &plan->glyphs); _create_old_gid_to_new_gid_map (plan->glyphs, - plan->glyph_map); + plan->glyph_map); return plan; } @@ -179,7 +179,7 @@ hb_subset_plan_destroy (hb_subset_plan_t *plan) if (!hb_object_destroy (plan)) return; hb_set_destroy (plan->unicodes); - plan->glyphs.fini(); + plan->glyphs.fini (); hb_face_destroy (plan->source); hb_face_destroy (plan->dest); hb_map_destroy (plan->codepoint_to_glyph); diff --git a/src/hb-subset-plan.hh b/src/hb-subset-plan.hh index 5ab32ad8..c574f8f8 100644 --- a/src/hb-subset-plan.hh +++ b/src/hb-subset-plan.hh @@ -56,7 +56,7 @@ struct hb_subset_plan_t inline bool new_gid_for_codepoint (hb_codepoint_t codepoint, - hb_codepoint_t *new_gid) const + hb_codepoint_t *new_gid) const { hb_codepoint_t old_gid = codepoint_to_glyph->get (codepoint); if (old_gid == HB_MAP_VALUE_INVALID) @@ -67,7 +67,7 @@ struct hb_subset_plan_t inline bool new_gid_for_old_gid (hb_codepoint_t old_gid, - hb_codepoint_t *new_gid) const + hb_codepoint_t *new_gid) const { hb_codepoint_t gid = glyph_map->get (old_gid); if (gid == HB_MAP_VALUE_INVALID) @@ -79,13 +79,13 @@ struct hb_subset_plan_t inline bool add_table (hb_tag_t tag, - hb_blob_t *contents) + hb_blob_t *contents) { hb_blob_t *source_blob = source->reference_table (tag); DEBUG_MSG(SUBSET, nullptr, "add table %c%c%c%c, dest %d bytes, source %d bytes", - HB_UNTAG(tag), - hb_blob_get_length (contents), - hb_blob_get_length (source_blob)); + HB_UNTAG(tag), + hb_blob_get_length (contents), + hb_blob_get_length (source_blob)); hb_blob_destroy (source_blob); return hb_face_builder_add_table (dest, tag, contents); } diff --git a/src/hb-subset.cc b/src/hb-subset.cc index a1c52c57..a3917b86 100644 --- a/src/hb-subset.cc +++ b/src/hb-subset.cc @@ -70,10 +70,10 @@ _subset2 (hb_subset_plan_t *plan) { hb_vector_t<char> buf; unsigned int buf_size = _plan_estimate_subset_table_size (plan, source_blob->length); - DEBUG_MSG(SUBSET, nullptr, "OT::%c%c%c%c initial estimated table size: %u bytes.", HB_UNTAG(tag), buf_size); + DEBUG_MSG(SUBSET, nullptr, "OT::%c%c%c%c initial estimated table size: %u bytes.", HB_UNTAG (tag), buf_size); if (unlikely (!buf.alloc (buf_size))) { - DEBUG_MSG(SUBSET, nullptr, "OT::%c%c%c%c failed to allocate %u bytes.", HB_UNTAG(tag), buf_size); + DEBUG_MSG(SUBSET, nullptr, "OT::%c%c%c%c failed to allocate %u bytes.", HB_UNTAG (tag), buf_size); return false; } retry: @@ -83,10 +83,10 @@ _subset2 (hb_subset_plan_t *plan) if (serializer.ran_out_of_room) { buf_size += (buf_size >> 1) + 32; - DEBUG_MSG(SUBSET, nullptr, "OT::%c%c%c%c ran out of room; reallocating to %u bytes.", HB_UNTAG(tag), buf_size); + DEBUG_MSG(SUBSET, nullptr, "OT::%c%c%c%c ran out of room; reallocating to %u bytes.", HB_UNTAG (tag), buf_size); if (unlikely (!buf.alloc (buf_size))) { - DEBUG_MSG(SUBSET, nullptr, "OT::%c%c%c%c failed to reallocate %u bytes.", HB_UNTAG(tag), buf_size); + DEBUG_MSG(SUBSET, nullptr, "OT::%c%c%c%c failed to reallocate %u bytes.", HB_UNTAG (tag), buf_size); return false; } goto retry; @@ -94,21 +94,21 @@ _subset2 (hb_subset_plan_t *plan) if (result) { hb_blob_t *dest_blob = serializer.copy_blob (); - DEBUG_MSG(SUBSET, nullptr, "OT::%c%c%c%c final subset table size: %u bytes.", HB_UNTAG(tag), dest_blob->length); + DEBUG_MSG(SUBSET, nullptr, "OT::%c%c%c%c final subset table size: %u bytes.", HB_UNTAG (tag), dest_blob->length); result = c.plan->add_table (tag, dest_blob); hb_blob_destroy (dest_blob); } else { - DEBUG_MSG(SUBSET, nullptr, "OT::%c%c%c%c::subset table subsetted to empty.", HB_UNTAG(tag)); + DEBUG_MSG(SUBSET, nullptr, "OT::%c%c%c%c::subset table subsetted to empty.", HB_UNTAG (tag)); result = true; } } else - DEBUG_MSG(SUBSET, nullptr, "OT::%c%c%c%c::subset sanitize failed on source table.", HB_UNTAG(tag)); + DEBUG_MSG(SUBSET, nullptr, "OT::%c%c%c%c::subset sanitize failed on source table.", HB_UNTAG (tag)); hb_blob_destroy (source_blob); - DEBUG_MSG(SUBSET, nullptr, "OT::%c%c%c%c::subset %s", HB_UNTAG(tag), result ? "success" : "FAILED!"); + DEBUG_MSG(SUBSET, nullptr, "OT::%c%c%c%c::subset %s", HB_UNTAG (tag), result ? "success" : "FAILED!"); return result; } @@ -124,19 +124,19 @@ _subset (hb_subset_plan_t *plan) if (source_blob->data) result = table->subset (plan); else - DEBUG_MSG(SUBSET, nullptr, "OT::%c%c%c%c::subset sanitize failed on source table.", HB_UNTAG(tag)); + DEBUG_MSG(SUBSET, nullptr, "OT::%c%c%c%c::subset sanitize failed on source table.", HB_UNTAG (tag)); hb_blob_destroy (source_blob); - DEBUG_MSG(SUBSET, nullptr, "OT::%c%c%c%c::subset %s", HB_UNTAG(tag), result ? "success" : "FAILED!"); + DEBUG_MSG(SUBSET, nullptr, "OT::%c%c%c%c::subset %s", HB_UNTAG (tag), result ? "success" : "FAILED!"); return result; } static bool _subset_table (hb_subset_plan_t *plan, - hb_tag_t tag) + hb_tag_t tag) { - DEBUG_MSG(SUBSET, nullptr, "begin subset %c%c%c%c", HB_UNTAG(tag)); + DEBUG_MSG(SUBSET, nullptr, "begin subset %c%c%c%c", HB_UNTAG (tag)); bool result = true; switch (tag) { case HB_OT_TAG_glyf: @@ -186,20 +186,20 @@ _subset_table (hb_subset_plan_t *plan, break; default: - hb_blob_t *source_table = hb_face_reference_table(plan->source, tag); + hb_blob_t *source_table = hb_face_reference_table (plan->source, tag); if (likely (source_table)) - result = plan->add_table(tag, source_table); + result = plan->add_table (tag, source_table); else - result = false; + result = false; hb_blob_destroy (source_table); break; } - DEBUG_MSG(SUBSET, nullptr, "subset %c%c%c%c %s", HB_UNTAG(tag), result ? "ok" : "FAILED"); + DEBUG_MSG(SUBSET, nullptr, "subset %c%c%c%c %s", HB_UNTAG (tag), result ? "ok" : "FAILED"); return result; } static bool -_should_drop_table(hb_subset_plan_t *plan, hb_tag_t tag) +_should_drop_table (hb_subset_plan_t *plan, hb_tag_t tag) { switch (tag) { case HB_TAG ('c', 'v', 'a', 'r'): /* hint table, fallthrough */ @@ -248,9 +248,9 @@ _should_drop_table(hb_subset_plan_t *plan, hb_tag_t tag) **/ hb_face_t * hb_subset (hb_face_t *source, - hb_subset_input_t *input) + hb_subset_input_t *input) { - if (unlikely (!input || !source)) return hb_face_get_empty(); + if (unlikely (!input || !source)) return hb_face_get_empty (); hb_subset_plan_t *plan = hb_subset_plan_create (source, input); @@ -263,17 +263,17 @@ hb_subset (hb_face_t *source, for (unsigned int i = 0; i < count; i++) { hb_tag_t tag = table_tags[i]; - if (_should_drop_table(plan, tag)) + if (_should_drop_table (plan, tag)) { - DEBUG_MSG(SUBSET, nullptr, "drop %c%c%c%c", HB_UNTAG(tag)); - continue; + DEBUG_MSG(SUBSET, nullptr, "drop %c%c%c%c", HB_UNTAG (tag)); + continue; } success = success && _subset_table (plan, tag); } offset += count; } while (success && count == ARRAY_LENGTH (table_tags)); - hb_face_t *result = success ? hb_face_reference(plan->dest) : hb_face_get_empty(); + hb_face_t *result = success ? hb_face_reference (plan->dest) : hb_face_get_empty (); hb_subset_plan_destroy (plan); return result; } diff --git a/src/hb-subset.h b/src/hb-subset.h index 8b07a45e..3b306dd8 100644 --- a/src/hb-subset.h +++ b/src/hb-subset.h @@ -62,15 +62,14 @@ hb_subset_input_get_drop_hints (hb_subset_input_t *subset_input); HB_EXTERN void hb_subset_input_set_drop_layout (hb_subset_input_t *subset_input, - hb_bool_t drop_layout); + hb_bool_t drop_layout); HB_EXTERN hb_bool_t hb_subset_input_get_drop_layout (hb_subset_input_t *subset_input); -/* hb_subset() */ +/* hb_subset () */ HB_EXTERN hb_face_t * -hb_subset (hb_face_t *source, - hb_subset_input_t *input); +hb_subset (hb_face_t *source, hb_subset_input_t *input); HB_END_DECLS diff --git a/util/hb-subset.cc b/util/hb-subset.cc index 3f0963c3..c44f0af9 100644 --- a/util/hb-subset.cc +++ b/util/hb-subset.cc @@ -93,7 +93,7 @@ struct subset_consumer_t hb_face_t *face = hb_font_get_face (font); - hb_face_t *new_face = hb_subset(face, input); + hb_face_t *new_face = hb_subset (face, input); hb_blob_t *result = hb_face_reference_blob (new_face); failed = !hb_blob_get_length (result); |