526 Commits

Author SHA1 Message Date
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
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
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