Fix null accelerator's
Fixes all except for cmap. To be done separately.
Part of https://github.com/harfbuzz/harfbuzz/issues/1146
diff --git a/src/hb-ot-color-cbdt-table.hh b/src/hb-ot-color-cbdt-table.hh
index 614cc80..580dc37 100644
--- a/src/hb-ot-color-cbdt-table.hh
+++ b/src/hb-ot-color-cbdt-table.hh
@@ -409,9 +409,6 @@
inline bool get_extents (hb_font_t *font, hb_codepoint_t glyph,
hb_glyph_extents_t *extents) const
{
- if (!cblc)
- return false;
-
const void *base;
const BitmapSizeTable &strike = this->cblc->choose_strike (font);
const IndexSubtableRecord *subtable_record = strike.find_table (glyph, cblc, &base);
@@ -467,9 +464,6 @@
inline hb_blob_t* reference_png (hb_font_t *font,
hb_codepoint_t glyph) const
{
- if (!cblc)
- return hb_blob_get_empty ();
-
const void *base;
const BitmapSizeTable &strike = this->cblc->choose_strike (font);
const IndexSubtableRecord *subtable_record = strike.find_table (glyph, cblc, &base);
@@ -525,8 +519,8 @@
private:
hb_blob_t *cblc_blob;
hb_blob_t *cbdt_blob;
- const CBLC *cblc;
- const CBDT *cbdt;
+ hb_nonnull_ptr_t<const CBLC> cblc;
+ hb_nonnull_ptr_t<const 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 065c0dd..7a01d14 100644
--- a/src/hb-ot-color-sbix-table.hh
+++ b/src/hb-ot-color-sbix-table.hh
@@ -152,9 +152,6 @@
inline bool has_data () const
{
- /* XXX Fix somehow and remove next line.
- * https://github.com/harfbuzz/harfbuzz/issues/1146 */
- if (!num_glyphs) return false;
return table->has_data ();
}
@@ -234,8 +231,8 @@
hb_codepoint_t glyph,
hb_glyph_extents_t *extents) const
{
- /* Following code is safe to call even without data (XXX currently
- * isn't. See has_data()), but faster to short-circuit. */
+ /* Following code is safe to call even without data.
+ * But faster to short-circuit. */
if (!has_data ())
return false;
@@ -262,12 +259,12 @@
hb_blob_destroy (blob);
- return true;
+ return strike_ppem;
}
private:
hb_blob_t *sbix_blob;
- const sbix *table;
+ hb_nonnull_ptr_t<const 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 bb4c4f7..069c547 100644
--- a/src/hb-ot-color-svg-table.hh
+++ b/src/hb-ot-color-svg-table.hh
@@ -75,12 +75,13 @@
{
static const hb_tag_t tableTag = HB_OT_TAG_SVG;
+ inline bool has_data (void) const { return svgDocEntries; }
+
struct accelerator_t
{
inline void init (hb_face_t *face)
{
svg_blob = hb_sanitize_context_t().reference_table<SVG> (face);
- svg_len = hb_blob_get_length (svg_blob);
table = svg_blob->as<SVG> ();
}
@@ -91,18 +92,14 @@
inline hb_blob_t *reference_blob_for_glyph (hb_codepoint_t glyph_id) const
{
- if (unlikely (!svg_len))
- return hb_blob_get_empty ();
return table->get_glyph_entry (glyph_id).reference_blob (svg_blob, table->svgDocEntries);
}
- inline bool has_data () const { return svg_len; }
+ inline bool has_data () const { return table->has_data (); }
private:
hb_blob_t *svg_blob;
- const SVG *table;
-
- unsigned int svg_len;
+ hb_nonnull_ptr_t<const 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 7bd175e..d2a39f2 100644
--- a/src/hb-ot-glyf-table.hh
+++ b/src/hb-ot-glyf-table.hh
@@ -276,7 +276,7 @@
if (!get_offsets (glyph, &start_offset, &end_offset))
return false; /* glyph not found */
- return CompositeGlyphHeader::get_iterator ((const char*) this->glyf_table + start_offset,
+ return CompositeGlyphHeader::get_iterator ((const char *) this->glyf_table + start_offset,
end_offset - start_offset,
composite);
}
@@ -476,8 +476,8 @@
private:
bool short_offset;
unsigned int num_glyphs;
- const loca *loca_table;
- const glyf *glyf_table;
+ 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;
diff --git a/src/hb-ot-layout-gdef-table.hh b/src/hb-ot-layout-gdef-table.hh
index 7570908..5847953 100644
--- a/src/hb-ot-layout-gdef-table.hh
+++ b/src/hb-ot-layout-gdef-table.hh
@@ -418,7 +418,7 @@
}
hb_blob_t *blob;
- const GDEF *table;
+ hb_nonnull_ptr_t<const GDEF> table;
};
inline unsigned int get_size (void) const
diff --git a/src/hb-ot-layout-gsubgpos.hh b/src/hb-ot-layout-gsubgpos.hh
index 54ae429..0d9eeae 100644
--- a/src/hb-ot-layout-gsubgpos.hh
+++ b/src/hb-ot-layout-gsubgpos.hh
@@ -2774,7 +2774,7 @@
}
hb_blob_t *blob;
- const T *table;
+ hb_nonnull_ptr_t<const T> table;
unsigned int lookup_count;
hb_ot_layout_lookup_accelerator_t *accels;
};
diff --git a/src/hb-ot-name-table.hh b/src/hb-ot-name-table.hh
index 9f67b57..f1e785f 100644
--- a/src/hb-ot-name-table.hh
+++ b/src/hb-ot-name-table.hh
@@ -257,7 +257,7 @@
const void *pool;
unsigned int pool_len;
public:
- const name *table;
+ hb_nonnull_ptr_t<const name> table;
hb_vector_t<hb_ot_name_entry_t> names;
};
diff --git a/src/hb-ot-post-table.hh b/src/hb-ot-post-table.hh
index bd049f9..6432f3f 100644
--- a/src/hb-ot-post-table.hh
+++ b/src/hb-ot-post-table.hh
@@ -254,7 +254,7 @@
private:
hb_blob_t *blob;
uint32_t version;
- const ArrayOf<HBUINT16> *glyphNameIndex;
+ hb_nonnull_ptr_t<const ArrayOf<HBUINT16>> glyphNameIndex;
hb_vector_t<uint32_t, 1> index_to_offset;
const uint8_t *pool;
hb_atomic_ptr_t<uint16_t *> gids_sorted_by_name;