152 Commits

Author SHA1 Message Date
Simon Cozens
af9dfc94e7
Forbid empty classes (take 2) (#2446) 2021-11-18 11:31:49 +00:00
Simon Cozens
563730f8ce
Support variable feature syntax (#2432) 2021-10-28 11:58:54 +01:00
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
Khaled Hosny
000bf81700 Default to "\n" for newlinestr instead of None
If newlinestr is None, os.linesep is used, bu it is the third millennium
and we don’t need or want different line endings per-platform.
2021-07-30 04:12:33 +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
2830260a01 another test to check that empty lookups blocks are skipped 2021-04-26 10:07:36 +01:00
Cosimo Lupo
9b5bc9e18b feaLib: ignore empty named lookup reference
Fixes #2276
2021-04-22 13:11:57 +01:00
Cosimo Lupo
bd618d0117 add test to repro AttributeError when getAlternateGlyphs for empty lookups
https://github.com/fonttools/fonttools/issues/2276
2021-04-22 12:21:30 +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
Nikolaus Waxweiler
cc76169074 Test that G* table compilation does not change data 2021-03-24 07:58:42 -07:00
Nikolaus Waxweiler
30ade474dd Update test data 2021-03-22 14:45:24 +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
537fabcee9 [feaLib] update tests for indented anchors 2021-02-18 19:19:18 +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
3e964ad8da
Merge pull request #2101 from simoncozens/alternate-contextual-representations
[otlLib] Build format 1 and format 2 contextual lookups
2020-11-18 07:34:04 -08:00
Simon Cozens
a99bd4296a Tests for GSUB5/GSUB6 formats 1, 2 and 3 2020-11-17 15:17:02 +00:00
Simon Cozens
db37b3bd9a Update test expectations 2020-11-16 13:42:22 +00:00
Simon Cozens
7135255d4a Style nits 2020-09-11 09:35:45 +01:00
Simon Cozens
70b514270e Add debug tests 2020-09-10 08:29:04 +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
0b39745890 Restore test for chaining version 2020-07-11 19:56:29 +01:00
Simon Cozens
7db13c9872 Fixup test expectations 2020-07-07 13:24:41 +01:00
Simon Cozens
e8798059f2 Rename test 2020-07-07 13:20:57 +01:00
Simon Cozens
2cf9f681a2 Fix test expectation. Test is now badly named. 2020-07-07 13:19:50 +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
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
f6cbc45a6a
add test files triggering the AttributeError: 'NoneType' object has no attribute 'getAlternateGlyphs'
https://github.com/googlefonts/fontmake/issues/648
2020-04-17 17:12:00 +01:00
Cosimo Lupo
1cbb28acd8
Merge pull request #1870 from anthrotype/fealib-parser-no-glyphnames
feaLib: without glyphNames, warn but don't parse hyphens as ranges
2020-04-16 16:16:29 +01:00
Tom
c70395fbdb
[feaLib] Raise exception when GSUB statement doesn't match a rule. (#1876)
* [feaLib] Raise exception when substitute statement doesnt match any of the rules. Add tests that trigger said exception.
2020-04-16 16:10:03 +01:00
David Corbett
c97956672e [feaLib] Emit CID ranges with CIDs not glyph names 2020-04-03 19:40:22 -04:00
David Corbett
ec4273bbfd [feaLib] Emit spaces around hyphens in ranges 2020-04-03 17:36:34 -04:00
Cosimo Lupo
c1af75b803
feaLib.parser: check that glyph name is actually ambiguous
https://github.com/fonttools/fonttools/pull/1870#discussion_r403259450
2020-04-03 21:17:02 +01:00
Cosimo Lupo
a913431ecd
feaLib.parser: if no glyphNames, treat dash as names, not ranges
But print a warning about the possible ambiguity.

Fixes https://github.com/fonttools/fonttools/issues/1768
2020-04-03 12:42:22 +01:00
Cosimo Lupo
be77f3eeab
feaLib/parser_test: rename {Unicode,String}IO, remove misc.py23 2020-04-03 11:46:36 +01:00
Simon Cozens
8fac69b0ea Also output mark attachment class 2020-03-11 13:59:05 +00:00
Simon Cozens
d6d21e067d Someone wrote more tests while I wasn't looking 2020-03-10 21:48:45 +00:00
Simon Cozens
ab075a9957 Annotate LookupFlag ttx dump 2020-03-10 21:42:28 +00:00
Nikolaus Waxweiler
36c64087a8 Add a proper message to IncludedFeaNotFound
Also, minor f-string refactor.
2020-02-27 18:13:45 +00:00
Nikolaus Waxweiler
5cda8381f9
[feaLib] Check that glyph names referenced in the feature file are part of the glyph set (#1828)
This checks that glyph names that appear in a feature file are actually
in the glyph set provided in glyphNames. If the set is empty, no check
is done. This preempts a KeyError later during saving of a TTFont object
and makes this case much more easily catchable.

Closes #1723.
2020-02-13 14:47:29 +00:00
Nikolaus Waxweiler
ef2742593c Compare realpath against realpath
On Windows, tests may be run in the user's temp directory, so the previous code
may compare C:\Users\nikolaus.waxweiler\ against C:\Users\NIKOLA~1.WAX\.
2020-02-04 11:08:45 +00:00