238 Commits

Author SHA1 Message Date
Cosimo Lupo
9aeb48286d
black 2021-02-25 17:16:02 +00:00
Kamile Demir
29ff42d15f
Reusing otlLib buildStatTable() in feaLib 2021-02-25 17:16:02 +00:00
Zachary Scheuren
0434b1a917
Add feaLib support for STAT table 2021-02-25 17:16:01 +00:00
Simon Cozens
f827a2a7f1 Turn on feaLib debugging from the environment
export FONTTOOLS_LOOKUP_DEBUGGING=1 to make a Debg table
2020-11-19 11:48:54 +00:00
Simon Cozens
0c9cb3a878 Warn developer if subclass needs upgrading 2020-10-18 11:21:49 +01:00
Simon Cozens
8ed7792682 Only stash lookup location if buildLookups_ has cooperated
Fixes #2065
2020-09-23 10:10:38 +01:00
Simon Cozens
2ef66ea4ca Debugging should not be the default (oops) 2020-09-11 09:44:28 +01:00
Simon Cozens
7135255d4a Style nits 2020-09-11 09:35:45 +01:00
Simon Cozens
95a941ec15 Re-case debug info module 2020-09-11 09:31:07 +01:00
Simon Cozens
af4f1f6d6e Prefer module constant to hard-coded string for Debg table key 2020-09-10 16:00:06 +01:00
Simon Cozens
87c65acd3a JSON ends up stringifying number keys, so do that now in case we’re round-tripping without writing the file out. 2020-09-10 08:29:41 +01:00
Simon Cozens
b680eaf782 Add debug arg to addOpenTypeFeatures 2020-09-09 20:15:50 +01:00
Simon Cozens
41c1dcce1c Tidy up as per review 2020-09-09 19:56:44 +01:00
Simon Cozens
4cddc38263 Use a named tuple, tidy ttx dump code 2020-09-09 19:56:05 +01:00
Simon Cozens
b548c5f2e1 Namespace debug output. 2020-08-25 20:22:54 +01:00
Simon Cozens
e2433bd22a Make Debg table optional 2020-08-25 20:22:16 +01:00
Simon Cozens
2e112a464a Dump feature locations into Debg 2020-08-25 20:19:26 +01:00
Simon Cozens
85edf0e380 Use the ChainContextualRule class instead of bare tuples 2020-07-22 14:20:50 +01:00
Simon Cozens
e58fea95ce Reformat with black 2020-07-15 14:14:01 +01:00
Simon Cozens
6364d36633
[otlLib] Refactor chained contextual builders (#2007)
* Introduce a new subclass for chained contextual (sub and pos)

* Rename .substitutions to .rules in subst builders to allow for code reuse

* Make format of subtable break marker tuple common between sub/pos

Note that prior to this patch, add_subtable_break in a Subst builder adds:

(self.SUBTABLE_BREAK_, self.SUBTABLE_BREAK_, self.SUBTABLE_BREAK_, self.SUBTABLE_BREAK_)

while add_subtable_break in a Pos builder adds:

(self.SUBTABLE_BREAK_, self.SUBTABLE_BREAK_, self.SUBTABLE_BREAK_, [self.SUBTABLE_BREAK_])

This is messy. If we read the first element from the tuple instead of the last one to test if a rule is a subtable break, we can make the marker tuple the same.

* And now the subtable break code can be hoisted into superclass

* These helper methods will make the build routine common

* Hoist common build method to superclass

The diff doesn’t show it very clearly because it’s being too clever, but all I’ve done is moved one method. Everything works apart from the error message, which comes next.

* Fix the error message
2020-07-02 18:40:20 +01:00
Simon Cozens
ebfa4ba1fe
Move feature builders to otlLib
Refactors feaLib, moving code which builds OpenType lookups into otlLib. Note that this changes feaLib's concept of `location` from a tuple to an object.
2020-07-02 14:09:10 +01:00
Nikolaus Waxweiler
fe17d5937a
[feaLib] Builder.build(): proper error msg on unsupported tables (#1976)
Raise NotImplementedError instead of an assertion error.
2020-05-29 16:44:19 +01:00
Simon Cozens
ca8703f653
[docs] Document feaLib (#1941)
[docs] Document feaLib

* Rearrange docs by user intention, highlighting the things you can do with each component.
* Remove reference to lexer and error modules from documentation tree, since they’re not user-facing.
* I’ve added docstrings to the parser even though we only provide access to the user-facing part of the API in the main documentation, just to clarify what some of the more obscure methods do and provide links to the spec.
* AST *is* user-facing if you’re building your own feature files in code, so all classes are documented with the user in mind.
2020-05-12 23:11:17 +01:00
Simon Cozens
b299bfb389
[feaLib] Support multiple lookups per glyph position (#1905)
This allows for more than one "lookup ..." chaining statements at each glyph position in a chaining contextual substitution or positioning rule: e.g.

    sub a b c' lookup lookup1 lookup lookup2 d;

The corresponding change in the Adobe OpenType Feature File Specification (and implementation in makeotf) happened in adobe-type-tools/afdko#1132.
2020-05-12 06:28:25 +01:00
Khaled Hosny
d24fd71934 [feaLib] Fix building chained alt substitutions
Support was added in db49f20d6b2629e1ba25c4afd3fb60817387f3d6, but there
was only a parser test and no builder test, fix the build and add a
builder test based on the existing parser one.

Fixes https://github.com/fonttools/fonttools/issues/1901
2020-04-28 14:29:50 +02:00
Khaled Hosny
e0c49a1d4a [feaLib] Improve exception message 2020-04-27 18:13:18 +02:00
Khaled Hosny
4526e164f1 [feaLib] Check lookup index in chaining lookups
Raise if lookup_index is None, which would happen only of the lookup
referenced belongs to the wrong table. The error message needs to be less
cryptic, though.

Fixes https://github.com/fonttools/fonttools/issues/1896
2020-04-27 02:39:33 +02:00
Khaled Hosny
259e586f5d [feaLib] Ignore superfluous script statements
Setting script that is the same as current language system should make
no effect. This is not documented in the spec, but it is what makeotf
does. This as the effect of preserving lookupflag when set before such a
script statement.

Fixes https://github.com/fonttools/fonttools/issues/1824
2020-04-20 23:45:45 +02:00
Khaled Hosny
6a24c8fed1 [feaLib] Raise for script/language in standalone lookup
They are not allowed per spec and makeotf, but currently we would fail
later with some cryptic error message.
2020-04-20 23:09:53 +02:00
Cosimo Lupo
5777c2e057
feaLib.builder: skip getAlternateGlyphs if lookup is None in ChainContextSubstBuilder
Fixes https://github.com/googlefonts/fontmake/issues/648
2020-04-17 17:22:45 +01:00
Khaled Hosny
014991d710
Merge pull request #1815 from khaledhosny/fealib-flag-fix
[feaLib] Don’t reset lookupflag in nested lookups
2020-01-30 13:06:42 +02:00
Khaled Hosny
eed252cb92 [feaLib] Don’t reset lookupflag in nested lookups
In makeotf, lookups defined inside feature blocks inherit the current
lookupflag of the feature, so don’t reset the lookupflag for such
lookups.
2020-01-29 23:46:40 +02:00
David Corbett
62ed43ddb9 Do not fail on duplicate multiple substitutions 2020-01-26 10:30:17 -05:00
Jens Kutilek
864945df0b Change log call 2019-12-18 14:12:02 +01:00
Jens Kutilek
b858f7bb3e Change log message, remove comments 2019-12-18 10:03:08 +01:00
Jens Kutilek
9c6b7d2e7a Log warning instead of raising an error when identical substitutions are added again 2019-12-02 17:05:59 +01:00
Khaled Hosny
b99ae0d469 [feaLib] Fix handing of duplicate LigatureCaret
The spec has been updated for a while to allow only one rule per glyph,
and makeotf uses the first and ignores the rest.

See https://github.com/adobe-type-tools/afdko/issues/95, and
https://github.com/adobe-type-tools/afdko/issues/155
2019-09-26 16:44:46 +02:00
Nikolaus Waxweiler
01328213c7 Remove __future__ imports 2019-08-09 12:20:13 +01:00
Miguel Sousa
45596108e2 (Re)calculate OS/2.usMaxContext value
The value is only modified in the context of fontBuilder or subset. It will NOT be modified when using ttx.

maxContextCalc.py was copied from https://github.com/googlefonts/ufo2ft/blob/master/Lib/ufo2ft/maxContextCalc.py

Fixes #1191
Fixes #466
2019-04-24 18:31:12 -07:00
Cosimo Lupo
abae80d730 [feaLib] make 'forceChain' an optional kwarg for barkward compat
See discussion at:
https://github.com/fonttools/fonttools/pull/1511#issuecomment-472425283
2019-03-13 15:11:53 +00:00
justvanrossum
723e7a1d3c updated inline github issue URLs 2019-03-06 16:01:28 +01:00
Khaled Hosny
c82fb8fa13 [feaLib] Support Python < 3.5 in previous commits 2019-03-01 01:48:48 +02:00
Khaled Hosny
7d03e93e67 [feaLib] Make unsupported "subtable" a warning
AFDKO’s makeotf warns and ignores the statement, so do the same. I’m
abusing FeatureLibError() as a lazy way to keep reporting the location.
2019-03-01 01:48:48 +02:00
Khaled Hosny
10cad7be3a [feaLib] Refactor almost duplicated subtable code
Also make the code a little less ugly.
2019-03-01 01:48:48 +02:00
Khaled Hosny
226f5518b7 [feaLib] "subtable" in single substitutions 2019-03-01 01:48:48 +02:00
Khaled Hosny
3be73365a5 [feaLib] Reverse chain need not handle subtable 2019-03-01 01:48:48 +02:00
Khaled Hosny
d9893ab05a [feaLib] "subtable" in multiple substitutions 2019-03-01 01:48:48 +02:00
Khaled Hosny
c87e5cf4ad [feaLib] "subtable" in alternate lookups 2019-03-01 01:48:48 +02:00
Khaled Hosny
7454a3eb48 [feaLib] "subtable" in ligature lookups 2019-03-01 01:48:48 +02:00
Khaled Hosny
cc1b6baff7 [feaLib] "subtable" in contextual positioning 2019-03-01 01:48:48 +02:00