187 Commits

Author SHA1 Message Date
Jany Belluz
d6a5a489c0 [feaLib.parser] Parse a feature file with only comments 2018-01-22 17:07:28 +00:00
Cosimo Lupo
a4e1d4a2bf
[builder_test] test_pairPos_redefinition_warning 2018-01-15 18:45:42 +00:00
Khaled Hosny
5e23b0545b [feaLib] Test mixed single/multiple substitutions 2017-12-22 16:30:34 +02:00
Cosimo Lupo
4dfea00356 [feaLib] report error with multiple runs of marked ' glyphs
As Martin Hosken reported in https://github.com/fonttools/fonttools/pull/1096,
feaLib currently incorrectly handles the case where a marked input
glyph sequence in a contextual chaining sub/pos rule is split into
multiple runs, rather than being a single continuous run of ' marked
glyphs.

The consensus there was to raise a syntax error like makeotf instead of
second-guessing and silently fixing it like fontforge does.
2017-11-21 11:42:28 +01:00
Cosimo Lupo
fdab63f0b6 [feaLib.ast] add __str__ to all AST elements
which calls the asFea() method,
so one can e.g. print(doc.statements[0])
2017-11-16 15:40:52 +00:00
Cosimo Lupo
99aa8b0c66 [feaLib.parser] keep supporting (deprecated) glyphMap argument
so we don't break backward compatibility if user code has Parser(path, glyphMap=...)
2017-11-16 14:25:43 +00:00
Cosimo Lupo
e8535f2280 [feaLib.parser] make Parser accept glyphNames iterable...
... instead of a glyphMap dict.

The parser does not actually need a reverse glyph order mapping as
it is not interested in knowing the glyphID from the glyph name,
but only whether a glyph is in the font or not.

This makes it easier for client code (e.g. ufo2ft feature compiler)
to use the feaLib Parser, without having to first construct and pass
it a glyphMap argument.
2017-11-16 13:46:27 +00:00
Khaled Hosny
534326bd1d [feaLib] Fix writing back nested glyph classes
Before this change, the following glyph class:

  @Vowels = [@Vowels.lc @Vowels.uc y Y];

Would be written back as:

  @Vowels = [@Vowels.lc = [a e i o u]; @Vowels.uc = [A E I O U]; y Y];

Which is clearly invalid. It seems for GlyphClass.asFea() to work
correctly here we should be using GlyphClassName not GlyphClass
for the nested classes (similar to the code at the beginning of
parse_glyphclass_()).
2017-10-27 23:27:07 +03:00
Cosimo Lupo
bdeb9f8925
[Tests/feaLib/data] minor: update comments referring to issue #976 2017-05-30 11:01:39 +01:00
Cosimo Lupo
12b90f073e [feaLib] don't de-duplicate lookups
keep original lookup order and preserve the feature file's semantics

Fixes https://github.com/fonttools/fonttools/issues/448
2017-05-30 11:45:03 +02:00
Adrien Tétar
3e3ff0051e builder: throw when a mark is defined in multiple mark classes
(within the same lookup)

See #453.
2017-05-01 13:14:38 +02:00
Sascha Brawer
189c722626 [feaLib] Clean up syntax tree for FeatureNames
The syntax tree representation now reflects the syntax of feature files.
Before this change, FeatureNames did not have their own `ast.Block`,
which had made the code quite messy.
2017-03-10 02:48:32 +08:00
Sascha Brawer
4210c9d2d6 [feaLib] Clean up lexer test for handling comments
https://github.com/fonttools/fonttools/issues/829
2017-03-09 15:20:21 +01:00
Sascha Brawer
bc0670f53f [feaLib] Simplify parser API by removing the ignore_comments option
https://github.com/fonttools/fonttools/pull/879#discussion_r104947968
https://github.com/fonttools/fonttools/issues/829
2017-03-09 22:17:58 +08:00
Sascha Brawer
ac2762f0f3 [feaLib] Add more tests for parsing comments
https://github.com/fonttools/fonttools/issues/829
2017-03-09 14:13:46 +01:00
Sascha Brawer
04b1e8ada6 [feaLib] Recognize empty statements in all table blocks
Before this change, some table statements would allow empty statements
(just a semicolon) while others would not allow them. After this change,
we're more consistent.
2017-03-09 13:58:17 +01:00
Martin Hosken
5906b5358a Final changes to follow vagueries 2017-03-08 16:54:11 +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
450d2b939e Add support for comments to parser 2017-03-08 13:50:06 +00:00
Cosimo Lupo
01ed5a43e7 data/lookupflag.{fea,ttx}: add tests for duplicate glyphs in MarkAttachClass and MarkGlyphSets 2017-02-26 10:48:54 +08:00
Sascha Brawer
dc7bf89648 [feaLib] Test compiling zero values for SinglePos in vertical context
https://github.com/fonttools/fonttools/issues/633
2017-02-17 14:19:54 +01:00
Sascha Brawer
45c266441e [feaLib] Add tests for zero values in contextual positioning
Specifically, contextual positioning statements with in-line single
positioning rules, in horizontal and in vertical contexts. For these
test cases, feaLib and makeotf produce the exact same output.

https://github.com/fonttools/fonttools/issues/633
2017-02-17 13:49:32 +01: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
fa69c64466 [feaLib] Add test case for class-based pair kerning with zero values
https://github.com/fonttools/fonttools/issues/633
2017-02-16 17:38:47 +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
790c93d5cf [feaLib] Test compilation of zero values in SinglePos statements
In context of SinglePos, makeotf compiles zero values to value records
of format 0. feaLib already does the same, but it's good to have tests
to make sure that this doesn't accidentally change.

https://github.com/fonttools/fonttools/issues/633
2017-02-16 13:59:53 +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
e97b864cfc [feaLib] Use assertEqual instead of deprecated assertEquals
On Python 3, any use of `assertEquals` logs a deprecation warning.
2017-02-14 20:20:22 +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
Sascha Brawer
7cf22d01ae [feaLib] Move test file include0.fea into test data subdirectory
Move the other include files into a new subdirectory inside `data`.
Mention the changed behavior of include statements in NEWS.
See https://github.com/fonttools/fonttools/pull/838.
2017-02-13 09:19:41 +01:00
Miguel Sousa
75133fc4d1 [feaLib] Make include() work like makeotf 2017-02-13 08:42:03 +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
3cdc800873
[Tests] rename all 'testdata' folders to simply 'data'
as it's now obvious what kind of data they are
2017-01-17 13:33:46 +00:00
Cosimo Lupo
e1d340cc65
[Tests] use absolute imports and add __init__.py where relevant
We can't use relative imports any more since the tests are now located outside the package.

I had to add __init__.py to Tests/feaLib/ so that pytest does not get confused by the presence
of two test files with the same basename: i.e. Tests/feaLib/builder_test.py and Tests/feaLib/builder_test.py

https://github.com/pytest-dev/pytest/issues/774
http://stackoverflow.com/questions/12582503/py-test-test-discovery-failure-when-tests-in-different-directories-are-called
2017-01-16 09:14:13 +00:00
Cosimo Lupo
78ad48eaf3
Move all *_test.py modules and test data to external Tests/ folder 2017-01-16 09:14:12 +00:00