summaryrefslogtreecommitdiff
path: root/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-post-table.hh
diff options
context:
space:
mode:
Diffstat (limited to 'Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-post-table.hh')
-rw-r--r--Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-post-table.hh84
1 files changed, 39 insertions, 45 deletions
diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-post-table.hh b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-post-table.hh
index b15a459b17e..f80303cc8ba 100644
--- a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-post-table.hh
+++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-post-table.hh
@@ -49,12 +49,15 @@ namespace OT {
struct postV2Tail
{
+ friend struct post;
+
inline bool sanitize (hb_sanitize_context_t *c) const
{
TRACE_SANITIZE (this);
return_trace (glyphNameIndex.sanitize (c));
}
+ protected:
ArrayOf<HBUINT16> glyphNameIndex; /* This is not an offset, but is the
* ordinal number of the glyph in 'post'
* string tables. */
@@ -62,6 +65,7 @@ struct postV2Tail
namesX; /* Glyph names with length bytes [variable]
* (a Pascal string). */
+ public:
DEFINE_SIZE_ARRAY2 (2, glyphNameIndex, namesX);
};
@@ -69,28 +73,15 @@ struct post
{
static const hb_tag_t tableTag = HB_OT_TAG_post;
- inline bool sanitize (hb_sanitize_context_t *c) const
- {
- TRACE_SANITIZE (this);
- if (unlikely (!c->check_struct (this)))
- return_trace (false);
- if (version.to_int () == 0x00020000)
- {
- const postV2Tail &v2 = StructAfter<postV2Tail> (*this);
- return_trace (v2.sanitize (c));
- }
- return_trace (true);
- }
-
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_prime_blob = hb_blob_create_sub_blob (post_blob, 0, post::static_size);
+ 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);
- if (unlikely (!post_prime || post_prime_length != post::static_size))
+ if (unlikely (!post_prime || post_prime_length != post::min_size))
{
hb_blob_destroy (post_prime_blob);
DEBUG_MSG(SUBSET, nullptr, "Invalid source post table with length %d.", post_prime_length);
@@ -110,42 +101,39 @@ 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)
- return;
+ if (version != 0x00020000) return;
- const postV2Tail &v2 = StructAfter<postV2Tail> (*table);
+ const postV2Tail &v2 = table->v2;
glyphNameIndex = &v2.glyphNameIndex;
pool = &StructAfter<uint8_t> (v2.glyphNameIndex);
- const uint8_t *end = (uint8_t *) table + table_length;
- for (const uint8_t *data = pool; data < end && data + *data <= end; data += 1 + *data)
+ 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)
index_to_offset.push (data - pool);
}
inline void fini (void)
{
index_to_offset.fini ();
free (gids_sorted_by_name.get ());
- hb_blob_destroy (blob);
+ table.destroy ();
}
inline bool get_glyph_name (hb_codepoint_t glyph,
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 (buf_len <= s.len) /* What to do with truncation? Returning false for now. */
- return false;
- strncpy (buf, s.arrayZ, s.len);
- buf[s.len] = '\0';
+ 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';
return true;
}
@@ -153,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 ();
@@ -198,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;
}
@@ -252,14 +237,23 @@ struct post
}
private:
- hb_blob_t *blob;
+ hb_blob_ptr_t<post> table;
uint32_t version;
- hb_nonnull_ptr_t<const ArrayOf<HBUINT16> > glyphNameIndex;
+ 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;
};
+ inline bool sanitize (hb_sanitize_context_t *c) const
+ {
+ TRACE_SANITIZE (this);
+ return_trace (likely (c->check_struct (this) &&
+ (version.to_int () == 0x00010000 ||
+ (version.to_int () == 0x00020000 && v2.sanitize (c)) ||
+ version.to_int () == 0x00030000)));
+ }
+
public:
FixedVersion<>version; /* 0x00010000 for version 1.0
* 0x00020000 for version 2.0
@@ -292,8 +286,8 @@ struct post
* is downloaded as a Type 1 font. */
HBUINT32 maxMemType1; /* Maximum memory usage when an OpenType font
* is downloaded as a Type 1 font. */
-/*postV2Tail v2[VAR];*/
- DEFINE_SIZE_STATIC (32);
+ postV2Tail v2;
+ DEFINE_SIZE_MIN (32);
};
struct post_accelerator_t : post::accelerator_t {};