537 Commits

Author SHA1 Message Date
Khaled Hosny
e0c49a1d4a [feaLib] Improve exception message 2020-04-27 18:13:18 +02:00
Khaled Hosny
3d6c759ea3 [feaLib] Hide traceback by default on command line
Makes the command line tool a little nicer to use. Adds --traceback
option to show them when needed.
2020-04-27 02:53:32 +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
5777c2e057
feaLib.builder: skip getAlternateGlyphs if lookup is None in ChainContextSubstBuilder
Fixes https://github.com/googlefonts/fontmake/issues/648
2020-04-17 17:22:45 +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
40dcd1ebaa
minor: remove unnecessary f'' string 2020-04-03 21:19:01 +01: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
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
Khaled Hosny
014991d710
Merge pull request #1815 from khaledhosny/fealib-flag-fix
[feaLib] Don’t reset lookupflag in nested lookups
2020-01-30 13:06:42 +02:00
Khaled Hosny
42b51f084f
Merge pull request #1814 from khaledhosny/fealib-mult-fix
[feaLib] fix mixed single/multiple substitutions
2020-01-30 13:02:39 +02:00
Cosimo Lupo
39b02fd224
fix a coiple of SyntaxWarning on python 3.8 2020-01-30 10:47:57 +00:00
Khaled Hosny
eed252cb92 [feaLib] Don’t reset lookupflag in nested lookups
In makeotf, lookups defined inside feature blocks inherit the current
lookupflag of the feature, so don’t reset the lookupflag for such
lookups.
2020-01-29 23:46:40 +02:00
Khaled Hosny
22bfc305ee [feaLib] fix mixed single/multiple substitutions
If the single substitution involved a glyph class, we were incorrectly
using only the first glyph in the class.

Broken since ec6ff821f0e72022d7aec8794b6bb589d8f81808, apparently no one
else uses this feature!
2020-01-29 22:36:54 +02:00
David Corbett
62ed43ddb9 Do not fail on duplicate multiple substitutions 2020-01-26 10:30:17 -05:00
Jens Kutilek
864945df0b Change log call 2019-12-18 14:12:02 +01:00
Jens Kutilek
b858f7bb3e Change log message, remove comments 2019-12-18 10:03:08 +01:00
Jens Kutilek
9c6b7d2e7a Log warning instead of raising an error when identical substitutions are added again 2019-12-02 17:05:59 +01:00
Khaled Hosny
b99ae0d469 [feaLib] Fix handing of duplicate LigatureCaret
The spec has been updated for a while to allow only one rule per glyph,
and makeotf uses the first and ignores the rest.

See https://github.com/adobe-type-tools/afdko/issues/95, and
https://github.com/adobe-type-tools/afdko/issues/155
2019-09-26 16:44:46 +02:00
Khaled Hosny
197b36fef4 [feaLib] Don’t accept hex/octal numbers everywhere
Only in name, nameid, sizemenuname and Character.
2019-08-17 13:43:18 +02:00
Khaled Hosny
ae239722d4 [feaLib] Correctly handle octal numbers
From https://www.adobe.com/devnet/opentype/afdko/topic_feature_file_syntax.html#9.e:
> Decimal numbers must begin with a non-0 digit, octal numbers with a 0
> digit, and hexadecimal numbers with a 0x prefix to numbers and
> hexadecimal letters a-f or A-F.

Fixes https://github.com/fonttools/fonttools/issues/1541
2019-08-17 13:43:18 +02:00
Nikolaus Waxweiler
01328213c7 Remove __future__ imports 2019-08-09 12:20:13 +01:00
Khaled Hosny
41c7760be3 [feaLib] don’t write None in ast.ValueRecord.asFea()
The code tries to write the short format when some values as None, but
when writing the long format it would write any None value as is which
is invalid, use 0 for None values instead.
2019-05-03 00:53:09 +02:00
Miguel Sousa
45596108e2 (Re)calculate OS/2.usMaxContext value
The value is only modified in the context of fontBuilder or subset. It will NOT be modified when using ttx.

maxContextCalc.py was copied from https://github.com/googlefonts/ufo2ft/blob/master/Lib/ufo2ft/maxContextCalc.py

Fixes #1191
Fixes #466
2019-04-24 18:31:12 -07:00
Khaled Hosny
45861a15ca [feaLib] Reject invalid lookupflag without a value
Fixes https://github.com/fonttools/fonttools/issues/1538
2019-03-15 14:13:46 +02:00
Khaled Hosny
250eac4cae [feaLib] Correctly handle lookupflag 0 in asFea()
Part of https://github.com/fonttools/fonttools/issues/1538
2019-03-15 14:13:46 +02:00
Cosimo Lupo
abae80d730 [feaLib] make 'forceChain' an optional kwarg for barkward compat
See discussion at:
https://github.com/fonttools/fonttools/pull/1511#issuecomment-472425283
2019-03-13 15:11:53 +00:00
justvanrossum
723e7a1d3c updated inline github issue URLs 2019-03-06 16:01:28 +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
10cad7be3a [feaLib] Refactor almost duplicated subtable code
Also make the code a little less ugly.
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
3be73365a5 [feaLib] Reverse chain need not handle subtable 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
Khaled Hosny
cbd0995224 [feaLib] Fix double indentation of subtable
Similar to 05329ed033ae0aa2451272a39ada9aad9f1f5ed7.
2019-02-19 19:00:16 +02:00
Khaled Hosny
1a0aec4c56 [feaLib] Add forceChain to MultipleSubstStatement
For consistency with other substitution statements.
2019-02-19 18:59:58 +02:00
Cosimo Lupo
72e046647b
Add parentheses to clarify operators
Co-Authored-By: punchcutter <punchcutter@gmail.com>
2019-02-13 11:12:21 -08:00
punchcutter
da5b1500b9 Read special case of contextual positioning. 2019-02-12 12:35:34 -08:00
Miguel Sousa
17b2108666 [feaLib] Add 'tables' option to __main__.py
Relates to #1159
2019-02-10 22:27:26 -08:00