187 Commits

Author SHA1 Message Date
Sascha Brawer
9ec04f0537 Merge pull request #547 from adrientetar/patch-2
feaLib: support string input
2016-03-20 09:09:06 -07:00
Khaled Hosny
1ac37d7d00 [feaLib] Support BASE table
Just the parts documented a currently implemented by Adobe’s
implementation.
2016-03-20 13:36:02 +04:00
Khaled Hosny
40be0e6f3a [feaLib] Support size feature 2016-03-19 21:55:24 +04:00
Khaled Hosny
9feaab13aa [feaLib] Support stylistic set featureNames
Does not handle featureNames for cvXX features, but it shouldn’t be hard
for someone to extend the code to support them if inclined to do so.
2016-03-18 14:08:00 +04:00
Khaled Hosny
53dc98be55 [feaLib] Fix parsing name records
Don’t override supplied encoding and language ids.
2016-03-18 14:06:33 +04:00
Adrien Tétar
5e64857b97 feaLib: support string input 2016-03-15 20:01:29 +01:00
Khaled Hosny
4e316cd337 [feaLib] Support name table 2016-03-15 17:49:02 +04:00
Sascha Brawer
5ab852277d [feaLib] Emit context-free contextual chains to SinglePos
Before this change, we had only emitted a SinglePos (GPOS type 1) lookup
for a statement like `pos A' B' 20`; after this change, we always emit a
chain rule even if there is no context. There is a semantic difference if
the rule is preceded by a `ignore pos` statement. Omitting context-free
contextual chains was actually not a (premature) optimization, but an
artifact that came from the representation of glyph patterns.

https://github.com/behdad/fonttools/issues/516
2016-02-09 09:00:06 +01:00
Sascha Brawer
b5d1124f43 [feaLib] Handle the ignore pos statement
https://github.com/behdad/fonttools/issues/503
2016-02-06 11:14:27 +01:00
Sascha Brawer
1ddfe24338 [feaLib] Support multiple chain contexts after ignore sub
Although this construct is in violation of the `ignore sub` grammar
given by the current OpenType Feature File syntax specification,
the very same specification document illustrates (in example 3
of section 5.f.ii) the `ignore sub` statement with a comma-separated
list of backgrack/input/lookahead triples.

See https://github.com/adobe-type-tools/afdko/issues/105 for a request
to amend the OpenType Feature File syntax specification.

After this code change, feaLib can now parse testdata/spec5f_ii_3.fea;
the output is identical to what is generated by Adobe's makeotf tool.

https://github.com/behdad/fonttools/issues/503
2016-02-05 11:02:29 +01:00
Sascha Brawer
27e23f9a95 [feaLib] Emit context-free chains to single substitutions
Resolves https://github.com/behdad/fonttools/issues/509
2016-02-04 16:45:05 +01:00
Sascha Brawer
dba1d6666b [feaLib] Emit chains to LigatureSubst even without backtrack or lookahead
https://github.com/behdad/fonttools/issues/506
2016-02-04 15:31:29 +01:00
Sascha Brawer
ab7b86005e [feaLib] Implement the ignore substitution statement
https://github.com/behdad/fonttools/issues/503
2016-02-04 11:39:03 +01:00
Sascha Brawer
4ee17824e1 [feaLib] Use global scope for glyph classes; allow re-definitions
Resolves https://github.com/behdad/fonttools/issues/496
2016-02-01 18:29:41 +01:00
Sascha Brawer
befce507a8 [feaLib] Use global scope for lookup names
Resolves https://github.com/behdad/fonttools/issues/461
2016-02-01 14:39:32 +01:00
Sascha Brawer
a7c0b5c78f [feaLib] Implement chained contextual single positioning
https://github.com/behdad/fonttools/issues/485
2016-01-25 15:10:40 +01:00
Sascha Brawer
82a444d659 [feaLib] Parse glyph patterns with multiple values
For example, we now recognize `pos one' 1 two' 2 three' 3;`
as a SinglePos statement, like makeotf does.

https://github.com/behdad/fonttools/issues/485
2016-01-25 12:18:17 +01:00
James Godfrey-Kittle
8fa5073e7e [feaLib] Accept empty statements in parser 2016-01-21 10:32:30 -08:00
Sascha Brawer
cc749c9c73 [feaLib] Allow 63 chars in names of glyphs and glyph classes
Resolves https://github.com/behdad/fonttools/issues/460.
See https://github.com/adobe-type-tools/afdko/pull/99 for
the change to the OpenType Feature File format specification.
2016-01-13 16:31:05 +01:00
Sascha Brawer
bfc3bff0e3 [feaLib] Support CID glyph names
Resolves https://github.com/behdad/fonttools/issues/459
2016-01-12 10:58:00 +01:00
Sascha Brawer
38f4ee7908 [feaLib] Implement table head with FontRevision statement 2016-01-11 18:01:47 +01:00
Sascha Brawer
2de6fc7744 [feaLib] Imlement special support for feature aalt 2016-01-11 16:00:52 +01:00
Sascha Brawer
5696b50fac [feaLib] Implement the GlyphClassDef statement 2016-01-08 19:06:52 +01:00
Sascha Brawer
13d23401f2 [feaLib] Parse GlyphClassDef statements
No output is generated yet; this will come in a later change.
2016-01-08 17:15:04 +01:00
Sascha Brawer
89ac1b2d0d [feaLib] Implement the Attach statement 2016-01-08 08:32:47 +01:00
Sascha Brawer
f8987125e7 [feaLib] Implement the LigatureCaretByIndex statement 2016-01-07 17:22:31 +01:00
Sascha Brawer
a44d8c5364 [feaLib] Implement the LigatureCaretByPos statement 2016-01-07 16:39:35 +01:00
Sascha Brawer
4daf0601b2 [feaLib] Adjust test case to use example from feature file format spec v1.17
In earlier versions of the OpenType Feature File Format specification,
the example was mal-formed so we had invented our own test case.
Adobe has kindly fixed the format specification:
https://github.com/adobe-type-tools/afdko/issues/88

This change revealed a bug in the parser where mark classes did
not get recognized as glyph classes; this is now fixed, too.
2016-01-07 13:02:21 +01:00
Sascha Brawer
adbf7ec4b1 [feaLib] Treat vkrn, vpal, vhal, valt as vertical features
Resolves https://github.com/behdad/fonttools/issues/449
2016-01-07 12:31:28 +01:00
Sascha Brawer
db49f20d6b [feaLib] Support compact syntax for chaining to alternate substitutions
https://github.com/behdad/fonttools/issues/445

Not sure whether it makes much sense to define a contextual chain
that points to a GSUB type 3, but the OpenType feature file syntax
does not explicitly forbid it.  Adobe's `makeotf` tool rejects this
kind of input with "Contextual alternate rule not yet supported";
this implies that the construct is valid (albeit definitely exotic).
2016-01-07 11:32:54 +01:00
Sascha Brawer
931bbc50c1 [feaLib] Support compact syntax for chaining to ligature substitutions
https://github.com/behdad/fonttools/issues/445
2016-01-07 10:31:13 +01:00
Sascha Brawer
45cc496bed [feaLib] Support compact syntax for chaining to multiple substitutions
https://github.com/behdad/fonttools/issues/445
2016-01-06 17:33:34 +01:00
Sascha Brawer
a543b2e3b9 [feaLib] Support compact syntax for chaining to single substitutions
Resolves https://github.com/behdad/fonttools/issues/445 for single
substitutions. The compact forms for chaining to other GSUB types
are not yet supported; these will get fixed in follow-up changes.
2016-01-06 16:15:26 +01:00
Sascha Brawer
cba2220446 [feaLib] Pass syntax tree nodes for kerned glyphs to builder
For GPOS type 2, the OpenType Feature File format makes a semantic
difference between `glyph` and `[glyph]`, so we need to pass the
syntax tree for the kerned glyphs and glyph classes down to the builder.

Previously, we were expanding syntax tree nodes to glyphSets at
parsing time. Therefore, the builder could not distinguish a statement
for kerning two single glyphs from a statement for kerning two glyph
glasses, where each glyph class would consist of a singleton
glyph. (Debating whether or not it makes much sense to have this
distinction is outside the scope of fonttools; we want to implement
the language in its present form).

The builder does not yet use this information for building different
tables. This change is just about plumbing.
2015-12-14 12:33:07 +01:00
Sascha Brawer
0dd370760e [feaLib] Clean up the handling of markClass statements 2015-12-12 12:55:21 +01:00
Sascha Brawer
dcae8fd8ba [feaLib] Represent mark class names as nodes in the syntax tree
Again, this will be needed for eventually distinguishing `glyph`
from `[glyph]` or `@CLASS`, which makes a semantic difference
when building GPOS type 2 tables.
2015-12-11 16:30:20 +01:00
Sascha Brawer
e99eb7948b [feaLib] Distinguish between glyphs and glyph classes in parse tree
This will be needed for implementing class-based kerning.  According
to the OpenType Feature File specification, a different table needs to
be built for `glyph` versus `[glyph]`.
2015-12-11 15:16:22 +01:00
Sascha Brawer
dfd210faef [feaLib] Parse lookupflag also when MarkAttachmentType comes last
Before this fix, the parser failed to process statements of the form
`lookupflag MarkAttachmentType @GLYPHCLASS;` when no other flag
were set after the glyph class. However, statements like
`lookupflag MarkAttachmentType @GLYPHCLASS RightToLeft;` were
getting recognized perfectly fine.
2015-12-10 16:00:54 +01:00
Sascha Brawer
0dbb2fdcc0 [feaLib] Parse lookupflag statements
They do not have any impact yet, this change is just for the parsing.
2015-12-10 13:06:28 +01:00
Sascha Brawer
e0a3350406 [feaLib] Implement GPOS type 8: Chaining contextual positioning 2015-12-09 23:53:20 +01:00
Sascha Brawer
cb0adb98b9 [feaLib] Parse GPOS type 8: Chaining contextual positioning
No output is generated yet, this change is just on the parser.

The OpenType Feature File specification is surprisingly vague about
the exact syntax of chaining contextual positioning rules, so I expect
that we will have to iterate on this parser. However, the test case
in parser_test.py gets recognized by `makeotf`, so the current
implementation is unlikely to be completely wrong.
2015-12-09 23:04:36 +01:00
Sascha Brawer
a364f60d1d [feaLib] Change semantics of markClass to also define a glyphclass
While not really documented in the OpenType Feature File specification,
the AFDKO makeotf tool handles the `markClass` statement this way.
Also, some examples in the specification seem to imply this semantics.
2015-12-09 22:15:52 +01:00
Sascha Brawer
2af0adde6c [feaLib] Parse Mark-to-mark attachment positioning statements
No output is produced yet; this will come in an upcoming change.
2015-12-09 17:14:13 +01:00
Sascha Brawer
d622f99982 [feaLib] Clean up class names of Abstract Syntax Tree statements
The class names of tree nodes for substitution and positioning rules
are now consistent with `builder.py`, which in turn is consistent with
`otTables.py`.
2015-12-09 13:58:05 +01:00
Sascha Brawer
0532ec85d3 [feaLib] Parse GPOS type 5: Mark-to-Ligature Attachment Positioning
No output is produced yet, this is just the change on the parser.
2015-12-09 10:40:49 +01:00
Sascha Brawer
25acebd824 [feaLib] Minor parser refactoring in preparation for GPOS type 5
GPOS type 5 has much in common with GPOS type 4, so we want to share
the common parsing code.
2015-12-08 23:46:04 +01:00
Sascha Brawer
790ea83a02 [feaLib] Parse GPOS type 4 aka Mark-to-Base Attachment Positioning
However, no output tables are being built yet. This change is just
implementing the feature file parser.
2015-12-08 19:04:42 +01:00
Sascha Brawer
dfa1551ece [feaLib] Implement markClass statement 2015-12-08 17:04:21 +01:00
Sascha Brawer
6240593839 [feaLib] Parse anchors in format A, B, C, D, and E 2015-12-07 22:48:10 +01:00
Sascha Brawer
46983f573f [feaLib] Parse GPOS type 2 format A and B, and ValueRecord format D
This is just the change on the parser. Building the output tables
is still marked as a TODO.
2015-12-07 17:18:18 +01:00