[color] Port to hb_blob_ptr_t
Fix hb_blob_ptr_t::get_length () as well.
This commit is contained in:
parent
925b7a214f
commit
0b0fad3ea8
@ -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;
|
||||
};
|
||||
|
@ -384,26 +384,16 @@ struct CBDT
|
||||
{
|
||||
inline void init (hb_face_t *face)
|
||||
{
|
||||
cblc = hb_sanitize_context_t().reference_table<CBLC> (face);
|
||||
cbdt = hb_sanitize_context_t().reference_table<CBDT> (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> ();
|
||||
|
||||
}
|
||||
|
||||
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;
|
||||
};
|
||||
|
||||
|
@ -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;
|
||||
};
|
||||
|
@ -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
|
||||
|
@ -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:
|
||||
|
Loading…
Reference in New Issue
Block a user