[subset] Move OS/2 to subset2.

This commit is contained in:
Garret Rieger 2019-06-05 17:40:59 -07:00
parent 93d592e0e1
commit f9b1ae7336
2 changed files with 17 additions and 17 deletions

View File

@ -145,29 +145,20 @@ struct OS2
} }
} }
bool subset (hb_subset_plan_t *plan) const bool subset (hb_subset_context_t *c) const
{ {
hb_blob_t *os2_blob = hb_sanitize_context_t ().reference_table<OS2> (plan->source); TRACE_SUBSET (this);
hb_blob_t *os2_prime_blob = hb_blob_create_sub_blob (os2_blob, 0, -1); OS2 *os2_prime = c->serializer->embed (this);
// TODO(grieger): move to hb_blob_copy_writable_or_fail if (unlikely (!os2_prime)) return_trace (false);
hb_blob_destroy (os2_blob);
OS2 *os2_prime = (OS2 *) hb_blob_get_data_writable (os2_prime_blob, nullptr);
if (unlikely (!os2_prime)) {
hb_blob_destroy (os2_prime_blob);
return false;
}
uint16_t min_cp, max_cp; uint16_t min_cp, max_cp;
find_min_and_max_codepoint (plan->unicodes, &min_cp, &max_cp); find_min_and_max_codepoint (c->plan->unicodes, &min_cp, &max_cp);
os2_prime->usFirstCharIndex = min_cp; os2_prime->usFirstCharIndex = min_cp;
os2_prime->usLastCharIndex = max_cp; os2_prime->usLastCharIndex = max_cp;
_update_unicode_ranges (plan->unicodes, os2_prime->ulUnicodeRange); _update_unicode_ranges (c->plan->unicodes, os2_prime->ulUnicodeRange);
bool result = plan->add_table (HB_OT_TAG_OS2, os2_prime_blob);
hb_blob_destroy (os2_prime_blob); return_trace (true);
return result;
} }
void _update_unicode_ranges (const hb_set_t *codepoints, void _update_unicode_ranges (const hb_set_t *codepoints,
@ -218,6 +209,15 @@ struct OS2
font_page_t get_font_page () const font_page_t get_font_page () const
{ return (font_page_t) (version == 0 ? fsSelection & 0xFF00 : 0); } { return (font_page_t) (version == 0 ? fsSelection & 0xFF00 : 0); }
unsigned get_size () const
{
unsigned result = min_size;
if (version >= 1) result += v1X.get_size ();
if (version >= 2) result += v2X.get_size ();
if (version >= 5) result += v5X.get_size ();
return result;
}
bool sanitize (hb_sanitize_context_t *c) const bool sanitize (hb_sanitize_context_t *c) const
{ {
TRACE_SANITIZE (this); TRACE_SANITIZE (this);

View File

@ -190,7 +190,7 @@ _subset_table (hb_subset_plan_t *plan,
result = _subset<const OT::cmap> (plan); result = _subset<const OT::cmap> (plan);
break; break;
case HB_OT_TAG_OS2: case HB_OT_TAG_OS2:
result = _subset<const OT::OS2> (plan); result = _subset2<const OT::OS2> (plan);
break; break;
case HB_OT_TAG_post: case HB_OT_TAG_post:
result = _subset2<const OT::post> (plan); result = _subset2<const OT::post> (plan);