Skip to content

Commit

Permalink
[tx] Support self-closing <dict/> in UFO's lib.plist
Browse files Browse the repository at this point in the history
Fixes #701
  • Loading branch information
miguelsousa committed Feb 8, 2019
1 parent 8f399b6 commit c8c4d6f
Show file tree
Hide file tree
Showing 9 changed files with 91 additions and 0 deletions.
3 changes: 3 additions & 0 deletions c/public/lib/source/uforead/uforead.c
Original file line number Diff line number Diff line change
Expand Up @@ -1158,6 +1158,9 @@ static int parseGlyphOrder(ufoCtx h) {
} else if (state == IN_COMMENT) {
continue;
} else if (tokenEqualStrN(tk, "<dict", 5)) {
// <dict/> case
if ((tk->val[tk->length - 2] == '/') && (tk->val[tk->length - 1] == '>'))
continue;
state++;
} else if (tokenEqualStr(tk, "</dict>")) {
state--;
Expand Down
10 changes: 10 additions & 0 deletions tests/tx_data/expected_output/bug701.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
## Filename font.ufo
## Top Dict
version "1.000"
FullName "PSnameSerifTextBold"
FamilyName "PSname Serif Text"
sup.srcFontType UFO (name-keyed)
sup.nGlyphs 1
## FontDict[0]
FontName "PSnameSerifText-Bold"
## Private
18 changes: 18 additions & 0 deletions tests/tx_data/input/bug701.ufo/fontinfo.plist
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?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>729</integer>
<key>capHeight</key>
<real>675.0</real>
<key>familyName</key>
<string>PSname Serif Text</string>
<key>styleName</key>
<string>Bold</string>
<key>postscriptFontName</key>
<string>PSnameSerifText-Bold</string>
<key>postscriptFullName</key>
<string>PSnameSerifTextBold</string>
</dict>
</plist>
13 changes: 13 additions & 0 deletions tests/tx_data/input/bug701.ufo/glyphs/A_.glif
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?xml version='1.0' encoding='UTF-8'?>
<glyph name="A" format="2">
<advance width="706"/>
<unicode hex="0041"/>
<outline>
<contour>
<point x="184" y="315" type="line"/>
<point x="184" y="266" type="line"/>
<point x="481" y="266" type="line"/>
<point x="481" y="315" type="line"/>
</contour>
</outline>
</glyph>
8 changes: 8 additions & 0 deletions tests/tx_data/input/bug701.ufo/glyphs/contents.plist
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?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>A</key>
<string>A_.glif</string>
</dict>
</plist>
10 changes: 10 additions & 0 deletions tests/tx_data/input/bug701.ufo/layercontents.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">
<array>
<array>
<string>foreground</string>
<string>glyphs</string>
</array>
</array>
</plist>
13 changes: 13 additions & 0 deletions tests/tx_data/input/bug701.ufo/lib.plist
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?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>com.loicsander.scaleFast</key>
<dict>
<key>guides</key>
<array/>
<key>presets</key>
<dict/>
</dict>
</dict>
</plist>
10 changes: 10 additions & 0 deletions tests/tx_data/input/bug701.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>3</integer>
</dict>
</plist>
6 changes: 6 additions & 0 deletions tests/tx_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -366,3 +366,9 @@ def test_standard_apple_glyph_names():
actual_path = runner(CMD + ['-s', '-o', 'dump', '4', '-f', 'post-v2.ttf'])
expected_path = get_expected_path('post-v2.txt')
assert differ([expected_path, actual_path])


def test_ufo_self_closing_dict_element_bug701():
actual_path = runner(CMD + ['-s', '-o', 'dump', '0', '-f', 'bug701.ufo'])
expected_path = get_expected_path('bug701.txt')
assert differ([expected_path, actual_path, '-s', '## Filename'])

0 comments on commit c8c4d6f

Please sign in to comment.