[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:
parent
829b0f3353
commit
34e0b28fae
|
@ -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);
|
||||
|
|
|
@ -41,6 +41,7 @@ EXTRA_DIST += \
|
|||
expected/colr_with_components \
|
||||
expected/cbdt \
|
||||
expected/variable \
|
||||
expected/glyph_names \
|
||||
fonts \
|
||||
profiles \
|
||||
$(NULL)
|
||||
|
|
|
@ -33,6 +33,7 @@ TESTS = \
|
|||
tests/layout.tests \
|
||||
tests/sbix.tests \
|
||||
tests/variable.tests \
|
||||
tests/glyph_names.tests \
|
||||
$(NULL)
|
||||
|
||||
# TODO: re-enable once colrv1 subsetting is stabilized.
|
||||
|
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -0,0 +1,9 @@
|
|||
FONTS:
|
||||
Ubuntu-Regular.ttf
|
||||
|
||||
PROFILES:
|
||||
glyph-names.txt
|
||||
|
||||
SUBSETS:
|
||||
U+0x0,U+0x8,U+0x9,U+0x1d,U+0x20,U+0xb7
|
||||
*
|
|
@ -36,6 +36,7 @@ tests = [
|
|||
'colr_with_components',
|
||||
'cbdt',
|
||||
'variable',
|
||||
'glyph_names',
|
||||
]
|
||||
|
||||
repack_tests = [
|
||||
|
|
Loading…
Reference in New Issue