Merge pull request #2236 from fonttools/feaLib-no-compile-fixups

[feaLib] Test that G* table compilation does not change data
This commit is contained in:
Behdad Esfahbod 2021-03-24 08:28:16 -07:00 committed by GitHub
commit 0e5fe2d1d7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 12 additions and 36 deletions

View File

@ -971,8 +971,8 @@ class Parser(object):
location = self.cur_token_location_
DesignSize = self.expect_decipoint_()
SubfamilyID = self.expect_number_()
RangeStart = 0
RangeEnd = 0
RangeStart = 0.
RangeEnd = 0.
if self.next_token_type_ in (Lexer.NUMBER, Lexer.FLOAT) or SubfamilyID != 0:
RangeStart = self.expect_decipoint_()
RangeEnd = self.expect_decipoint_()

View File

@ -12,7 +12,6 @@ include Lib/fontTools/ttLib/tables/table_API_readme.txt
include *requirements.txt
include tox.ini
include mypy.ini
include run-tests.sh
recursive-include Lib/fontTools py.typed

View File

@ -14,7 +14,7 @@ uninstall:
pip uninstall --yes fonttools
check: all
./run-tests.sh
pytest
clean:
./setup.py clean --all

View File

@ -142,10 +142,15 @@ class BuilderTest(unittest.TestCase):
feapath = self.getpath("%s.fea" % name)
addOpenTypeFeatures(font, feapath)
self.expect_ttx(font, self.getpath("%s.ttx" % name))
# Make sure we can produce binary OpenType tables, not just XML.
# Check that:
# 1) tables do compile (only G* tables as long as we have a mock font)
# 2) dumping after save-reload yields the same TTX dump as before
for tag in ('GDEF', 'GSUB', 'GPOS'):
if tag in font:
font[tag].compile(font)
data = font[tag].compile(font)
font[tag].decompile(data, font)
self.expect_ttx(font, self.getpath("%s.ttx" % name))
# Optionally check a debug dump.
debugttx = self.getpath("%s-debug.ttx" % name)
if os.path.exists(debugttx):
addOpenTypeFeatures(font, feapath, debug=True)

View File

@ -26,8 +26,8 @@
<DesignSize value="10.0"/>
<SubfamilyID value="0"/>
<SubfamilyNameID value="0"/>
<RangeStart value="0"/>
<RangeEnd value="0"/>
<RangeStart value="0.0"/>
<RangeEnd value="0.0"/>
</FeatureParamsSize>
<!-- LookupCount=0 -->
</Feature>

View File

@ -1,28 +0,0 @@
#!/bin/sh
# exit if any subcommand return non-zero status
set -e
# Choose python version
if test "x$1" = x-3; then
PYTHON=py3
shift
elif test "x$1" = x-2; then
PYTHON=py2
shift
fi
test "x$PYTHON" = x && PYTHON=py
# Find tests
FILTERS=
for arg in "$@"; do
test "x$FILTERS" != x && FILTERS="$FILTERS or "
FILTERS="$FILTERS$arg"
done
# Run tests
if [ -z "$FILTERS" ]; then
tox --develop -e $PYTHON
else
tox --develop -e $PYTHON -- -k "$FILTERS"
fi