[subset] CMAP table subsetting fix

Not all codepoints smaller than 0xFFFF go to cmap4 table.
Only subset codepoints existing in each table.
This will also make harfbuzz consistent with fontTools' behavior
This commit is contained in:
Qunxin Liu 2020-01-28 09:30:51 -08:00 committed by Garret Rieger
parent 777ba47b50
commit b6a8f5e63c
30 changed files with 30 additions and 3 deletions

View File

@ -783,7 +783,7 @@ struct NonDefaultUVS : SortedArrayOf<UVSMapping, HBUINT32>
{
unsigned int count = len;
for (unsigned int i = 0; i < count; i++)
out->add (arrayZ[i].glyphID);
out->add (arrayZ[i].unicodeValue);
}
void closure_glyphs (const hb_set_t *unicodes,
@ -977,6 +977,12 @@ struct CmapSubtableFormat14
;
}
void collect_unicodes (hb_set_t *out) const
{
for (const VariationSelectorRecord& _ : record)
_.collect_unicodes (out, this);
}
bool sanitize (hb_sanitize_context_t *c) const
{
TRACE_SANITIZE (this);
@ -1155,10 +1161,13 @@ struct cmap
for (const EncodingRecord& _ : encodingrec_iter)
{
hb_set_t unicodes_set;
(src_base+_.subtable).collect_unicodes (&unicodes_set);
unsigned format = (src_base+_.subtable).u.format;
if (format == 4) c->copy (_, it, 4u, src_base, this, plan, &format4objidx);
else if (format == 12) c->copy (_, it, 12u, src_base, this, plan, &format12objidx);
if (format == 4) c->copy (_, + it | hb_filter (unicodes_set, hb_first), 4u, src_base, this, plan, &format4objidx);
else if (format == 12) c->copy (_, + it | hb_filter (unicodes_set, hb_first), 12u, src_base, this, plan, &format12objidx);
else if (format == 14) c->copy (_, it, 14u, src_base, this, plan, &format14objidx);
}

View File

@ -17,6 +17,7 @@ EXTRA_DIST += \
expected/layout.gpos2 \
expected/layout.gpos3 \
expected/layout.gsub6 \
expected/cmap \
expected/cmap14 \
expected/sbix \
expected/colr \

View File

@ -9,6 +9,7 @@ TESTS = \
tests/layout.gpos2.tests \
tests/layout.gpos3.tests \
tests/layout.gsub6.tests \
tests/cmap.tests \
tests/cmap14.tests \
tests/sbix.tests \
tests/colr.tests \

Binary file not shown.

View File

@ -0,0 +1,16 @@
FONTS:
AdobeBlank-Regular.ttf
PROFILES:
default.txt
drop-hints.txt
drop-hints-retain-gids.txt
retain-gids.txt
name-ids.txt
SUBSETS:
ﻹﻺ
ﻦﻏ
ab
aﻺ