Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do not expect a contents.plist file to exist in glyphs.com.adobe.type.processedglyphs #1702

Open
wants to merge 7 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
24 changes: 16 additions & 8 deletions python/afdko/ufotools.py
Original file line number Diff line number Diff line change
Expand Up @@ -606,11 +606,11 @@ def getOrSkipGlyph(self, glyphName, doAll=0):

def loadGlyphMap(self):
# Need to both get the list of glyphs from contents.plist, and also
# the glyph order. The latter is take from the public.glyphOrder key
# the glyph order. The latter is taken from the public.glyphOrder key
# in lib.plist, if it exists, else it is taken from the contents.plist
# file. Any glyphs in contents.plist which are not named in the
# public.glyphOrder are sorted after all glyphs which are named in the
# public.glyphOrder,, in the order that they occured in contents.plist.
# public.glyphOrder, in the order that they occured in contents.plist.
contentsPath = os.path.join(self.parentPath, "glyphs", kContentsName)
self.glyphMap, self.glyphList = parsePList(contentsPath)
orderPath = os.path.join(self.parentPath, kLibName)
Expand Down Expand Up @@ -902,8 +902,14 @@ def cleanUpGLIFFiles(defaultContentsFilePath, glyphDirPath, doWarning=True):
contentsFilePath = os.path.join(glyphDirPath, kContentsName)
# maps glyph names to files.

with open(contentsFilePath, 'r', encoding='utf-8') as fp:
contentsDict = plistlib.load(fp)
if os.path.exists(contentsFilePath):
# contents.plist exists in glyphDirPath
with open(contentsFilePath, 'r', encoding='utf-8') as fp:
contentsDict = plistlib.load(fp)
else:
# contents.plist does not exist in glyphDirPath, load the default
with open(defaultContentsFilePath, 'r', encoding='utf-8') as fp:
contentsDict = plistlib.load(fp)

# First, delete glyph files that are not in the contents.plist file in
# the glyphDirPath. In some UFOfont files, we end up with case errors,
Expand Down Expand Up @@ -935,10 +941,10 @@ def cleanUpGLIFFiles(defaultContentsFilePath, glyphDirPath, doWarning=True):
os.remove(glyphFilePath)
if doWarning:
print("Removing glif file %s that was not in the contents.plist "
"file: %s" % (glyphDirPath, contentsFilePath))
"file: %s" % (fileName, contentsFilePath))
changed = 1

if defaultContentsFilePath == contentsFilePath:
if str(defaultContentsFilePath) == str(contentsFilePath):
return changed

# Now remove glyphs that are not referenced in the defaultContentsFilePath.
Expand Down Expand Up @@ -976,8 +982,10 @@ def cleanupContentsList(glyphDirPath, doWarning=True):
contentsFilePath = os.path.join(glyphDirPath, kContentsName)
# maps glyph names to files.

with open(contentsFilePath, 'r', encoding='utf-8') as fp:
contentsDict = plistlib.load(fp)
contentsDict = {}
if os.path.exists(contentsFilePath):
with open(contentsFilePath, 'r', encoding='utf-8') as fp:
contentsDict = plistlib.load(fp)

fileDict = {}
fileList = os.listdir(glyphDirPath)
Expand Down

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions tests/ufotools_data/input/ufotools_basic.ufo/features.fea
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
include(../../../../../features.fea);
161 changes: 161 additions & 0 deletions tests/ufotools_data/input/ufotools_basic.ufo/fontinfo.plist
Original file line number Diff line number Diff line change
@@ -0,0 +1,161 @@
<?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>730</integer>
<key>capHeight</key>
<integer>670</integer>
<key>copyright</key>
<string>Copyright 2014 - 2023 Adobe (http://www.adobe.com/), with Reserved Font Name 'Source'.</string>
<key>descender</key>
<integer>-240</integer>
<key>familyName</key>
<string>Source Serif 4</string>
<key>guidelines</key>
<array>
</array>
<key>italicAngle</key>
<integer>0</integer>
<key>openTypeHheaAscender</key>
<integer>1003</integer>
<key>openTypeHheaDescender</key>
<integer>-336</integer>
<key>openTypeHheaLineGap</key>
<integer>0</integer>
<key>openTypeNameDesigner</key>
<string>Frank Grießhammer</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</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>4</integer>
<integer>6</integer>
<integer>3</integer>
<integer>5</integer>
<integer>4</integer>
<integer>5</integer>
<integer>2</integer>
<integer>2</integer>
<integer>4</integer>
</array>
<key>openTypeOS2TypoAscender</key>
<integer>730</integer>
<key>openTypeOS2TypoDescender</key>
<integer>-270</integer>
<key>openTypeOS2TypoLineGap</key>
<integer>0</integer>
<key>openTypeOS2UnicodeRanges</key>
<array>
<integer>0</integer>
<integer>1</integer>
<integer>2</integer>
<integer>7</integer>
<integer>9</integer>
<integer>29</integer>
<integer>32</integer>
<integer>33</integer>
<integer>57</integer>
</array>
<key>openTypeOS2VendorID</key>
<string>ADBO</string>
<key>openTypeOS2WinAscent</key>
<integer>1036</integer>
<key>openTypeOS2WinDescent</key>
<integer>335</integer>
<key>postscriptBlueFuzz</key>
<integer>0</integer>
<key>postscriptBlueScale</key>
<real>0.0375</real>
<key>postscriptBlueShift</key>
<integer>7</integer>
<key>postscriptBlueValues</key>
<array>
<integer>-15</integer>
<integer>0</integer>
<integer>475</integer>
<integer>488</integer>
<integer>527</integer>
<integer>540</integer>
<integer>549</integer>
<integer>563</integer>
<integer>647</integer>
<integer>660</integer>
<integer>670</integer>
<integer>685</integer>
<integer>730</integer>
<integer>750</integer>
</array>
<key>postscriptFamilyBlues</key>
<array>
<integer>-15</integer>
<integer>0</integer>
<integer>475</integer>
<integer>488</integer>
<integer>527</integer>
<integer>540</integer>
<integer>549</integer>
<integer>563</integer>
<integer>647</integer>
<integer>660</integer>
<integer>670</integer>
<integer>685</integer>
<integer>730</integer>
<integer>750</integer>
</array>
<key>postscriptFamilyOtherBlues</key>
<array>
<integer>-250</integer>
<integer>-240</integer>
</array>
<key>postscriptFontName</key>
<string>SourceSerif4-Regular</string>
<key>postscriptForceBold</key>
<false/>
<key>postscriptOtherBlues</key>
<array>
<integer>-250</integer>
<integer>-240</integer>
</array>
<key>postscriptStemSnapH</key>
<array>
<integer>46</integer>
<integer>36</integer>
</array>
<key>postscriptStemSnapV</key>
<array>
<integer>85</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 in the United States and/or other countries.</string>
<key>unitsPerEm</key>
<integer>1000</integer>
<key>xHeight</key>
<integer>475</integer>
</dict>
</plist>
30 changes: 30 additions & 0 deletions tests/ufotools_data/input/ufotools_basic.ufo/glyphs/_notdef.glif
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?xml version="1.0" encoding="UTF-8"?>
<glyph name=".notdef" format="2">
<advance width="640"/>
<outline>
<contour>
<point x="80" y="0" type="line"/>
<point x="142" y="0" type="line"/>
<point x="560" y="670" type="line"/>
<point x="498" y="670" type="line"/>
</contour>
<contour>
<point x="560" y="0" type="line"/>
<point x="142" y="670" type="line"/>
<point x="80" y="670" type="line"/>
<point x="498" y="0" type="line"/>
</contour>
<contour>
<point x="141" y="51" type="line"/>
<point x="141" y="619" type="line"/>
<point x="499" y="619" type="line"/>
<point x="499" y="51" type="line"/>
</contour>
<contour>
<point x="80" y="0" type="line"/>
<point x="560" y="0" type="line"/>
<point x="560" y="670" type="line"/>
<point x="80" y="670" type="line"/>
</contour>
</outline>
</glyph>
77 changes: 77 additions & 0 deletions tests/ufotools_data/input/ufotools_basic.ufo/glyphs/a.glif
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
<?xml version="1.0" encoding="UTF-8"?>
<glyph name="a" format="2">
<unicode hex="0061"/>
<advance width="509"/>
<outline>
<contour>
<point x="179" y="-13" type="curve" smooth="yes"/>
<point x="241" y="-13"/>
<point x="274" y="15"/>
<point x="334" y="75" type="curve"/>
<point x="364" y="75" type="line"/>
<point x="350" y="125" type="line"/>
<point x="269" y="65"/>
<point x="248" y="53"/>
<point x="214" y="53" type="curve" smooth="yes"/>
<point x="168" y="53"/>
<point x="134" y="74"/>
<point x="134" y="126" type="curve" smooth="yes"/>
<point x="134" y="157"/>
<point x="142" y="197"/>
<point x="233" y="226" type="curve" smooth="yes"/>
<point x="277" y="240"/>
<point x="321" y="255"/>
<point x="366" y="269" type="curve"/>
<point x="366" y="305" type="line"/>
<point x="314" y="290"/>
<point x="263" y="275"/>
<point x="211" y="260" type="curve" smooth="yes"/>
<point x="72" y="220"/>
<point x="45" y="169"/>
<point x="45" y="112" type="curve" smooth="yes"/>
<point x="45" y="29"/>
<point x="106" y="-13"/>
</contour>
<contour>
<point x="416" y="-10" type="curve" smooth="yes"/>
<point x="451" y="-10"/>
<point x="479" y="3"/>
<point x="503" y="42" type="curve"/>
<point x="483" y="64" type="line"/>
<point x="472" y="51"/>
<point x="461" y="42"/>
<point x="444" y="42" type="curve" smooth="yes"/>
<point x="422" y="42"/>
<point x="408" y="58"/>
<point x="408" y="101" type="curve" smooth="yes"/>
<point x="408" y="314" type="line" smooth="yes"/>
<point x="408" y="440"/>
<point x="358" y="488"/>
<point x="253" y="488" type="curve" smooth="yes"/>
<point x="151" y="488"/>
<point x="77" y="440"/>
<point x="58" y="364" type="curve"/>
<point x="61" y="338"/>
<point x="77" y="323"/>
<point x="105" y="323" type="curve" smooth="yes"/>
<point x="132" y="323"/>
<point x="148" y="340"/>
<point x="157" y="371" type="curve" smooth="yes"/>
<point x="182" y="456" type="line"/>
<point x="140" y="424" type="line"/>
<point x="178" y="439"/>
<point x="207" y="442"/>
<point x="230" y="442" type="curve" smooth="yes"/>
<point x="296" y="442"/>
<point x="324" y="418"/>
<point x="324" y="321" type="curve" smooth="yes"/>
<point x="324" y="96" type="line"/>
<point x="324" y="91" type="line"/>
<point x="324" y="30"/>
<point x="360" y="-10"/>
</contour>
</outline>
<anchor name="aboveLC" x="251" y="495"/>
<anchor name="belowLC" x="250" y="-20"/>
<anchor name="ogonek" x="447" y="0"/>
</glyph>
58 changes: 58 additions & 0 deletions tests/ufotools_data/input/ufotools_basic.ufo/glyphs/b.glif
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
<?xml version="1.0" encoding="UTF-8"?>
<glyph name="b" format="2">
<unicode hex="0062"/>
<advance width="577"/>
<outline>
<contour>
<point x="30" y="0" type="line"/>
<point x="180" y="-10" type="line"/>
<point x="191" y="79" type="line"/>
<point x="191" y="81" type="line"/>
<point x="191" y="386" type="line"/>
<point x="188" y="399" type="line"/>
<point x="188" y="589" type="line"/>
<point x="192" y="732" type="line"/>
<point x="178" y="740" type="line"/>
<point x="25" y="695" type="line"/>
<point x="25" y="659" type="line"/>
<point x="107" y="649" type="line"/>
<point x="107" y="210" type="line" smooth="yes"/>
<point x="107" y="165"/>
<point x="106" y="99"/>
<point x="105" y="49" type="curve"/>
<point x="30" y="36" type="line"/>
</contour>
<contour>
<point x="326" y="-13" type="curve" smooth="yes"/>
<point x="443" y="-13"/>
<point x="532" y="88"/>
<point x="532" y="242" type="curve" smooth="yes"/>
<point x="532" y="397"/>
<point x="448" y="488"/>
<point x="342" y="488" type="curve" smooth="yes"/>
<point x="278" y="488"/>
<point x="220" y="456"/>
<point x="165" y="383" type="curve"/>
<point x="149" y="383" type="line"/>
<point x="158" y="342" type="line"/>
<point x="229" y="413"/>
<point x="278" y="431"/>
<point x="315" y="431" type="curve" smooth="yes"/>
<point x="390" y="431"/>
<point x="442" y="362"/>
<point x="442" y="234" type="curve" smooth="yes"/>
<point x="442" y="105"/>
<point x="381" y="44"/>
<point x="310" y="44" type="curve" smooth="yes"/>
<point x="263" y="44"/>
<point x="210" y="70"/>
<point x="159" y="135" type="curve"/>
<point x="150" y="93" type="line"/>
<point x="164" y="93" type="line"/>
<point x="214" y="10"/>
<point x="270" y="-13"/>
</contour>
</outline>
<anchor name="aboveLC" x="150" y="740"/>
<anchor name="belowLC" x="300" y="-20"/>
</glyph>