Skip to content

Commit

Permalink
[makeotf test] Tests for validating current handling of include() in …
Browse files Browse the repository at this point in the history
…FEA files

This issue touches on two problems. The features file spec says that feature include files are relative to the parent including files, but several implementations assume that relative paths are all relative to the main feature file. The second problem is that the UFO spec says that for UFO fonts, a relative include file path is always relative to the UFO font directory. In the discussion thread for this issue, it was agreed that for non-UFO fonts, the default is to resolve relative include paths relative to the main feature file, and relative to the UFO font directory for UFO fonts. Also, for legacy project support, if an include file cannot be found, makeotfexe should also look relative to including file.

makeotfexe currently supports both of the first two implementations, but does not support include paths relative to the UFO font directory. This commit adds a test case documenting current behavior.
  • Loading branch information
readroberts authored and miguelsousa committed Oct 5, 2018
1 parent feaa64b commit 98e8d12
Show file tree
Hide file tree
Showing 16 changed files with 293 additions and 1 deletion.
Empty file.
65 changes: 65 additions & 0 deletions tests/makeotf_data/input/bug164/d1/d2/font.pfa

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
include(../../rel_to_main1.fea);
62 changes: 62 additions & 0 deletions tests/makeotf_data/input/bug164/d1/d2/font.ufo/fontinfo.plist
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>postscriptFontName</key>
<string>SourceSans-Test</string>
<key>styleName</key>
<string>Test</string>
<key>familyName</key>
<string>Source Sans</string>
<key>versionMajor</key>
<integer>2</integer>
<key>versionMinor</key>
<integer>20</integer>
<key>copyright</key>
<string>Copyright 2010, 2012, 2014 Adobe Systems Incorporated (http://www.adobe.com/), with Reserved Font Name 'Source'.</string>
<key>trademark</key>
<string>Source is a trademark of Adobe Systems Incorporated in the United States and/or other countries.</string>
<key>unitsPerEm</key>
<integer>1000</integer>
<key>postscriptUnderlinePosition</key>
<integer>-75</integer>
<key>postscriptBlueValues</key>
<array>
<integer>-12</integer>
<integer>0</integer>
<integer>486</integer>
<integer>498</integer>
<integer>518</integer>
<integer>530</integer>
<integer>574</integer>
<integer>586</integer>
<integer>638</integer>
<integer>650</integer>
<integer>656</integer>
<integer>668</integer>
<integer>712</integer>
<integer>724</integer>
</array>
<key>postscriptOtherBlues</key>
<array>
<integer>-217</integer>
<integer>-205</integer>
</array>
<key>postscriptStemSnapH</key>
<array>
<integer>67</integer>
<integer>78</integer>
</array>
<key>postscriptStemSnapV</key>
<array>
<integer>84</integer>
<integer>95</integer>
</array>
<key>postscriptBlueScale</key>
<real>0.0625</real>
<key>postscriptBlueShift</key>
<integer>7</integer>
<key>postscriptBlueFuzz</key>
<integer>0</integer>
</dict>
</plist>
38 changes: 38 additions & 0 deletions tests/makeotf_data/input/bug164/d1/d2/font.ufo/glyphs/_notdef.glif
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<?xml version="1.0" encoding="UTF-8"?>
<glyph name=".notdef" format="1" >
<advance width="653"/>
<outline>
<contour>
<point x="89" y="0" type="line"/>
<point x="565" y="0" type="line"/>
<point x="565" y="660" type="line"/>
<point x="89" y="660" type="line"/>
</contour>
<contour>
<point x="197" y="58" type="line"/>
<point x="271" y="190" type="line"/>
<point x="325" y="293" type="line"/>
<point x="329" y="293" type="line"/>
<point x="381" y="190" type="line"/>
<point x="454" y="58" type="line"/>
</contour>
<contour>
<point x="325" y="387" type="line"/>
<point x="275" y="481" type="line"/>
<point x="209" y="600" type="line"/>
<point x="444" y="600" type="line"/>
<point x="378" y="481" type="line"/>
<point x="329" y="387" type="line"/>
</contour>
<contour>
<point x="154" y="110" type="line"/>
<point x="154" y="572" type="line"/>
<point x="281" y="340" type="line"/>
</contour>
<contour>
<point x="498" y="110" type="line"/>
<point x="372" y="340" type="line"/>
<point x="498" y="572" type="line"/>
</contour>
</outline>
</glyph>
46 changes: 46 additions & 0 deletions tests/makeotf_data/input/bug164/d1/d2/font.ufo/glyphs/a.glif
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
<?xml version="1.0" encoding="UTF-8"?>
<glyph name="a" format="1" >
<advance width="504"/>
<outline>
<contour>
<point x="194" y="-12" type="curve"/>
<point x="255" y="-12" />
<point x="309" y="20" />
<point x="355" y="58" type="curve"/>
<point x="358" y="58" type="line"/>
<point x="365" y="0" type="line"/>
<point x="433" y="0" type="line"/>
<point x="433" y="298" type="line"/>
<point x="433" y="419" />
<point x="383" y="498" />
<point x="264" y="498" type="curve"/>
<point x="186" y="498" />
<point x="118" y="464" />
<point x="73" y="435" type="curve"/>
<point x="105" y="378" type="line"/>
<point x="143" y="404" />
<point x="194" y="430" />
<point x="250" y="430" type="curve"/>
<point x="330" y="430" />
<point x="350" y="370" />
<point x="350" y="308" type="curve"/>
<point x="143" y="285" />
<point x="52" y="232" />
<point x="52" y="126" type="curve"/>
<point x="52" y="39" />
<point x="113" y="-12" />
</contour>
<contour>
<point x="218" y="54" type="curve"/>
<point x="170" y="54" />
<point x="132" y="77" />
<point x="132" y="132" type="curve"/>
<point x="132" y="194" />
<point x="188" y="234" />
<point x="350" y="254" type="curve"/>
<point x="350" y="119" type="line"/>
<point x="303" y="77" />
<point x="265" y="54" />
</contour>
</outline>
</glyph>
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>.notdef</key>
<string>_notdef.glif</string>
<key>a</key>
<string>a.glif</string>
<key>negative</key>
<string>negative.glif</string>
</dict>
</plist>
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<glyph name="negative" format="1" >
<advance width="-5"/>
<outline>
</outline>
</glyph>
12 changes: 12 additions & 0 deletions tests/makeotf_data/input/bug164/d1/d2/font.ufo/lib.plist
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>public.glyphOrder</key>
<array>
<string>.notdef</string>
<string>a</string>
<string>negative</string>
</array>
</dict>
</plist>
10 changes: 10 additions & 0 deletions tests/makeotf_data/input/bug164/d1/d2/font.ufo/metainfo.plist
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>creator</key>
<string>com.adobe.type.tx</string>
<key>formatVersion</key>
<integer>2</integer>
</dict>
</plist>
1 change: 1 addition & 0 deletions tests/makeotf_data/input/bug164/d1/d2/rel_to_main.fea
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
include(../../rel_to_main1.fea);
1 change: 1 addition & 0 deletions tests/makeotf_data/input/bug164/d1/d2/rel_to_parent.fea
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
include(../../rel_to_parent1.fea);
5 changes: 5 additions & 0 deletions tests/makeotf_data/input/bug164/d1/include2.fea
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
languagesystem DLFT dflt;

feature tst1 {
sub a by a;
} tst1;
1 change: 1 addition & 0 deletions tests/makeotf_data/input/bug164/rel_to_main1.fea
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
include (../include2.fea);
1 change: 1 addition & 0 deletions tests/makeotf_data/input/bug164/rel_to_parent1.fea
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
include (d1/include2.fea);
33 changes: 32 additions & 1 deletion tests/makeotf_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
from runner import main as runner
from differ import main as differ, SPLIT_MARKER
from test_utils import (get_input_path, get_expected_path, get_temp_file_path,
generate_ttx_dump)
generate_ttx_dump, font_has_table)

TOOL = 'makeotf'
CMD = ['-t', TOOL]
Expand Down Expand Up @@ -497,3 +497,34 @@ def test_update_cff_bbox_bug617():
' <checkSumAdjustment value=' + SPLIT_MARKER +
' <created value=' + SPLIT_MARKER +
' <modified value='])


@pytest.mark.parametrize('feat_filename', [
'bug164/d1/d2/rel_to_main.fea',
'bug164/d1/d2/rel_to_parent.fea',
])
def test_feature_includes_type1_bug164(feat_filename):
input_filename = "bug164/d1/d2/font.pfa"
otf_path = get_temp_file_path()

runner(CMD + ['-o',
'f', '_{}'.format(get_input_path(input_filename)),
'ff', '_{}'.format(get_input_path(feat_filename)),
'o', '_{}'.format(otf_path)])

assert font_has_table(otf_path, 'head')


def test_feature_includes_ufo_bug164():
input_filename = "bug164/d1/d2/font.ufo"
otf_path = get_temp_file_path()

stderr_path = runner(
CMD + ['-s', '-e', '-o',
'f', '_{}'.format(get_input_path(input_filename)),
'o', '_{}'.format(otf_path)])

with open(stderr_path, 'rb') as f:
output = f.read()
assert(b"[FATAL] <SourceSans-Test> include file <../../rel_to_main1.fea> "
b"not found [font.ufo/features.fea 1]") in output

0 comments on commit 98e8d12

Please sign in to comment.