537 Commits

Author SHA1 Message Date
Colin Rofls
6bc5d7f887 [feaLib] Allow duplicate script/language statements
And accumulate all of the declared lookups into the appropriate feature.
2025-01-22 12:58:44 -05:00
Simon Cozens
cb159dea72
Black (#3736) 2025-01-07 08:23:24 +00:00
梁海 Liang Hai
b497b5de60
Correct docstring of AlternateSubstStatement (#3735) 2025-01-07 07:31:08 +00:00
Colin Rofls
4b9f5ef605 [feaLib] More efficient inline format 4 lookups
With this patch we will now reuse lookups more frequently when a
contextual lookup has inline ligature substitution rules.
2024-12-10 09:51:05 -07:00
خالد حسني (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
4193aeaa26
Merge pull request #3495 from NightFurySL2001/patch-2
Allow UTF-8 with BOM for features.fea
2024-05-30 12:27:21 +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
Just van Rossum
24cb4e0dcf
[feaLib.variableScalar] fix value_at_location() method (#3491) 2024-05-13 08:48:59 +01:00
NFSL2001
80db8cd6f7
Allow UTF-8 with BOM for features.fea 2024-05-01 22:41:03 +08:00
NFSL2001
cc02ada3c4
Allow UTF-8 with BOM for features.fea 2024-05-01 22:29:43 +08: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
Khaled Hosny
2616ab959c feaLib: Drop glyph and class names length limit
These were implemented to follow FEA spec, but makeotf does not seem to
have a name length limit any more (or it has a very large one, I tested
a 600-character name and it was accepted).

Fixes https://github.com/googlefonts/ufo2ft/issues/588
See also https://github.com/googlefonts/ufo2ft/pull/811#discussion_r1461667058
2024-01-22 16:38:54 +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
Cosimo Lupo
335a1e56ec re-run black v23.10 on all .py files 2023-11-03 10:25:15 +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
David Corbett
8b69b9412e feaLib: Dedupe multiple substitutions with classes 2023-05-13 13:24:58 -04:00
Khaled Hosny
88885ba9fc feaLib: handle singleton class as a single glyph in multiple subst
This how GlyphsApp handles it and how it is handled in single
substitution.
2023-05-09 17:33:36 +03:00
Khaled Hosny
f642a2aac4 feaLib: support multiple substitution with classes
This is a GlyphsApp extension, (partially) documented [here][1], but it is a
useful one as it allows concise glyph insertion using decomposition
without having to maintain the list of glyphs in two places. E.g.

```fea
@upper = [A-Z];

lookup insert {
  sub @upper by @upper connector;
} insert;

feature ccmp {
  sub @upper' lookup insert x;
} ccmp;
```

As apposed to:

```fea
@upper = [A-Z];

lookup insert {
  sub A by A connector;
  sub B by B connector;
  sub C by C connector;
  sub D by D connector;
  sub E by E connector;
  sub F by F connector;
  sub G by G connector;
  sub H by H connector;
  sub I by I connector;
  sub J by J connector;
  sub K by K connector;
  sub L by L connector;
  sub M by M connector;
  sub N by N connector;
  sub O by O connector;
  sub P by P connector;
  sub R by R connector;
  sub S by S connector;
  sub T by T connector;
  sub U by U connector;
  sub V by V connector;
  sub W by W connector;
  sub X by X connector;
  sub Y by Y connector;
  sub Z by Z connector;
} insert;

feature ccmp {
  sub @upper' lookup insert x;
} ccmp;
```

1. http://handbook.glyphsapp.com/en/layout/multiple-substitution-with-classes/
2023-05-09 14:06:12 +03:00
Cosimo Lupo
69b1752d80
variableScalar: make model_cache parameter optional 2023-03-16 12:03:33 +00: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
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
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
d48d858c2c
Speed up cache key construction in variableScalar (#2801) 2022-09-05 15:41:01 +01: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
Simon Cozens
17feda4608
Cythonize lexer (#2799) 2022-09-05 12:58:00 +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
David Corbett
8ec37c4bb3 [feaLib] Let the parser set nameIDs 1 through 6 2022-07-02 15:23:03 -04:00
Behdad Esfahbod
97958a95e1
Merge pull request #2662 from fonttools/varstore-empty
[varLib.varStore] Support NO_VARIATION_INDEX
2022-06-23 12:02:00 -06:00
Simon Cozens
d224e1f73d
[feaLib] show all missing glyphs at once (#2665) 2022-06-23 15:04:59 +01: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
Thomas Rettig
892322aaff
Fix grammar (#2487) 2022-01-04 11:44:04 +01:00
Simon Cozens
ed07df39da
Die noisily (#2472) 2021-12-14 19:26:50 +00:00