added desubroutinize & retain-gids full test cases with CFF fonts

and CFF retain-gids fixes
This commit is contained in:
Michiharu Ariza 2019-02-01 14:50:01 -08:00
parent f2908b4d8f
commit c12862657f
54 changed files with 36 additions and 27 deletions

View File

@ -476,24 +476,20 @@ struct cff_subset_plan {
unsigned int glyph;
for (glyph = 1; glyph < plan->num_output_glyphs (); glyph++)
{
hb_codepoint_t orig_glyph;
if (!plan->old_gid_for_new_gid (glyph, &orig_glyph))
hb_codepoint_t old_glyph;
if (!plan->old_gid_for_new_gid (glyph, &old_glyph))
{
/* pretend a missing glyph has the last code + 1
* as an attempt to minimize the number of ranges */
code = last_code + 1;
/* Retain the code for the old missing glyph ID */
old_glyph = glyph;
}
else
code = acc.glyph_to_code (old_glyph);
if (code == CFF_UNDEF_CODE)
{
code = acc.glyph_to_code (orig_glyph);
if (code == CFF_UNDEF_CODE)
{
subset_enc_num_codes = glyph - 1;
break;
}
subset_enc_num_codes = glyph - 1;
break;
}
if (code != last_code + 1)
if ((last_code == CFF_UNDEF_CODE) || (code != last_code + 1))
{
code_pair_t pair = { code, glyph };
subset_enc_code_ranges.push (pair);
@ -502,7 +498,7 @@ struct cff_subset_plan {
if (encoding != &Null(Encoding))
{
hb_codepoint_t sid = acc.glyph_to_sid (orig_glyph);
hb_codepoint_t sid = acc.glyph_to_sid (old_glyph);
encoding->get_supplement_codes (sid, supp_codes);
for (unsigned int i = 0; i < supp_codes.length; i++)
{
@ -540,22 +536,18 @@ struct cff_subset_plan {
unsigned int glyph;
for (glyph = 1; glyph < plan->num_output_glyphs (); glyph++)
{
hb_codepoint_t orig_glyph;
if (!plan->old_gid_for_new_gid (glyph, &orig_glyph))
hb_codepoint_t old_glyph;
if (!plan->old_gid_for_new_gid (glyph, &old_glyph))
{
/* pretend a missing glyph has the last sid + 1
* as an attempt to minimize the number of ranges */
sid = last_sid + 1;
/* Retain the SID for the old missing glyph ID */
old_glyph = glyph;
}
else
{
sid = acc.glyph_to_sid (orig_glyph);
sid = acc.glyph_to_sid (old_glyph);
if (!acc.is_CID ())
sid = sidmap.add (sid);
}
if (!acc.is_CID ())
sid = sidmap.add (sid);
if (sid != last_sid + 1)
if ((last_sid == CFF_UNDEF_CODE) || (sid != last_sid + 1))
{
code_pair_t pair = { sid, glyph };
subset_charset_ranges.push (pair);

View File

@ -0,0 +1,2 @@
--desubroutinize
--retain-gids

View File

@ -0,0 +1,3 @@
--no-hinting
--desubroutinize
--retain-gids

View File

@ -5,6 +5,12 @@ SourceSansPro-Regular.otf
PROFILES:
default.txt
drop-hints.txt
drop-hints-retain-gids.txt
retain-gids.txt
desubroutinize.txt
desubroutinize-retain-gids.txt
drop-hints-desubroutinize.txt
drop-hints-desubroutinize-retain-gids.txt
SUBSETS:
abc

View File

@ -5,6 +5,12 @@ SourceHanSans-Regular.otf
PROFILES:
default.txt
drop-hints.txt
drop-hints-retain-gids.txt
retain-gids.txt
desubroutinize.txt
desubroutinize-retain-gids.txt
drop-hints-desubroutinize.txt
drop-hints-desubroutinize-retain-gids.txt
SUBSETS:

View File

@ -34,7 +34,7 @@ class Test:
return font_base_name_parts[1]
def applicable(self):
return self.profile_path.find("desubroutinize") < 0 or self.get_font_extension() == "otf"
return self.profile_path.find("desubroutinize") < 0 and self.profile_path.find("retain-gids") < 0 or self.get_font_extension() == ".otf"
# A group of tests to perform on the subsetter. Each test
# Identifies a font a subsetting profile, and a subset to be cut.