src/hb-blob.hh | 2 +- src/hb-ot-cmap-table.hh | 7 +++---- src/hb-ot-color-cbdt-table.hh | 38 +++++++++++++------------------------- src/hb-ot-color-sbix-table.hh | 10 ++++------ src/hb-ot-color-svg-table.hh | 11 +++++------ src/hb-ot-glyf-table.hh | 22 ++++++++-------------- src/hb-ot-hmtx-table.hh | 24 ++++++++++-------------- src/hb-ot-post-table.hh | 11 +++++------ 8 files changed, 49 insertions(+), 76 deletions(-)
New commits: commit bb9abb4efd7d72198ffe8abb137ccf07ae17743e Author: Behdad Esfahbod <[email protected]> Date: Sun Nov 11 00:39:52 2018 -0500 [hmtx/port] Use hb_blob_ptr_t diff --git a/src/hb-ot-hmtx-table.hh b/src/hb-ot-hmtx-table.hh index f898a033..7a1eb799 100644 --- a/src/hb-ot-hmtx-table.hh +++ b/src/hb-ot-hmtx-table.hh @@ -113,7 +113,7 @@ struct hmtxvmtx DEBUG_MSG(SUBSET, nullptr, "%c%c%c%c in src has %d advances, %d lsbs", HB_UNTAG(T::tableTag), _mtx.num_advances, _mtx.num_metrics - _mtx.num_advances); DEBUG_MSG(SUBSET, nullptr, "%c%c%c%c in dest has %d advances, %d lsbs, %u bytes", HB_UNTAG(T::tableTag), num_advances, gids.len - num_advances, (unsigned int) dest_sz); - const char *source_table = hb_blob_get_data (_mtx.blob, nullptr); + const char *source_table = hb_blob_get_data (_mtx.table.get_blob (), nullptr); // Copy everything over LongMetric * old_metrics = (LongMetric *) source_table; FWORD *lsbs = (FWORD *) (old_metrics + _mtx.num_advances); @@ -221,10 +221,10 @@ struct hmtxvmtx has_font_extents = got_font_extents; - blob = hb_sanitize_context_t().reference_table<hmtxvmtx> (face, T::tableTag); + table = hb_sanitize_context_t().reference_table<hmtxvmtx> (face, T::tableTag); /* Cap num_metrics() and num_advances() based on table length. */ - unsigned int len = hb_blob_get_length (blob); + unsigned int len = table.get_length (); if (unlikely (num_advances * 4 > len)) num_advances = len / 4; num_metrics = num_advances + (len - 4 * num_advances) / 2; @@ -234,19 +234,17 @@ struct hmtxvmtx if (unlikely (!num_advances)) { num_metrics = num_advances = 0; - hb_blob_destroy (blob); - blob = hb_blob_get_empty (); + hb_blob_destroy (table.get_blob ()); + table = hb_blob_get_empty (); } - table = blob->as<hmtxvmtx> (); - var_blob = hb_sanitize_context_t().reference_table<HVARVVAR> (face, T::variationsTag); - var_table = var_blob->as<HVARVVAR> (); + var_table = hb_sanitize_context_t().reference_table<HVARVVAR> (face, T::variationsTag); } inline void fini (void) { - hb_blob_destroy (blob); - hb_blob_destroy (var_blob); + hb_blob_destroy (table.get_blob ()); + hb_blob_destroy (var_table.get_blob ()); } /* TODO Add variations version. */ @@ -301,10 +299,8 @@ struct hmtxvmtx unsigned int default_advance; private: - const hmtxvmtx *table; - hb_blob_t *blob; - const HVARVVAR *var_table; - hb_blob_t *var_blob; + hb_blob_ptr_t<hmtxvmtx> table; + hb_blob_ptr_t<HVARVVAR> var_table; }; protected: diff --git a/src/hb-ot-post-table.hh b/src/hb-ot-post-table.hh index 77eef3f5..48505814 100644 --- a/src/hb-ot-post-table.hh +++ b/src/hb-ot-post-table.hh @@ -101,9 +101,8 @@ struct post { index_to_offset.init (); - blob = hb_sanitize_context_t().reference_table<post> (face); - const post *table = blob->as<post> (); - unsigned int table_length = blob->length; + table = hb_sanitize_context_t().reference_table<post> (face); + unsigned int table_length = table.get_length (); version = table->version.to_int (); if (version != 0x00020000) @@ -114,7 +113,7 @@ struct post glyphNameIndex = &v2.glyphNameIndex; pool = &StructAfter<uint8_t> (v2.glyphNameIndex); - const uint8_t *end = (uint8_t *) table + table_length; + const uint8_t *end = (const uint8_t *) (const void *) table + table_length; for (const uint8_t *data = pool; index_to_offset.len < 65535 && data < end && data + *data < end; data += 1 + *data) @@ -124,7 +123,7 @@ struct post { index_to_offset.fini (); free (gids_sorted_by_name.get ()); - hb_blob_destroy (blob); + hb_blob_destroy (table.get_blob ()); } inline bool get_glyph_name (hb_codepoint_t glyph, @@ -244,7 +243,7 @@ struct post } private: - hb_blob_t *blob; + hb_blob_ptr_t<post> table; uint32_t version; const ArrayOf<HBUINT16> *glyphNameIndex; hb_vector_t<uint32_t, 1> index_to_offset; commit 0e2680a6e8d16afd38ffdb6e8cf244150a5e3837 Author: Behdad Esfahbod <[email protected]> Date: Sun Nov 11 00:28:47 2018 -0500 [cmap] Port to hb_blob_ptr_t Although didn't need it... diff --git a/src/hb-ot-cmap-table.hh b/src/hb-ot-cmap-table.hh index c0e08666..8d94ad31 100644 --- a/src/hb-ot-cmap-table.hh +++ b/src/hb-ot-cmap-table.hh @@ -1014,8 +1014,7 @@ struct cmap { inline void init (hb_face_t *face) { - this->blob = hb_sanitize_context_t().reference_table<cmap> (face); - const cmap *table = this->blob->as<cmap> (); + this->table = hb_sanitize_context_t().reference_table<cmap> (face); bool symbol; this->subtable = table->find_best_subtable (&symbol); this->subtable_uvs = &Null(CmapSubtableFormat14); @@ -1051,7 +1050,7 @@ struct cmap inline void fini (void) { - hb_blob_destroy (this->blob); + hb_blob_destroy (this->table.get_blob ()); } inline bool get_nominal_glyph (hb_codepoint_t unicode, @@ -1157,7 +1156,7 @@ struct cmap CmapSubtableFormat4::accelerator_t format4_accel; - hb_blob_t *blob; + hb_blob_ptr_t<cmap> table; }; protected: commit 0b0fad3ea8888d57d1e077077f5897d1901c5371 Author: Behdad Esfahbod <[email protected]> Date: Sun Nov 11 00:26:55 2018 -0500 [color] Port to hb_blob_ptr_t Fix hb_blob_ptr_t::get_length () as well. diff --git a/src/hb-blob.hh b/src/hb-blob.hh index 7007540c..1b7d4bed 100644 --- a/src/hb-blob.hh +++ b/src/hb-blob.hh @@ -96,7 +96,7 @@ struct hb_blob_ptr_t inline operator const char * (void) const { return (const char *) get (); } inline const T * get (void) const { return b->as<T> (); } inline hb_blob_t * get_blob (void) const { return b.get_raw (); } - inline unsigned int get_length (void) const { return get_blob ()->length; } + inline unsigned int get_length (void) const { return b.get ()->length; } hb_nonnull_ptr_t<hb_blob_t> b; }; diff --git a/src/hb-ot-color-cbdt-table.hh b/src/hb-ot-color-cbdt-table.hh index 580dc376..0a8f4e1a 100644 --- a/src/hb-ot-color-cbdt-table.hh +++ b/src/hb-ot-color-cbdt-table.hh @@ -384,26 +384,16 @@ struct CBDT { inline void init (hb_face_t *face) { - upem = hb_face_get_upem (face); - - cblc_blob = hb_sanitize_context_t().reference_table<CBLC> (face); - cbdt_blob = hb_sanitize_context_t().reference_table<CBDT> (face); - cbdt_len = hb_blob_get_length (cbdt_blob); - - if (hb_blob_get_length (cblc_blob) == 0) { - cblc = nullptr; - cbdt = nullptr; - return; /* Not a bitmap font. */ - } - cblc = cblc_blob->as<CBLC> (); - cbdt = cbdt_blob->as<CBDT> (); + cblc = hb_sanitize_context_t().reference_table<CBLC> (face); + cbdt = hb_sanitize_context_t().reference_table<CBDT> (face); + upem = hb_face_get_upem (face); } inline void fini (void) { - hb_blob_destroy (this->cblc_blob); - hb_blob_destroy (this->cbdt_blob); + hb_blob_destroy (this->cblc.get_blob ()); + hb_blob_destroy (this->cbdt.get_blob ()); } inline bool get_extents (hb_font_t *font, hb_codepoint_t glyph, @@ -423,6 +413,7 @@ struct CBDT return false; { + unsigned int cbdt_len = cbdt.get_length (); if (unlikely (image_offset > cbdt_len || cbdt_len - image_offset < image_length)) return false; @@ -475,6 +466,7 @@ struct CBDT return hb_blob_get_empty (); { + unsigned int cbdt_len = cbdt.get_length (); if (unlikely (image_offset > cbdt_len || cbdt_len - image_offset < image_length)) return hb_blob_get_empty (); @@ -485,7 +477,7 @@ struct CBDT return hb_blob_get_empty (); const GlyphBitmapDataFormat17& glyphFormat17 = StructAtOffset<GlyphBitmapDataFormat17> (this->cbdt, image_offset); - return hb_blob_create_sub_blob (cbdt_blob, + return hb_blob_create_sub_blob (cbdt.get_blob (), image_offset + GlyphBitmapDataFormat17::min_size, glyphFormat17.data.len); } @@ -494,7 +486,7 @@ struct CBDT return hb_blob_get_empty (); const GlyphBitmapDataFormat18& glyphFormat18 = StructAtOffset<GlyphBitmapDataFormat18> (this->cbdt, image_offset); - return hb_blob_create_sub_blob (cbdt_blob, + return hb_blob_create_sub_blob (cbdt.get_blob (), image_offset + GlyphBitmapDataFormat18::min_size, glyphFormat18.data.len); } @@ -503,7 +495,7 @@ struct CBDT return hb_blob_get_empty (); const GlyphBitmapDataFormat19& glyphFormat19 = StructAtOffset<GlyphBitmapDataFormat19> (this->cbdt, image_offset); - return hb_blob_create_sub_blob (cbdt_blob, + return hb_blob_create_sub_blob (cbdt.get_blob (), image_offset + GlyphBitmapDataFormat19::min_size, glyphFormat19.data.len); } @@ -513,16 +505,12 @@ struct CBDT return hb_blob_get_empty (); } - inline bool has_data () const - { return cbdt_len; } + inline bool has_data () const { return cbdt.get_length (); } private: - hb_blob_t *cblc_blob; - hb_blob_t *cbdt_blob; - hb_nonnull_ptr_t<const CBLC> cblc; - hb_nonnull_ptr_t<const CBDT> cbdt; + hb_blob_ptr_t<CBLC> cblc; + hb_blob_ptr_t<CBDT> cbdt; - unsigned int cbdt_len; unsigned int upem; }; diff --git a/src/hb-ot-color-sbix-table.hh b/src/hb-ot-color-sbix-table.hh index 7a01d14a..64ebb63e 100644 --- a/src/hb-ot-color-sbix-table.hh +++ b/src/hb-ot-color-sbix-table.hh @@ -140,14 +140,13 @@ struct sbix { inline void init (hb_face_t *face) { - sbix_blob = hb_sanitize_context_t().reference_table<sbix> (face); - table = sbix_blob->as<sbix> (); + table = hb_sanitize_context_t().reference_table<sbix> (face); num_glyphs = face->get_num_glyphs (); } inline void fini (void) { - hb_blob_destroy (sbix_blob); + hb_blob_destroy (table.get_blob ()); } inline bool has_data () const @@ -169,7 +168,7 @@ struct sbix int *y_offset, unsigned int *available_ppem) const { - return choose_strike (font).get_glyph_blob (glyph_id, sbix_blob, + return choose_strike (font).get_glyph_blob (glyph_id, table.get_blob (), HB_TAG ('p','n','g',' '), x_offset, y_offset, num_glyphs, available_ppem); @@ -263,8 +262,7 @@ struct sbix } private: - hb_blob_t *sbix_blob; - hb_nonnull_ptr_t<const sbix> table; + hb_blob_ptr_t<sbix> table; unsigned int num_glyphs; }; diff --git a/src/hb-ot-color-svg-table.hh b/src/hb-ot-color-svg-table.hh index 069c5478..37b28ea6 100644 --- a/src/hb-ot-color-svg-table.hh +++ b/src/hb-ot-color-svg-table.hh @@ -81,25 +81,24 @@ struct SVG { inline void init (hb_face_t *face) { - svg_blob = hb_sanitize_context_t().reference_table<SVG> (face); - table = svg_blob->as<SVG> (); + table = hb_sanitize_context_t().reference_table<SVG> (face); } inline void fini (void) { - hb_blob_destroy (svg_blob); + hb_blob_destroy (table.get_blob ()); } inline hb_blob_t *reference_blob_for_glyph (hb_codepoint_t glyph_id) const { - return table->get_glyph_entry (glyph_id).reference_blob (svg_blob, table->svgDocEntries); + return table->get_glyph_entry (glyph_id).reference_blob (table.get_blob (), + table->svgDocEntries); } inline bool has_data () const { return table->has_data (); } private: - hb_blob_t *svg_blob; - hb_nonnull_ptr_t<const SVG> table; + hb_blob_ptr_t<SVG> table; }; inline const SVGDocumentIndexEntry &get_glyph_entry (hb_codepoint_t glyph_id) const diff --git a/src/hb-ot-glyf-table.hh b/src/hb-ot-glyf-table.hh index 0623be89..43b921e2 100644 --- a/src/hb-ot-glyf-table.hh +++ b/src/hb-ot-glyf-table.hh @@ -246,19 +246,16 @@ struct glyf short_offset = 0 == head_table->indexToLocFormat; hb_blob_destroy (head_blob); - loca_blob = hb_sanitize_context_t().reference_table<loca> (face); - loca_table = loca_blob->as<loca> (); - glyf_blob = hb_sanitize_context_t().reference_table<glyf> (face); - glyf_table = glyf_blob->as<glyf> (); + loca_table = hb_sanitize_context_t().reference_table<loca> (face); + glyf_table = hb_sanitize_context_t().reference_table<glyf> (face); - num_glyphs = MAX (1u, hb_blob_get_length (loca_blob) / (short_offset ? 2 : 4)) - 1; - glyf_len = hb_blob_get_length (glyf_blob); + num_glyphs = MAX (1u, loca_table.get_length () / (short_offset ? 2 : 4)) - 1; } inline void fini (void) { - hb_blob_destroy (loca_blob); - hb_blob_destroy (glyf_blob); + hb_blob_destroy (loca_table.get_blob ()); + hb_blob_destroy (glyf_table.get_blob ()); } /* @@ -388,7 +385,7 @@ struct glyf *end_offset = offsets[glyph + 1]; } - if (*start_offset > *end_offset || *end_offset > glyf_len) + if (*start_offset > *end_offset || *end_offset > glyf_table.get_length ()) return false; return true; @@ -476,11 +473,8 @@ struct glyf private: bool short_offset; unsigned int num_glyphs; - hb_nonnull_ptr_t<const loca> loca_table; - hb_nonnull_ptr_t<const glyf> glyf_table; - hb_blob_t *loca_blob; - hb_blob_t *glyf_blob; - unsigned int glyf_len; + hb_blob_ptr_t<loca> loca_table; + hb_blob_ptr_t<glyf> glyf_table; }; protected: _______________________________________________ HarfBuzz mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/harfbuzz
