[cff1] Hygiene

pull/4264/head
Behdad Esfahbod 1 year ago
parent ebc5257e29
commit bf0a08c930
  1. 2
      src/hb-open-type.hh
  2. 13
      src/hb-ot-cff1-table.hh
  3. 2
      src/hb-subset-cff1.cc

@ -479,7 +479,7 @@ struct UnsizedArrayOf
return *p; return *p;
} }
unsigned int get_size (unsigned int len) const static unsigned int get_size (unsigned int len)
{ return len * Type::static_size; } { return len * Type::static_size; }
template <typename T> operator T * () { return arrayZ; } template <typename T> operator T * () { return arrayZ; }

@ -312,11 +312,12 @@ struct Encoding
}; };
/* Charset */ /* Charset */
struct Charset0 { struct Charset0
{
bool sanitize (hb_sanitize_context_t *c, unsigned int num_glyphs) const bool sanitize (hb_sanitize_context_t *c, unsigned int num_glyphs) const
{ {
TRACE_SANITIZE (this); TRACE_SANITIZE (this);
return_trace (c->check_struct (this) && sids[num_glyphs - 1].sanitize (c)); return_trace (sids.sanitize (c, num_glyphs - 1));
} }
hb_codepoint_t get_sid (hb_codepoint_t glyph, unsigned num_glyphs) const hb_codepoint_t get_sid (hb_codepoint_t glyph, unsigned num_glyphs) const
@ -347,13 +348,13 @@ struct Charset0 {
return 0; return 0;
} }
unsigned int get_size (unsigned int num_glyphs) const static unsigned int get_size (unsigned int num_glyphs)
{ {
assert (num_glyphs > 0); assert (num_glyphs > 0);
return HBUINT16::static_size * (num_glyphs - 1); return UnsizedArrayOf<HBUINT16>::get_size (num_glyphs - 1);
} }
HBUINT16 sids[HB_VAR_ARRAY]; UnsizedArrayOf<HBUINT16> sids;
DEFINE_SIZE_ARRAY(0, sids); DEFINE_SIZE_ARRAY(0, sids);
}; };
@ -490,7 +491,7 @@ struct Charset
{ {
case 0: case 0:
{ {
Charset0 *fmt0 = c->allocate_size<Charset0> (Charset0::min_size + HBUINT16::static_size * (num_glyphs - 1)); Charset0 *fmt0 = c->allocate_size<Charset0> (Charset0::get_size (num_glyphs));
if (unlikely (!fmt0)) return_trace (false); if (unlikely (!fmt0)) return_trace (false);
unsigned int glyph = 0; unsigned int glyph = 0;
for (unsigned int i = 0; i < sid_ranges.length; i++) for (unsigned int i = 0; i < sid_ranges.length; i++)

@ -525,7 +525,7 @@ struct cff_subset_plan {
bool two_byte = subset_charset_ranges.complete (glyph); bool two_byte = subset_charset_ranges.complete (glyph);
size0 = Charset0::min_size + HBUINT16::static_size * (plan->num_output_glyphs () - 1); size0 = Charset0::get_size (plan->num_output_glyphs ());
if (!two_byte) if (!two_byte)
size_ranges = Charset1::min_size + Charset1_Range::static_size * subset_charset_ranges.length; size_ranges = Charset1::min_size + Charset1_Range::static_size * subset_charset_ranges.length;
else else

Loading…
Cancel
Save