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

fixes for modules used by tx #425

Merged
merged 13 commits into from
Jun 19, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 26 additions & 21 deletions Tests/differ.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

from fontTools.misc.py23 import open

__version__ = '0.2.3'
__version__ = '0.2.4'

logger = logging.getLogger('differ')

Expand Down Expand Up @@ -82,26 +82,31 @@ def _read_txt_file(self, path):
# Hard code a first line; this way the difflib results start
# from 1 instead of zero, thus matching the file's line numbers
lines = ['']
with open(path, "r", encoding=self.encoding) as f:
for i, line in enumerate(f.readlines(), 1):
# Skip lines that change, such as timestamps
if self._line_to_skip(line):
logger.debug("Matched begin of line. Skipped: {}"
"".format(line.rstrip()))
# Blank the line instead of actually skipping (via
# 'continue'); this way the difflib results show the
# correct line numbers
line = ''
# Skip specific lines, referenced by number
elif i in self.skip_lines:
logger.debug("Matched line #{}. Skipped: {}"
"".format(i, line.rstrip()))
# Blank the line instead of actually skipping (via
# 'continue'); this way the difflib results show the
# correct line numbers
line = ''
# Use os-native line separator to enable running difflib
lines.append(line.rstrip() + os.linesep)
try:
with open(path, "r", encoding=self.encoding) as f:
for i, line in enumerate(f.readlines(), 1):
# Skip lines that change, such as timestamps
if self._line_to_skip(line):
logger.debug("Matched begin of line. Skipped: {}"
"".format(line.rstrip()))
# Blank the line instead of actually skipping (via
# 'continue'); this way the difflib results show the
# correct line numbers
line = ''
# Skip specific lines, referenced by number
elif i in self.skip_lines:
logger.debug("Matched line #{}. Skipped: {}"
"".format(i, line.rstrip()))
# Blank the line instead of actually skipping (via
# 'continue'); this way the difflib results show the
# correct line numbers
line = ''
# Use os-native line separator to enable running difflib
lines.append(line.rstrip() + os.linesep)
except UnicodeDecodeError:
logger.error("Couldn't read text file using '{}' encoding.\n"
" File path: {}".format(self.encoding, path))
sys.exit(1)
return lines

def _line_to_skip(self, line):
Expand Down
69 changes: 69 additions & 0 deletions Tests/tx_data/expected_output/trademark.pfa

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

166 changes: 166 additions & 0 deletions Tests/tx_data/input/trademark.ufo/fontinfo.plist
Original file line number Diff line number Diff line change
@@ -0,0 +1,166 @@
<?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>postscriptFontName</key>
<string>SourceSansPro-Regular</string>
<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>This trademark string contains a © U+00A9 character that will be converted to 'Copyright'</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/tx_data/input/trademark.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/tx_data/input/trademark.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>
Loading