summaryrefslogtreecommitdiff
path: root/thirdparty/harfbuzz/src/hb-ot-post-table.hh
diff options
context:
space:
mode:
Diffstat (limited to 'thirdparty/harfbuzz/src/hb-ot-post-table.hh')
-rw-r--r--thirdparty/harfbuzz/src/hb-ot-post-table.hh36
1 files changed, 27 insertions, 9 deletions
diff --git a/thirdparty/harfbuzz/src/hb-ot-post-table.hh b/thirdparty/harfbuzz/src/hb-ot-post-table.hh
index f22d6e244d..39de671707 100644
--- a/thirdparty/harfbuzz/src/hb-ot-post-table.hh
+++ b/thirdparty/harfbuzz/src/hb-ot-post-table.hh
@@ -55,8 +55,15 @@ struct postV2Tail
return_trace (glyphNameIndex.sanitize (c));
}
+ template<typename Iterator>
+ bool serialize (hb_serialize_context_t *c,
+ Iterator it,
+ const void* _post) const;
+
+ bool subset (hb_subset_context_t *c) const;
+
protected:
- ArrayOf<HBUINT16> glyphNameIndex; /* This is not an offset, but is the
+ Array16Of<HBUINT16> glyphNameIndex; /* This is not an offset, but is the
* ordinal number of the glyph in 'post'
* string tables. */
/*UnsizedArrayOf<HBUINT8>
@@ -71,13 +78,18 @@ struct post
{
static constexpr hb_tag_t tableTag = HB_OT_TAG_post;
- void serialize (hb_serialize_context_t *c) const
+ bool serialize (hb_serialize_context_t *c, bool glyph_names) const
{
+ TRACE_SERIALIZE (this);
post *post_prime = c->allocate_min<post> ();
- if (unlikely (!post_prime)) return;
+ if (unlikely (!post_prime)) return_trace (false);
memcpy (post_prime, this, post::min_size);
- post_prime->version.major = 3; // Version 3 does not have any glyph names.
+ if (!glyph_names)
+ return_trace (c->check_assign (post_prime->version.major, 3,
+ HB_SERIALIZE_ERROR_INT_OVERFLOW)); // Version 3 does not have any glyph names.
+
+ return_trace (true);
}
bool subset (hb_subset_context_t *c) const
@@ -86,13 +98,19 @@ struct post
post *post_prime = c->serializer->start_embed<post> ();
if (unlikely (!post_prime)) return_trace (false);
- serialize (c->serializer);
+ bool glyph_names = c->plan->flags & HB_SUBSET_FLAGS_GLYPH_NAMES;
+ if (!serialize (c->serializer, glyph_names))
+ return_trace (false);
+
+ if (glyph_names && version.major == 2)
+ return_trace (v2X.subset (c));
return_trace (true);
}
struct accelerator_t
{
+ friend struct postV2Tail;
void init (hb_face_t *face)
{
index_to_offset.init ();
@@ -117,7 +135,7 @@ struct post
void fini ()
{
index_to_offset.fini ();
- free (gids_sorted_by_name.get ());
+ hb_free (gids_sorted_by_name.get ());
table.destroy ();
}
@@ -148,7 +166,7 @@ struct post
if (unlikely (!gids))
{
- gids = (uint16_t *) malloc (count * sizeof (gids[0]));
+ gids = (uint16_t *) hb_malloc (count * sizeof (gids[0]));
if (unlikely (!gids))
return false; /* Anything better?! */
@@ -158,7 +176,7 @@ struct post
if (unlikely (!gids_sorted_by_name.cmpexch (nullptr, gids)))
{
- free (gids);
+ hb_free (gids);
goto retry;
}
}
@@ -236,7 +254,7 @@ struct post
private:
uint32_t version;
- const ArrayOf<HBUINT16> *glyphNameIndex;
+ const Array16Of<HBUINT16> *glyphNameIndex;
hb_vector_t<uint32_t> index_to_offset;
const uint8_t *pool;
hb_atomic_ptr_t<uint16_t *> gids_sorted_by_name;