485 Commits

Author SHA1 Message Date
Khaled Hosny
232b2ccbc4 Move the rest of py23 module to textTools
Change all imports to use textTools module, except the test_py23.py test
which is kept until we decide to remove the module (if ever).
2021-08-20 01:29:45 +02:00
justvanrossum
3e0a6542c0 Use r-string instead of escaping backslash 2021-05-20 13:44:38 +02:00
justvanrossum
f99f1bbc36 fixed two instances of 'DeprecationWarning: invalid escape sequence' 2021-05-19 14:20:57 +02:00
Khaled Hosny
f6d2ff8d2a [feaLib] Allow substituting a glyph class with NULL
sub [a b c] by NULL; was producing errors, now it builds as multiple
statements.
2021-05-12 08:53:26 +02:00
Just van Rossum
9825ab0977
Fix for #2293: allow more than one lookahead glyph/class in contextual positioning with "value at end" (#2294)
* add test that fails for #2293

* fixing #2293: rewrite of contextual positioning logic, ensure len(suffix) > 1 yields the correct result; checking more edge cases and raising errors inspired by makeotf

* test error cases

* only check when we actually have a value

* catch one more case that makeotf errors on and we didn't
2021-05-08 09:22:30 +02:00
Cosimo Lupo
9b5bc9e18b feaLib: ignore empty named lookup reference
Fixes #2276
2021-04-22 13:11:57 +01:00
Just van Rossum
5fc65d7168
Misc py23 cleanups (#2243)
* Replaced all from ...py23 import * with explicit name imports, or removed completely when possible.
* Replaced tounicode() with tostr()
* Changed all BytesIO ans StringIO imports to from io import ..., replaced all UnicodeIO with StringIO.
* Replaced all unichr() with chr()
* Misc minor tweaks and fixes
2021-03-29 11:45:58 +02:00
Behdad Esfahbod
d0aaf1bceb [feaLib] Set RangeStart/RangeEnd as float
Fixes the one failing test after previous commit.
2021-03-24 08:04:14 -07:00
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
Denis Moyogo Jacquerye
2563b1df7e [feaLib] black ast.py 2021-02-18 19:19:18 +00:00
Denis Moyogo Jacquerye
e47101d683 [feaLib] indent anchor statements 2021-02-18 17:14:57 +00:00
Simon Cozens
56df97b5f2 Prohibit non-functional "sub A B by NULL" 2021-02-03 14:16:57 +00:00
Simon Cozens
d1e85cb888 Allow 'sub X by NULL;' sequence to delete a glyph 2021-02-03 14:12:46 +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
8869e0dec7 Add debug flag to feaLib command line utility 2020-09-09 20:18:03 +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
Khaled Hosny
7db9ba6ef6 [feaLib] Allow anonymous glyphclass in LookupFlags
Almost everywhere else when a glyph class name is accepted, anonymous
glyph classes are also accepted. This is rather inconsistent and
inconvenient.
2020-08-07 19:57:31 +02:00
Simon Cozens
85edf0e380 Use the ChainContextualRule class instead of bare tuples 2020-07-22 14:20:50 +01:00
Simon Cozens
ae5e000e29 Run black on all these too. 2020-07-15 17:16:12 +01:00
Simon Cozens
8590bcf06d Reformat with black 2020-07-15 17:12:46 +01:00
Simon Cozens
e58fea95ce Reformat with black 2020-07-15 14:14:01 +01:00
Simon Cozens
8370849678 Fix documentation for MultipleSubstStatement (fixes #2012) 2020-07-07 08:41:06 +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
Nikolaus Waxweiler
0e7a4460f3
[feaLib] Introduce includeDir on Parser and IncludingLexer (#1973)
This makes the directory to search for included files explicit.

Also use Python 3's FileNotFoundError to catch non-existant files instead of a workaround for Python 2.
2020-05-28 17:43:19 +01:00
David Corbett
42a17500a3 [feaLib.ast] Restore compatibility with 4.9.0 2020-05-18 13:22:20 -04: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
2cef07af80
[doc] Add help options to fonttools CLI (#1920)
This adds a `help` verb (and `--help` option) to the `fonttools` command line tool. Submodules will be listed in the help text if they have an importable `main` function with a docstring, and `main`'s docstring will be used as the one-line description for the help text.
2020-05-12 06:31:13 +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
Cosimo Lupo
d91724d76c
Revert "[doc] Add help options to fonttools CLI" 2020-05-04 17:37:24 +01:00
Simon Cozens
02f23a214c [doc] Add help options to fonttools CLI 2020-05-03 22:59:54 +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
1d2d5b345b
Merge pull request #1897 from khaledhosny/issue-1896
[feaLib] Check lookup index in chaining lookups
2020-04-27 18:38:51 +02:00
Khaled Hosny
e0c49a1d4a [feaLib] Improve exception message 2020-04-27 18:13:18 +02:00
Khaled Hosny
3d6c759ea3 [feaLib] Hide traceback by default on command line
Makes the command line tool a little nicer to use. Adds --traceback
option to show them when needed.
2020-04-27 02:53:32 +02:00