[subset] make glyph-names option match fonttools behavior

Don't encode psNames that are contained in standard glyph names set
This commit is contained in:
Qunxin Liu authored and Behdad Esfahbod committed 2021-08-20 01:30:23 -06:00
1 parent 829b0f3353
commit 34e0b28fae
8 files changed
+32 -4

No files matched your search

+20 -4
View File
@@ -76,6 +76,9 @@ HB_INTERNAL bool postV2Tail::subset (hb_subset_context_t *c) const
hb_map_t old_new_index_map, old_gid_new_index_map;
unsigned i = 0;
post::accelerator_t _post;
_post.init (c->plan->source);
for (hb_codepoint_t new_gid = 0; new_gid < num_glyphs; new_gid++)
{
hb_codepoint_t old_gid = reverse_glyph_map.get (new_gid);
@@ -86,9 +89,24 @@ HB_INTERNAL bool postV2Tail::subset (hb_subset_context_t *c) const
else if (old_new_index_map.has (old_index)) new_index = old_new_index_map.get (old_index);
else
{
new_index = 258 + i;
hb_bytes_t s = _post.find_glyph_name (old_gid);
int standard_glyph_index = -1;
for (unsigned i = 0; i < format1_names_length; i++)
{
if (s == format1_names (i))
{
standard_glyph_index = i;
break;
}
}
if (standard_glyph_index == -1)
{
new_index = 258 + i;
i++;
}
else
{ new_index = standard_glyph_index; }
old_new_index_map.set (old_index, new_index);
i++;
}
old_gid_new_index_map.set (old_gid, new_index);
}
@@ -103,8 +121,6 @@ HB_INTERNAL bool postV2Tail::subset (hb_subset_context_t *c) const
})
;
post::accelerator_t _post;
_post.init (c->plan->source);
bool ret = serialize (c->serializer, index_iter, &_post);
_post.fini ();
return_trace (ret);