78 Commits

Author SHA1 Message Date
خالد حسني (Khaled Hosny)
1c25210360
[featureVars] Re-use FeatureVariationRecord's when possible
If a FeatureVariationRecord with the same ConditionTable exists re-use
it and append FeatureTableSubstitutionRecord’s.

Without this, in the following feature code only the first lookup will
be applied since there will be two FeatureVariationRecord with the same
ConditionTable, so the first will be matched and the other will be
skipped:

    conditionset test {
        wght 600 1000;
        wdth 150 200;
    } test;

    variation ccmp test {
        sub e by a;
    } ccmp;

    variation rlig test {
        sub b by c;
    } rlig;

With this change only one FeatureVariationRecord will be created with
two FeatureTableSubstitutionRecord’s.
2024-01-10 19:06:26 +02:00
Simon Cozens
4c60c5f3ba
Clone variable mark anchor before building (#3330)
* Copy mark anchor before OTifying

* Add test for variable mark anchor
2023-11-13 16:43:55 +00:00
Khaled Hosny
a43f824af9 [feaLib] Support variable ligature caret position
Allow variable scaler in ligature caret position and build
CaretValueFormat3 with DeviceTable. Does not support non-variable device
table, but can be added if someone really really wants it.
2023-05-30 20:21:21 +03:00
Simon Cozens
65bc6105f7
[feaLib] Allow empty aalt features (#3110)
* Demote "feature has not been defined" to a warning

* Rework test

* Not my black
2023-05-17 15:08:08 +01:00
Nikolaus Waxweiler
cf43ff5d22 Apply avar to variable locations 2023-03-15 16:19:39 +00:00
Nikolaus Waxweiler
73e7aad1c3 Guard against missing avar entries 2023-03-15 16:18:47 +00:00
Nikolaus Waxweiler
c3a5e9ea1f Consult avar for normalizing user-space values in conditionsets 2023-03-15 09:16:06 +00:00
Khaled Hosny
eb93b7688e [feaLib] Fix handled of "ignore" with unmarked glyphs
Fixes https://github.com/fonttools/fonttools/issues/2949

- If there are no marked glyphs in an "ignore" statement, issue a
  warning. The spec disallows this but makeotf allows it. It is most
likely a typo, so a warning is warranted.
- Mark the first glyph not all the glyphs, this matches makeotf.
- In asFea() always mark the input glyph.
- Udpate the tests.
2023-01-10 16:26:12 +02:00
Nikolaus Waxweiler
d584daa8fd Blacken code 2022-12-13 11:26:36 +00:00
Simon Cozens
64fd837ca1
Allow multiple value record types in the same pairpos table (#2776)
* Use buildPairPosClassesSubtable's ability to promote value records (see #2772)

* Add tests for #2772
2022-09-05 14:44:50 +01:00
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
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
Cosimo Lupo
2830260a01 another test to check that empty lookups blocks are skipped 2021-04-26 10:07:36 +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
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
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
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
Simon Cozens
0b39745890 Restore test for chaining version 2020-07-11 19:56:29 +01:00
Simon Cozens
e8798059f2 Rename test 2020-07-07 13:20:57 +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
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
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
David Corbett
c97956672e [feaLib] Emit CID ranges with CIDs not glyph names 2020-04-03 19:40:22 -04: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
David Corbett
62ed43ddb9 Do not fail on duplicate multiple substitutions 2020-01-26 10:30:17 -05:00
Jens Kutilek
67da54fb5f Add a simple test 2019-12-18 11:09:23 +01:00
Nikolaus Waxweiler
01328213c7 Remove __future__ imports 2019-08-09 12:20:13 +01:00
Cosimo Lupo
6ea99e4569
feaLib/builder_test: use CapturingLogHandler instead of assertLogs 2019-06-11 13:14:47 +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
226f5518b7 [feaLib] "subtable" in single substitutions 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
Khaled Hosny
47d30499a5 [feaLib] "subtable" in contextual substitution 2019-03-01 01:48:48 +02:00
Khaled Hosny
6bb0545655 [feaLib] Don’t hard-code "subtable" support
Allow for making more lookups support subtabe breaks. Although AFDKO’s
makeotf supports subtable breaks only in pair pos lookups, I believe
that is an implementation limit that we don’t have to follow; all
OpenType lookups has subtables and it should be possible to code that in
the feature files.
2019-03-01 01:48:48 +02:00