536 Commits

Author SHA1 Message Date
Khaled Hosny
83434b4286 [feaLib] Escape glyph names matching keywords
Glyph names matching reserved keywords were not consistently escaped;
they were escaped in GDEF classes but not elsewhere. Call module’s
asFea() function in GlyohName.asFea() to ensure they are consistently
escaped.
2019-02-05 13:10:33 +02:00
Khaled Hosny
a291e9a2f1 [feaLib] Add table names to reserved keywords
Apparently AFDKO expects these to be escaped in glyph names.
2019-02-05 13:10:33 +02:00
Khaled Hosny
05329ed033 [feaLib] Fix double indentation of markClass
When a MarkClassDefinition is inside a block, it gets double indentation
compared to the rest of the block. It should ignore the indent argument
like other similar statements.
2019-02-05 00:46:58 +02:00
Khaled Hosny
354b89c068 [feaLib] Implement ValueRecord.asFea()
ValueRecord had a makeString() method that takes an optional “vertical”
argument, but no code outside the tests sets this argument. Renamed it
to asFea() and dropped the “vertical”, so that it consistent with the
rest of feaLib.ast classes.
2019-01-28 11:52:36 +02:00
Khaled Hosny
f48f4cc6b4 [feaLib] Round-trip useExtension keyword 2019-01-27 12:16:35 +02:00
Cosimo Lupo
23f0b5f5b1
[feaLib.builder] do not make <NULL> ValueRecord 2019-01-19 12:11:14 +00:00
Cosimo Lupo
091b05296d
[feaLib] distinguish missing value and explicit '<NULL>' for PairPos2 format A
Fixes #1459
2019-01-19 11:46:05 +00:00
Khaled Hosny
baf4f560bb [feaLib] Skip noop class PairPos subtables
If Coverage is None then the subtable is a noop that does nothing and
there is no point in building it. As a bonus, it makes OTS happy since
it will reject subtables where coverageOffset is NULL (0) and the spec
does not say whether this is allowed or not.
2018-09-16 12:23:34 +02:00
Cosimo Lupo
9536541aba
feaLib: demote warning about redefined kern pairs to debug message
https://github.com/fonttools/fonttools/issues/1147#issuecomment-421539956
2018-09-15 10:09:49 +02:00
Martin Hosken
59a4e934ee Get the fix we want 2018-09-07 15:37:33 +07:00
Martin Hosken
0902cea8b6 Fix default lookups for a language 2018-08-17 10:32:55 +07:00
Cosimo Lupo
83f9156f8d
Merge pull request #1302 from moyogo/fix-subtable-break
Fix subtable break
2018-07-26 11:16:58 +01:00
Denis Moyogo Jacquerye
18ad93fb41 feaLib: reset forceSubtableBreak_ to False 2018-07-26 11:06:24 +01:00
Cosimo Lupo
68951b7c3d
feaLib: when name table not selected, skip building featureNames blocks
ufo2ft feature writer calls feaLib builder with tables=[GSUB] first, to run closure
over glyph substitutions; if the GSUB features contains 'featureNames' blocks, then
an AssertionError will be raised; in this case, we can simply skip building the
FeatureParams tables as we haven't build the name records they point to.
2018-07-26 10:51:37 +01:00
Cosimo Lupo
9456ae9485
feaLib: support explicit 'subtable' statements in PairPos lookups
Fixes https://github.com/fonttools/fonttools/issues/1279
2018-07-24 17:13:52 +01:00
Cosimo Lupo
d3229d5777
feaLib: ensure languagesystems using 'DFLT' script tag precede all others
https://github.com/fonttools/fonttools/pull/1292#issuecomment-407427544

this is to match makeotf's behavior

https://github.com/adobe-type-tools/afdko/pull/498/files#diff-17824930b3cdfb707ae56e1f42bccec6R2305
2018-07-24 16:17:23 +01:00
Martin Hosken
d5a1e5257e Simplify code for language statement 2018-07-09 21:10:46 +01:00
Martin Hosken
d76f447775 More depths to allowing languages in DFLT 2018-07-09 16:41:54 +01:00
Martin Hosken
1ae0bf87a0 Allow any languages under DFLT script 2018-06-20 09:42:46 +01:00
Denis Moyogo Jacquerye
b3edba70e9 [feaLib] implement SubtableStatement.asFea() 2018-06-15 10:53:38 +01:00
Cosimo Lupo
fc6f758d20
feaLib: add __all__ to ast module
for * imports
2018-05-21 12:40:14 +01:00
Cosimo Lupo
88f495dd68
feaLib.parser: use set for predefined ssXX and cvXX tags
it turns out regex would be slower in this case

See comments:
7cefeadb3a (r28011318)
2018-03-15 13:07:53 +00:00
Cosimo Lupo
5c83b7483e
feaLib.parser: use class attributes for ss and cv tags; minor comment 2018-03-01 11:20:22 +00:00
Cosimo Lupo
3a41e70fd4
make 'location' optional for newly added cvXX elements 2018-03-01 10:39:17 +00:00
Miguel Sousa
7cefeadb3a
[feaLib] Improve feature tag sniffing
https://github.com/fonttools/fonttools/pull/1169#discussion_r170216680
2018-03-01 10:25:24 +00:00
Miguel Sousa
ce5cebfef2
[feaLib] Use tuple for dict key
https://github.com/fonttools/fonttools/pull/1169#discussion_r170218517
2018-03-01 10:25:24 +00:00
Miguel Sousa
6810f02528
[feaLib] Add TODOs for work needed on Lexer.NUMBER 2018-03-01 10:25:24 +00:00
Miguel Sousa
f6bcea960d
[feaLib] asFea methods for statements in cvParameters 2018-03-01 10:25:23 +00:00
Miguel Sousa
d0fd2759d4
[feaLib] Build cvParameters block 2018-03-01 10:25:23 +00:00
Miguel Sousa
9c38b8a9d0
[feaLib] Method to parse 'name' records in cvXX features 2018-03-01 10:23:54 +00:00
Miguel Sousa
0667875538
[feaLib] Method to parse Character statements 2018-03-01 10:23:54 +00:00
Miguel Sousa
82c54f4601
[feaLib] Method to parse cvParameters block 2018-03-01 10:23:54 +00:00
Miguel Sousa
dbe4dce070
[feaLib] Special handle Character Variants features (cvXX) 2018-03-01 10:23:54 +00:00
Miguel Sousa
7bad066995
[feaLib] Simplify builder.add_featureName() 2018-03-01 10:22:09 +00:00
Miguel Sousa
a4c055c18a
[feaLib] Generalize FeatureNamesBlock 2018-03-01 10:22:09 +00:00
Cosimo Lupo
b30704114b
[feaLib.lexer] pass included filename token to IncludedFeaNotFound ...
In the IncludedFeaNotFound error, pass on the filename token as
it was included in the include statement, so that a client can do their
thing (e.g. issue a warning to suggest the user to write the path
relative to the UFO itself, instead of relative to the feautures.fea
which is inside a UFO).

Also. resolve includes relative to current working directory when the
IncludingLexer' filename is None because it originates from an in-memory stream.
2018-02-28 18:44:17 +00:00
Cosimo Lupo
0ab40b772e
[feaLib.ast] default enumerated=False in PairPosStatement 2018-02-27 19:24:04 +00:00
Cosimo Lupo
e5c0bdd5df
[feaLib.ast] make location=None by default
This would make it easier to construct feaLib AST from code,
where the location is not defined and thus should be None.
Also, we can make other arguments as kwargs with a default
value, now that the first parameter is no longer 'location'.
2018-02-27 19:00:08 +00:00
Cosimo Lupo
7d7212b01f
feaLib: add IncludedFeaNotFound error
subclass of FeatureLibError, only raised if IOError.errno == ENOENT (i.e. FileNotFoundError)

https://github.com/googlei18n/fontmake/issues/157#issuecomment-367380471

Will be useful in ufo2ft to detect when an included feature file doesn't exist and print a nicer error message
explaining that includes must be relative to the UFO itself, and not relative to the embedded features.fea file.

https://github.com/unified-font-object/ufo-spec/issues/55
2018-02-21 16:41:11 +00:00
Cosimo Lupo
bdc82fb7f5
feaLib: LookupListIndex must be list, not tuple
all otData arrays are decompiled as lists (see otConverters.BaseConverter.readArray).
If one tries to call the subsetter on a GSUB table that was not read from file
but was just built from feaLib, it crases with a TypeError because it's expecting
list but finds tuples.

Traceback (most recent call last):
  File /home/clupo/Github/fonttools/Lib/fontTools/subset/__init__.py, line 1462, in prune_lookups
    lookup_indices = self.table.FeatureList.collect_lookups(feature_indices)
  File /home/clupo/Github/fonttools/Lib/fontTools/subset/__init__.py, line 1263, in collect_lookups
    if i < self.FeatureCount), [])
TypeError: can only concatenate list (not tuple) to list
2018-01-25 12:35:17 -08:00
Cosimo Lupo
241384ab21
[feaLib] allow to build from pre-parsed ast.FeatureFile object 2018-01-25 09:53:42 -08:00
Cosimo Lupo
b1a67bd812
Merge pull request #1159 from anthrotype/feaLib-build-some-tables
[feaLib] add `tables` argument to only build some tables (e.g. GSUB)
2018-01-25 00:42:12 +01:00
Cosimo Lupo
596ad14526
Merge pull request #1157 from moyogo/feaLib-multiple_by_multiple_error
feaLib.parser: raise meaningful error for substitution of multiple glyphs by multiple glyphs
2018-01-25 00:09:07 +01:00
Cosimo Lupo
803530b281
[feaLib] assert all requested tables are supported
better than just warn
2018-01-24 15:07:34 -08:00
Cosimo Lupo
b2da85cffd
[feaLib] add tables argument to only build some tables (e.g. GSUB)
`tables=None` by default will build all supported tables;
To build only some of these and ignore the others, one can pass a
subset of supported tables tags: .e.g. `tables={'GSUB'}` will only
build the GSUB, even if the feature file may contain e.g. GPOS
related features.
2018-01-24 15:07:34 -08:00
Denis Moyogo Jacquerye
94b51e7344 feaLib.parser: raise meaningful error for substitution of multiple glyphs by multiple glyphs 2018-01-24 11:40:07 +00:00
Jany Belluz
89979dea04 [feaLib.parser] Add option to not follow includes
Currently, the feature file parser always resolves included files,
parses their content and inserts it in the resulting AST. The original
`include` statement is lost.

This commit introduces an option to not follow inclusions. Instead, the
output AST will contain an `include` statement. This allows to process a
feature file on its own, and allows to round-trip it.

For example in glyphsLib, when going from a UFO to a .glyphs file, a
UFO feature file will be sliced up into Glyphs.app classes (e.g. a
GSFeaturePrefix with code `include(../family.fea);`) and when going back
from .glyphs to UFO, the feature file will be patched back together.
2018-01-23 11:07:16 +00:00
Jany Belluz
d6a5a489c0 [feaLib.parser] Parse a feature file with only comments 2018-01-22 17:07:28 +00:00
Cosimo Lupo
95030cb788
minor: unused variables 2018-01-15 19:50:34 +00:00
Cosimo Lupo
27d40f5160
[feaLib.builder] don't error when specific kern pairs conflict
Fixes #1147
2018-01-15 18:43:10 +00:00