Skip to content

Commit

Permalink
[buildcff2vf] fix bug 817: unintentional subsetting of features
Browse files Browse the repository at this point in the history
A side effect of of using the fontTools subsetter module to implement glyph subsetting with the -i option is that features are removed if they are not in the subsetter default features set . Since buildcff2vf  is not intended to filter out features, I fixed this by setting the subsetter module's layout_features option field to '*', which causes it to pass through all features.
  • Loading branch information
readroberts committed Jun 26, 2019
1 parent 5a1eda3 commit a8ecfcf
Show file tree
Hide file tree
Showing 8 changed files with 107 additions and 1 deletion.
2 changes: 1 addition & 1 deletion python/afdko/buildcff2vf.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ def getSubset(subset_Path):

def subset_masters(designspace, subsetDict):
from fontTools import subset
subset_options = subset.Options(notdef_outline=True)
subset_options = subset.Options(notdef_outline=True, layout_features='*')
for ds_source in designspace.sources:
key = tuple(ds_source.location.items())
included = set(subsetDict[key])
Expand Down
43 changes: 43 additions & 0 deletions tests/buildcff2vf_data/expected_output/bug817.ttx
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<?xml version="1.0" encoding="UTF-8"?>
<ttFont sfntVersion="OTTO" ttLibVersion="3.43">

<GSUB>
<Version value="0x00010000"/>
<ScriptList>
<!-- ScriptCount=1 -->
<ScriptRecord index="0">
<ScriptTag value="DFLT"/>
<Script>
<DefaultLangSys>
<ReqFeatureIndex value="65535"/>
<!-- FeatureCount=1 -->
<FeatureIndex index="0" value="0"/>
</DefaultLangSys>
<!-- LangSysCount=0 -->
</Script>
</ScriptRecord>
</ScriptList>
<FeatureList>
<!-- FeatureCount=1 -->
<FeatureRecord index="0">
<FeatureTag value="test"/>
<Feature>
<!-- LookupCount=1 -->
<LookupListIndex index="0" value="0"/>
</Feature>
</FeatureRecord>
</FeatureList>
<LookupList>
<!-- LookupCount=1 -->
<Lookup index="0">
<LookupType value="1"/>
<LookupFlag value="0"/>
<!-- SubTableCount=1 -->
<SingleSubst index="0" Format="1">
<Substitution in="A" out="A"/>
</SingleSubst>
</Lookup>
</LookupList>
</GSUB>

</ttFont>
41 changes: 41 additions & 0 deletions tests/buildcff2vf_data/input/bug817/bug817.designspace
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<?xml version="1.0" encoding="utf-8"?>
<designspace format="3">
<axes>
<axis default="368" maximum="1000.0" minimum="0.0" name="weight" tag="wght">
</axis>
</axes>
<sources>
<source filename="source_fonts/SourceCode_ExtraLight.ufo" name="master_0">
<location>
<dimension name="weight" xvalue="0" />
</location>
</source>
<source filename="source_fonts/SourceCode_Regular.ufo" name="master_1">
<location>
<dimension name="weight" xvalue="368" />
</location>
</source>
<source filename="source_fonts/SourceCode_Black.ufo" name="master_2">
<location>
<dimension name="weight" xvalue="1000" />
</location>
</source>
</sources>
<instances>
<instance familyname="Bug 816 TestVF" postscriptfontname="SourceCodeRoman-ExtraLight" stylename="ExtraLight">
<location>
<dimension name="weight" xvalue="0" />
</location>
</instance>
<instance familyname="Bug 816 TestVF" postscriptfontname="SourceCodeRoman-Regular" stylename="Regular">
<location>
<dimension name="weight" xvalue="368" />
</location>
</instance>
<instance familyname="Bug 816 TestVF" postscriptfontname="SourceCodeRoman-Black" stylename="Black">
<location>
<dimension name="weight" xvalue="1000" />
</location>
</instance>
</instances>
</designspace>
7 changes: 7 additions & 0 deletions tests/buildcff2vf_data/input/bug817/bug817.subset
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
((('weight',0.0),), (('weight', 368.0),),)
.notdef
A
T
((('weight',1000.0),),)
.notdef
A
Binary file not shown.
Binary file not shown.
Binary file not shown.
15 changes: 15 additions & 0 deletions tests/buildcff2vf_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,3 +71,18 @@ def test_compatibility_vf():
['CFF2', ])
expected_ttx = get_expected_path('bug816.ttx')
assert differ([expected_ttx, actual_ttx, '-s', '<ttFont sfntVersion'])


def test_subset_vf():
input_dir = get_input_path('bug817')
temp_dir = os.path.join(tempfile.mkdtemp(), 'bug817var')
copytree(input_dir, temp_dir)
ds_path = os.path.join(temp_dir, 'bug817.designspace')
subset_path = os.path.join(temp_dir, 'bug817.subset')
runner(CMD + ['-o', 'd', '_{}'.format(
ds_path), 'i', '_{}'.format(subset_path)])
actual_path = os.path.join(temp_dir, 'bug817.otf')
actual_ttx = generate_ttx_dump(actual_path,
['GSUB', ])
expected_ttx = get_expected_path('bug817.ttx')
assert differ([expected_ttx, actual_ttx, '-s', '<ttFont sfntVersion'])

0 comments on commit a8ecfcf

Please sign in to comment.