271 Commits

Author SHA1 Message Date
خالد حسني (Khaled Hosny)
26590d3d6e
[feaLib] Don’t modify variable anchors in place (#3717)
When passing a parsed feature file that has variable anchors to
addOpenTypeFeatures(), builder would modify the anchors in place and
discard the variations, which break any subsequent use of the feature
file.

I encountered this building a font that has variable cursing anchors
with ufo2ft. The cursFeatureWriter would write the variable anchors, but
then when kernFeatreWriter compiles the file to get GSUB closure, the
variation would be dropped from the anchors, and later when when the
feature data is compiled into the font, the anchors would be compiled
without variations.
2024-12-05 12:09:44 +00:00
Cosimo Lupo
97929b3236
[feaLib] try reuse existing inline chained multiple subst lookups when possible
We already do this for inline single substitutions in chained contextual lookups, this PR extends this for multiple substitutions as well.

Fixes https://github.com/fonttools/fonttools/issues/3551
2024-06-03 17:06:46 +01:00
Cosimo Lupo
0902d1e482 [feaLib] don't reference same lookup multiple times within the same feature
Fixes https://github.com/fonttools/fonttools/issues/2946
2024-05-23 19:00:39 +01:00
Cosimo Lupo
6ff7d00e06
[feaLib] fix ordering of alternates in aalt lookups
Fixes https://github.com/fonttools/fonttools/issues/2937
2024-01-25 13:25:41 +00:00
Cosimo Lupo
957b5fb45a
don't sort product of liga components to keep declaration order
technically we are tweaking the original example from the spec but it keeps the spirit, so that the product of glyph classes produces the same representation in the font as if the sequences were manually enumerated (while keeping the declaration order)
2024-01-24 12:59:00 +00: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
Simon Cozens
c5295d2f16
Better OTL builder errors (#3286)
* Raise a sensible error for keyerror

* Try harder to find error locations

* Chain exception
2023-10-05 11:09:22 +01: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
Khaled Hosny
fd854d70d8 [feaLib] Simplify variable scalars that don’t vary
If a variable scalar does not vary (i.e. all values are the same), we
can simplify it and use a simple value instead. Arguably users shouldn’t
be using variable scalar in this case, but it helps when the feature
code is auto generated so each feaLib users doesn’t have to do the
check done here themselves.
2023-05-27 02:56:11 +03:00
Khaled Hosny
f8abda4570 [feaLib] Refactor-out builder code handling variable scalars
Refactor-out this piece of code to simplify the next commit.
2023-05-27 02:55:07 +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
ac0361fe31 Move VariableScalar cache into Builder 2023-03-16 11:27:06 +00:00
Nikolaus Waxweiler
cf43ff5d22 Apply avar to variable locations 2023-03-15 16:19:39 +00:00
Nikolaus Waxweiler
a993247e47 Remove unused variable 2023-03-15 16:19:12 +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
Nikolaus Waxweiler
d1b916ad04 Add missing location argument
and make code nicer.
2023-03-15 09:16:06 +00:00
Nikolaus Waxweiler
f926909fef Make code nicer 2023-03-14 18:24:07 +00:00
Khaled Hosny
253b4f9afc [feaLib] Further merge inline single substitutions
Fixes https://github.com/fonttools/fonttools/issues/2150 (see the
discussion there).
2023-01-28 09:51:49 -07:00
Cosimo Lupo
c30a6355ff
Merge pull request #2925 from fonttools/blacken-code
Blacken code
2022-12-14 18:53:35 +00:00
Colin Rofls
4716f85731 [feaLib] Sort name table entries in builder
This patch ensures that feaLib always produces a name table with entries
sorted in the order proscribed by the spec: platform id, encoding id,
language id, name id.

This breaks some tests, and so I have manually updated the test data to
match the new outputs.
2022-12-13 10:39:33 -05:00
Nikolaus Waxweiler
d584daa8fd Blacken code 2022-12-13 11:26:36 +00:00
Simon Cozens
5d5c16207b
Speed up varscalar with caching (#2798)
* Speed up varscalar with caching

* Don't use cached_property

* Make model pool a class attribute

* Don't catch things on the values side

* Remove unused import
2022-09-05 14:27:08 +01:00
Just van Rossum
2f79fbc951 remove GDEF warning completely, as per discussion in #2694 2022-08-16 14:08:46 +02:00
Just van Rossum
10c92ba338 Fix for #2694: only warn about not-requested-GDEF if building a VF AND GPOS is requested but GDEF isn't 2022-08-15 21:20:13 +02:00
Just van Rossum
e4c5c842f1 Allow features to be added to VF without building GDEF; warn when GDEF would be needed but isn't requested. This fixes #2694 2022-07-20 11:28:29 +02:00
Just van Rossum
6c6245e382 Add missing required argument. Fixes #2692 2022-07-12 13:52:17 -06:00
Behdad Esfahbod
e917c43ca9 [varLib.varStore] Add operator __bool__ and use it
Part of https://github.com/fonttools/fonttools/issues/2211#issuecomment-790125437
2022-06-21 14:03:20 -06: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
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
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
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