[subset] call collect_mapping only when --gids option is used.
collect_mapping is time consuming as it iterates all codepoints in all cmap subtables, only trigger it when necessary
This commit is contained in:
parent
1ebe5bad1a
commit
8e5bc535d1
|
@ -1359,14 +1359,14 @@ struct cmap
|
|||
unsigned format4objidx = 0, format12objidx = 0, format14objidx = 0;
|
||||
|
||||
for (const EncodingRecord& _ : encodingrec_iter)
|
||||
{
|
||||
unsigned format = (base+_.subtable).u.format;
|
||||
if (!plan->glyphs_requested->is_empty ())
|
||||
{
|
||||
hb_set_t unicodes_set;
|
||||
hb_map_t cp_glyphid_map;
|
||||
(base+_.subtable).collect_mapping (&unicodes_set, &cp_glyphid_map);
|
||||
|
||||
unsigned format = (base+_.subtable).u.format;
|
||||
if (!plan->glyphs_requested->is_empty ())
|
||||
{
|
||||
auto table_iter =
|
||||
+ hb_zip (unicodes_set.iter(), unicodes_set.iter() | hb_map(cp_glyphid_map))
|
||||
| hb_filter (plan->_glyphset, hb_second)
|
||||
|
@ -1389,6 +1389,9 @@ struct cmap
|
|||
* all codepoints in each subtable, which is more efficient */
|
||||
else
|
||||
{
|
||||
hb_set_t unicodes_set;
|
||||
(base+_.subtable).collect_unicodes (&unicodes_set);
|
||||
|
||||
if (format == 4) c->copy (_, + it | hb_filter (unicodes_set, hb_first), 4u, base, plan, &format4objidx);
|
||||
else if (format == 12) c->copy (_, + it | hb_filter (unicodes_set, hb_first), 12u, base, plan, &format12objidx);
|
||||
else if (format == 14) c->copy (_, it, 14u, base, plan, &format14objidx);
|
||||
|
|
|
@ -174,6 +174,8 @@ struct OS2
|
|||
if (unlikely (!os2_prime)) return_trace (false);
|
||||
|
||||
hb_set_t unicodes;
|
||||
if (!c->plan->glyphs_requested->is_empty ())
|
||||
{
|
||||
hb_map_t unicode_glyphid_map;
|
||||
|
||||
OT::cmap::accelerator_t cmap;
|
||||
|
@ -189,12 +191,15 @@ struct OS2
|
|||
| hb_map (hb_first)
|
||||
| hb_sink (unicodes)
|
||||
;
|
||||
}
|
||||
/* when --gids option is not used, no need to do collect_mapping that is
|
||||
* iterating all codepoints in each subtable, which is not efficient */
|
||||
uint16_t min_cp, max_cp;
|
||||
find_min_and_max_codepoint (&unicodes, &min_cp, &max_cp);
|
||||
find_min_and_max_codepoint (unicodes.is_empty () ? c->plan->unicodes : &unicodes, &min_cp, &max_cp);
|
||||
os2_prime->usFirstCharIndex = min_cp;
|
||||
os2_prime->usLastCharIndex = max_cp;
|
||||
|
||||
_update_unicode_ranges (&unicodes, os2_prime->ulUnicodeRange);
|
||||
_update_unicode_ranges (unicodes.is_empty () ? c->plan->unicodes : &unicodes, os2_prime->ulUnicodeRange);
|
||||
|
||||
return_trace (true);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue