318 Commits

Author SHA1 Message Date
Martin Hosken
2972d81d82 More pop8erry and try to minimise redundancy in the patch 2017-03-08 16:49:08 +00:00
Martin Hosken
c870cde47e Refactor to remove option in Lexer. Lexer always returns comments now 2017-03-08 16:29:55 +00:00
Martin Hosken
45a4a1f249 Add tests, rename _OMITs 2017-03-08 15:19:09 +00:00
Martin Hosken
90b57d2dec Fix bad colon 2017-03-08 14:15:34 +00:00
Martin Hosken
d5d4ea4ddc Tidy up space colon to colon in python statements 2017-03-08 14:05:00 +00:00
Martin Hosken
450d2b939e Add support for comments to parser 2017-03-08 13:50:06 +00:00
Cosimo Lupo
2c9eea33ee [feaLib.builder] rename 'id' -> 'id_' to avoid shadowing id() built-in function 2017-02-26 10:48:54 +08:00
Cosimo Lupo
1958334158 [feaLib.builder] sort markFilterSets_ items by id to make output deterministic
The items() of self.markFilterSets_ dictionary are not guaranteed to be always
ordered the same (may vary across python implementations or on subsequent runs).
To ensure deterministic order of Coverage subtables in MarkGlyphSetsDef tables,
we sort the mark sets by the order in which 'UseMarkFilteringSet' statements appear
in the feature file.
2017-02-26 10:48:54 +08:00
Cosimo Lupo
a9e0165b93 [feaLib.builder] ignore duplicates in classes used as MarkFilteringSet and MarkAttachmentType
Glyph classes from feaLib parser are tuples of strings, with an order and possibly containing duplicates.
However when building MarkGlyphSetsDef or MarkAttachClassDef we are only interested in the *set* of glyphs they contain, i.e. the unordered collection of unique glyph names.

Also, note how in the tests for otlLib.builder.buildMarkGlyphSetsDef, the input is given as set literals, not tuples:
https://github.com/fonttools/fonttools/blob/78ad48e/Tests/otlLib/builder_test.py#L633
2017-02-26 10:48:54 +08:00
Sascha Brawer
a2e7d96cf4 [feaLib] Merge SinglePos chain targets
Fixes https://github.com/fonttools/fonttools/issues/514.
2017-02-17 12:49:12 +01:00
Sascha Brawer
7c67e4a63d [feaLib] Compile zero values to different formats based on context
If a zero value appears in a SinglePos statement, feaLib continues to
produce ValueRecords of format 0. But if a zero value appears in a
PairPos statement inside a horizontal compilation context, feaLib now
produces ValueRecords of format 4. Likewise, if a zero value appears
in a PairPos statement inside a vertical compilation context, feaLib
now produces ValueRecords of format 8.

The OpenType Feature Syntax specification is completely silent about this,
but the new behavior matches that of makeotf.

https://github.com/fonttools/fonttools/issues/633
2017-02-16 15:37:40 +01:00
Sascha Brawer
40474f1aab Distinguish value records format A from format B with zero values
Fixes https://github.com/fonttools/fonttools/issues/848.
2017-02-16 13:53:55 +01:00
Sascha Brawer
eac7ef89c0 [feaLib] Make nameid parsing more robust
We now correctly handle nameid statements with surrogate pairs and
old-style macOS-encoded names (provided that fonttools supports the
specified encoding).

Resolves https://github.com/fonttools/fonttools/issues/842.
2017-02-14 14:28:10 +01:00
Sascha Brawer
b22df7ff48 [feaLib]Escape nameid strings when writing feature files
https://github.com/fonttools/fonttools/issues/780
2017-02-14 11:02:12 +01:00
Miguel Sousa
75133fc4d1 [feaLib] Make include() work like makeotf 2017-02-13 08:42:03 +01:00
Sascha Brawer
706858646a Preserve ordering of glyph alternates when round-tripping through TTX
Also fixes a bug where glyph alternates in MTI feature files were
wrongly sorted by glyph name. After this change, the output is using
the same ordering as in the input MTI feature file.

Fixes https://github.com/fonttools/fonttools/issues/833.
2017-02-11 17:08:56 +01:00
Sascha Brawer
b31ed09421 Support glyph names with dashes
The OpenType Feature File Syntax has been changed to support dashes:
https://github.com/adobe-type-tools/afdko/issues/152

Resolves https://github.com/fonttools/fonttools/issues/559.
Needed for https://github.com/googlei18n/fontmake/issues/249.
2017-02-11 15:57:17 +01:00
Cosimo Lupo
78ad48eaf3
Move all *_test.py modules and test data to external Tests/ folder 2017-01-16 09:14:12 +00:00
Cosimo Lupo
48c12bda63
[feaLib] add __main__.py so one can call fonttools feaLib
This is the same as Snippets/apply-feature-file.py

Fixes #569
2017-01-13 11:26:26 +00:00
Cosimo Lupo
cb94d6c4cd [feaLib] fix check for redefined glyph between multiple markClass definitions (#803)
* [feaLib.ast] fix checking multiple markClass definitions don't redefine same glyphs

As pointed out by @mhosken, we are looking in the wrong list for glyphs
that have already been defined in a previous markClass definition.

With this patch, the current markClass.fea test case fails becuase it defines 'acute'
twice for the same @TOP_MARKS class:

fontTools.feaLib.error.FeatureLibError: Lib/fontTools/feaLib/testdata/markClass.fea:6:5: Glyph acute already defined at Lib/fontTools/feaLib/testdata/markClass.fea:3:1

Also see conversation at:
3b79d51755 (r94622074)

* feaLib/testdat/markClass.fea: remove duplicate 'acute' in @TOP_MARKS

Now the test pass, after 45c77b7

* [feaLib.builder_test] test case for redefined glyph in multiple markClass definitions
2017-01-12 15:39:21 +01:00
Cosimo Lupo
ea8608c168
[minor] whitespace 2017-01-12 13:36:06 +00:00
Cosimo Lupo
3dd31c8689
[feaLib.builder_test] minor refactoring in check_fea2fea_file 2017-01-12 13:21:20 +00:00
Cosimo Lupo
3bd0788a37
[feaLib] use generator expressions with "".join(), instead of list comprehensions
This should be a bit more efficient as we don't need to create a temporary list
object before passing it to "".join() method of str; the latter accepts any
Iterable
2017-01-12 11:49:54 +00:00
Martin Hosken
7387f0eebf
Put back buggy code that we don't want to deal with yet 2017-01-12 11:34:44 +00:00
Martin Hosken
7d01f365ea
Tidy up spacing, make generic fea2fea checker 2017-01-12 11:34:44 +00:00
Martin Hosken
15f4cfa2d3
whitespace reallignment for self.ast in fealib parser 2017-01-12 11:34:43 +00:00
Martin Hosken
a23da5384b
Add ast subclassing, extension commands and an example test 2017-01-12 11:34:43 +00:00
Cosimo Lupo
49bcbb916b
consistently do sys.exit(unittest.main()) in all test modules
So that when run as scrips they report test failures with exit code

Follow up on b7bb391033ef3255c90134da3d7aef50d2d5326d
2017-01-11 13:05:35 +00:00
Cosimo Lupo
26679a9d73
feaLib.builder: fix order of {from,to}file arguments of difflib.unified_diff 2017-01-04 22:01:40 +01:00
Cosimo Lupo
6bacc3e6f8
[feaLib.builder] use hex istead of float for GDEF.Version to avoid fixedToFloat warning 2017-01-02 13:08:36 +01:00
Behdad Esfahbod
3eacc23868 Update tests for previous commit
The following sed command can be used to update TTX sources for the LookupType
change:

$ sed -i'~' 's/<!-- LookupType=\(.\) -->/<LookupType value="\1"\/>/g' *.ttx
2016-12-28 20:29:43 -05:00
Behdad Esfahbod
2034cef52f Write test diffs to stderr, not stdout 2016-12-26 20:30:00 -05:00
Cosimo Lupo
be6afae761
builder_test: add test for omitted class definitions 2016-12-20 13:27:03 +00:00
Cosimo Lupo
f147398554
ast: write commas for empty glyph classes in GlyphClassDef statement 2016-12-20 13:26:48 +00:00
Cosimo Lupo
60e9fed16d
[minor] whitespace 2016-12-20 12:51:33 +00:00
Cosimo Lupo
934cbd72be
builder_test: open with UTF-8 encoding to fix failing Appveyor tests
https://ci.appveyor.com/project/fonttools/fonttools/build/1.0.259/job/yi83cj0hhid3asb8
2016-12-20 12:47:31 +00:00
Martin Hosken
3c2cc8e6aa
fea2fea passes all tests 2016-12-20 11:58:37 +00:00
Martin Hosken
e41bf35f06
Fix nameid type tests 2016-12-20 11:55:52 +00:00
Cosimo Lupo
b97e420895
minor style/whitespace fixes to appease flake8 linter 2016-12-20 11:03:10 +00:00
Sascha Brawer
0d14cfbc83 [feaLib] Fix minor typo in unittest comment 2016-12-20 11:14:39 +01:00
mhosken
7a0c5e1ca2 Add fea generation support (#776)
* First round of adding fea output

No format tests but all test files give reasonable output so far.

* Get existing tests working

* Initial tests that work for fea2fea

* Get more tests working

Bug fixes and re-layout some tests to compare with fea2fea output.
Ranges and name parameters are not optimised yet.

* Handle vertical default values in fea2fea

* Hide fea2fea differences in lookupflags

* No reduce() in py3 so use a for loop
2016-12-20 11:10:29 +01:00
Khaled Hosny
fbf896c969 [feaLib][test] No need to create temporary file (#764)
Loading features from file objects have been supported for a while
already.
2016-12-10 23:29:14 +01:00
Cosimo Lupo
3b1e0bdc47
[feaLib.builder_test] fix up tests for backslash-escaped glyph names 2016-11-02 16:01:35 +00:00
Cosimo Lupo
a0cc66bfc0
[feaLib.parser] strip initial backslash from glyph names
Fixes https://github.com/fonttools/fonttools/issues/457

Backslash-prefixed glyph name can be used in a Feature file to distinguish them from identically-named keywords.

From section "2.f.i. Glyph name" of Adobe's Feature File Specification:

> An initial backslash serves to differentiate a glyph name from an identical keyword in the feature file language. For example, a glyph named "table" must be specified in the feature file as: \table

Thus, when we parse a glyph name that begins with a backslash, we need to ignore the first character.

Note that makeotf rejects feature files with glyph names that start with or contain backslashes, even when escaped with another backslash.

feature liga {
    sub \\glyphWithBackslash by A;
} liga;

This yields:

    makeotfexe [FATAL] <Backslash-Regular> invalid token (text was "\") [features 2]
2016-11-02 16:01:21 +00:00
Sascha Brawer
248336a0fb Add test case for glyph names with backslash
Resolves https://github.com/fonttools/fonttools/issues/457
2016-10-24 22:39:59 +02:00
moyogo
004a5b7361 feaLib: hhea tableVersion = 0x00010000 2016-10-18 18:18:09 +02:00
moyogo
5b785950f8 feaLib: add test for vhea 2016-10-18 18:18:09 +02:00
moyogo
f55c60c4df feaLib: add vhea table 2016-10-18 18:18:09 +02:00
moyogo
bd4d43e7c5 feaLib: hhea test with hex version 2016-10-18 18:18:09 +02:00
moyogo
4dd1e73b04 Revert "Merge pull request #606 from anthrotype/cff-dehint"
This reverts commit 25a03f5a5736ed70791a8dde31605ed4cee9bbd9, reversing
changes made to 8351600bc628278960390d747f45593a50b7c1ea.
2016-10-14 20:20:35 +01:00