Skip to content

Commit

Permalink
[makeotf] Fail if UFO has no 'postscriptFontName' value
Browse files Browse the repository at this point in the history
Makes it behave the same as when a Type 1 font with no '/FontName' is used as input

Fixes #282
  • Loading branch information
miguelsousa committed Jun 29, 2018
1 parent 25169f7 commit 603c385
Show file tree
Hide file tree
Showing 10 changed files with 378 additions and 8 deletions.
63 changes: 63 additions & 0 deletions Tests/makeotf_data/input/t1pfa-noPSname.pfa

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

164 changes: 164 additions & 0 deletions Tests/makeotf_data/input/ufo2-noPSname.ufo/fontinfo.plist
Original file line number Diff line number Diff line change
@@ -0,0 +1,164 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>ascender</key>
<integer>712</integer>
<key>capHeight</key>
<integer>656</integer>
<key>copyright</key>
<string>Copyright 2010, 2012, 2014 Adobe Systems Incorporated (http://www.adobe.com/), with Reserved Font Name 'Source'.</string>
<key>descender</key>
<integer>-205</integer>
<key>familyName</key>
<string>Source Sans Pro</string>
<key>italicAngle</key>
<integer>0</integer>
<key>openTypeHheaAscender</key>
<integer>984</integer>
<key>openTypeHheaDescender</key>
<integer>-273</integer>
<key>openTypeHheaLineGap</key>
<integer>0</integer>
<key>openTypeNameDesigner</key>
<string>Paul D. Hunt</string>
<key>openTypeNameLicense</key>
<string>This Font Software is licensed under the SIL Open Font License, Version 1.1. This license is available with a FAQ at: http://scripts.sil.org/OFL. This Font Software is distributed on an 'AS IS' BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the SIL Open Font License for the specific language, permissions and limitations governing your use of this Font Software.</string>
<key>openTypeNameLicenseURL</key>
<string>http://scripts.sil.org/OFL</string>
<key>openTypeNameManufacturer</key>
<string>Adobe Systems Incorporated</string>
<key>openTypeNameManufacturerURL</key>
<string>http://www.adobe.com/type</string>
<key>openTypeOS2CodePageRanges</key>
<array>
<integer>0</integer>
<integer>1</integer>
<integer>2</integer>
<integer>3</integer>
<integer>4</integer>
<integer>7</integer>
<integer>8</integer>
<integer>29</integer>
</array>
<key>openTypeOS2Panose</key>
<array>
<integer>2</integer>
<integer>11</integer>
<integer>5</integer>
<integer>3</integer>
<integer>3</integer>
<integer>4</integer>
<integer>3</integer>
<integer>2</integer>
<integer>2</integer>
<integer>4</integer>
</array>
<key>openTypeOS2Type</key>
<array>
</array>
<key>openTypeOS2TypoAscender</key>
<integer>750</integer>
<key>openTypeOS2TypoDescender</key>
<integer>-250</integer>
<key>openTypeOS2TypoLineGap</key>
<integer>0</integer>
<key>openTypeOS2UnicodeRanges</key>
<array>
<integer>0</integer>
<integer>1</integer>
<integer>2</integer>
<integer>4</integer>
<integer>5</integer>
<integer>6</integer>
<integer>7</integer>
<integer>9</integer>
<integer>29</integer>
<integer>30</integer>
<integer>32</integer>
<integer>57</integer>
</array>
<key>openTypeOS2VendorID</key>
<string>ADBO</string>
<key>openTypeOS2WinAscent</key>
<integer>984</integer>
<key>openTypeOS2WinDescent</key>
<integer>273</integer>
<key>postscriptBlueFuzz</key>
<integer>0</integer>
<key>postscriptBlueScale</key>
<real>0.0625</real>
<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>postscriptFamilyBlues</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>postscriptFamilyOtherBlues</key>
<array>
<integer>-217</integer>
<integer>-205</integer>
</array>
<key>postscriptForceBold</key>
<false/>
<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>postscriptUnderlinePosition</key>
<integer>-75</integer>
<key>postscriptUnderlineThickness</key>
<integer>50</integer>
<key>styleName</key>
<string>Regular</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>versionMajor</key>
<integer>2</integer>
<key>versionMinor</key>
<integer>20</integer>
<key>xHeight</key>
<integer>486</integer>
</dict>
</plist>
38 changes: 38 additions & 0 deletions Tests/makeotf_data/input/ufo2-noPSname.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>
56 changes: 56 additions & 0 deletions Tests/makeotf_data/input/ufo2-noPSname.ufo/glyphs/a.glif
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
<?xml version="1.0" encoding="UTF-8"?>
<glyph name="a" format="1">
<unicode hex="0061"/>
<advance width="504"/>
<outline>
<contour>
<point x="194" y="-12" type="curve" smooth="yes"/>
<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" smooth="yes"/>
<point x="433" y="419"/>
<point x="383" y="498"/>
<point x="264" y="498" type="curve" smooth="yes"/>
<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" smooth="yes"/>
<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" smooth="yes"/>
<point x="52" y="39"/>
<point x="113" y="-12"/>
</contour>
<contour>
<point x="218" y="54" type="curve" smooth="yes"/>
<point x="170" y="54"/>
<point x="132" y="77"/>
<point x="132" y="132" type="curve" smooth="yes"/>
<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>
<contour>
<point name="ogonekLC" x="414" y="0" type="move"/>
</contour>
<contour>
<point name="aboveLC" x="269" y="509" type="move"/>
</contour>
<contour>
<point name="belowLC" x="252" y="-22" type="move"/>
</contour>
</outline>
</glyph>
10 changes: 10 additions & 0 deletions Tests/makeotf_data/input/ufo2-noPSname.ufo/glyphs/contents.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//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>
</dict>
</plist>
11 changes: 11 additions & 0 deletions Tests/makeotf_data/input/ufo2-noPSname.ufo/lib.plist
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//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>
</array>
</dict>
</plist>
10 changes: 10 additions & 0 deletions Tests/makeotf_data/input/ufo2-noPSname.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//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>creator</key>
<string>org.robofab.ufoLib</string>
<key>formatVersion</key>
<integer>2</integer>
</dict>
</plist>
11 changes: 10 additions & 1 deletion Tests/makeotf_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@ def test_exit_unknown_option(arg):
assert err.value.returncode == 1


# makeotf [Error] Could not find GlyphOrderAndAliasDB file at '...'
def test_type1_pfa_release_mode():
# makeotf [Error] Could not find GlyphOrderAndAliasDB file at '...'
with pytest.raises(subprocess.CalledProcessError) as err:
runner(CMD + ['-n', '-o',
'f', '_{}'.format(_get_input_path(T1PFA_NAME)), 'r'])
Expand Down Expand Up @@ -97,3 +97,12 @@ def test_ufo_with_trailing_slash_bug280():
runner(CMD + ['-n', '-a', '-o', 'f', '_{}{}'.format(tmp_ufo_path, os.sep)])
expected_path = os.path.join(temp_dir, 'SourceSansPro-Regular.otf')
assert os.path.isfile(expected_path)


@pytest.mark.parametrize('input_filename', ['t1pfa-noPSname.pfa',
'ufo2-noPSname.ufo'])
def test_no_postscript_name_bug282(input_filename):
# makeotf will fail for both UFO and Type 1 inputs
with pytest.raises(subprocess.CalledProcessError) as err:
runner(CMD + ['-n', '-o', 'f', '_{}'.format(input_filename)])
assert err.value.returncode == 1
Loading

0 comments on commit 603c385

Please sign in to comment.