25 Commits

Author SHA1 Message Date
Sascha Brawer
f76792c0eb Parse anonymous data blocks
http://www.adobe.com/devnet/opentype/afdko/topic_feature_file_syntax.html#10

For example, @mhosken is interested in experimenting with inlining
custom syntax (such as Python snippets) into feature files. After this
change, such experiments can be done on top of feaLib because the
Abstract Syntax Tree now contains the tag and content of `anonymous`
blocks.
2016-09-16 18:57:40 +02:00
Cosimo Lupo
cd8457f091 feaLib.lexer: strip newlines embedded within a string
Fixes #578
2016-04-17 22:21:24 +01:00
Behdad Esfahbod
2a0359af4d Always import * from py23
Since py23 modifies some essential builtins, it's safe to import
everything all the time.  At least, that's how it was designed.
It's a bug if importing * breaks some code.
2016-04-06 18:15:43 -07:00
Khaled Hosny
fdcba0e130 [feaLib] Allow “/” in name tokens
For “OS/2” table.
2016-03-23 03:10:05 +04:00
Cosimo Lupo
0f8f71d5ec [feaLib.lexer] modify make_lexer_ factory to take a 'file_or_path' argument
if 'file_or_path' is a file object keep it open, otherwise read the data from
the path and then close it.
2016-03-21 18:53:25 +00:00
Cosimo Lupo
83f074aac4 [feaLib] use shorter fea_path and fea_data kwargs in addOpenTypeFeatures
as discussed here: https://github.com/behdad/fonttools/pull/547/files#r56807232
2016-03-21 12:18:32 +00:00
Sascha Brawer
7eed24725f Allow include statements not terminated by a semicolon
The lexer passes the semicolon to the parser, which will read over it.
Resolves https://github.com/behdad/fonttools/issues/552.
2016-03-20 17:26:20 +01:00
Sascha Brawer
9ec04f0537 Merge pull request #547 from adrientetar/patch-2
feaLib: support string input
2016-03-20 09:09:06 -07:00
Adrien Tétar
492df7359b feaLib: fix tests 2016-03-20 15:01:33 +01:00
Khaled Hosny
6e291cf705 [feaLib] Fix parsing float numbers
Numbers with integral parts >= 10 were incorrectly parsed as integers as
next_char always pointed to the second number not the decimal point.
2016-03-18 18:42:59 +04:00
Adrien Tétar
5e64857b97 feaLib: support string input 2016-03-15 20:01:29 +01:00
Cosimo Lupo
ac56990aad replace all uses of codecs.open with py23.open 2016-01-26 15:45:27 +00: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
38f4ee7908 [feaLib] Implement table head with FontRevision statement 2016-01-11 18:01:47 +01:00
Sascha Brawer
5644da31d2 [feaLib] Parse device tables 2015-12-04 17:10:20 +01:00
Sascha Brawer
459eabf2e4 [feaLib] Allow +*:~^! in glyph names but not in glyph class names
Matches the behavior of Adobe's `makeotf` tool v2.0.84 of 2015-09-03.
Resolves https://github.com/behdad/fonttools/issues/370.
2015-09-14 10:53:37 +02:00
Sascha Brawer
9ddd313577 [feaLib] Merged LexerError and ParserError
This simplifies the public API to the library.  For clients, it does
not matter which exact component was detecting an error.  And we will
soon have more components; there would be little point in declaring
CompilerError, TableBuilderError, and so forth.
2015-09-07 11:39:09 +02:00
Sascha Brawer
5270a978a9 [feaLib] Support hexadecimal numbers
The OpenType Feature File specification does not specify hex numbers
as explicit token type, but they appear several times in the examples
given by the spec.
2015-08-10 11:17:52 +02:00
Sascha Brawer
d72aac035e [feaLib] Restrict length of glyph class names to 30 characters
This is required by the OpenType Feature File specification,
section 2.g.ii "Named glyph classes".
2015-08-10 11:17:52 +02:00
Sascha Brawer
ba238344b1 [feaLib] Implement top-level glyph class definitions 2015-08-10 11:17:52 +02:00
Sascha Brawer
f4ed6b5a85 Make pretty error messages for LexerError 2015-08-10 11:17:52 +02:00
Sascha Brawer
efbcba79a4 Handle inclusion of OpenType feature files 2015-08-10 11:17:52 +02:00
Sascha Brawer
ac700b0af5 Support FILENAME tokens when lexing OpenType feature files
When the lexer encounters the "include" keyword, it now enters
a special mode for scanning file names.  After having scanned over
the file name, the lexer goes back to normal.  The exact format
of file name strings is not defined by the OpenType feature file
specification, so we accept any character that is not a closing
parenthesis.
2015-08-10 11:17:52 +02:00
Sascha Brawer
612d2122ad Store file path in Lexer
This simplifies the implementation of the parser for
OpenType feature files, since it can now just keep
token locations returned by the lexer.  Before this
change, the parser had to un-pack the location tuples
and build new tuples that included the file path.
2015-08-10 11:17:52 +02:00
Sascha Brawer
da29d22748 Add lexer for OpenType feature files 2015-08-10 11:17:52 +02:00