477 Commits

Author SHA1 Message Date
Khaled Hosny
fbf896c969 [feaLib][test] No need to create temporary file (#764)
Loading features from file objects have been supported for a while
already.
2016-12-10 23:29:14 +01:00
Cosimo Lupo
3b1e0bdc47
[feaLib.builder_test] fix up tests for backslash-escaped glyph names 2016-11-02 16:01:35 +00:00
Cosimo Lupo
a0cc66bfc0
[feaLib.parser] strip initial backslash from glyph names
Fixes https://github.com/fonttools/fonttools/issues/457

Backslash-prefixed glyph name can be used in a Feature file to distinguish them from identically-named keywords.

From section "2.f.i. Glyph name" of Adobe's Feature File Specification:

> An initial backslash serves to differentiate a glyph name from an identical keyword in the feature file language. For example, a glyph named "table" must be specified in the feature file as: \table

Thus, when we parse a glyph name that begins with a backslash, we need to ignore the first character.

Note that makeotf rejects feature files with glyph names that start with or contain backslashes, even when escaped with another backslash.

feature liga {
    sub \\glyphWithBackslash by A;
} liga;

This yields:

    makeotfexe [FATAL] <Backslash-Regular> invalid token (text was "\") [features 2]
2016-11-02 16:01:21 +00:00
Sascha Brawer
248336a0fb Add test case for glyph names with backslash
Resolves https://github.com/fonttools/fonttools/issues/457
2016-10-24 22:39:59 +02:00
moyogo
004a5b7361 feaLib: hhea tableVersion = 0x00010000 2016-10-18 18:18:09 +02:00
moyogo
5b785950f8 feaLib: add test for vhea 2016-10-18 18:18:09 +02:00
moyogo
f55c60c4df feaLib: add vhea table 2016-10-18 18:18:09 +02:00
moyogo
bd4d43e7c5 feaLib: hhea test with hex version 2016-10-18 18:18:09 +02:00
moyogo
4dd1e73b04 Revert "Merge pull request #606 from anthrotype/cff-dehint"
This reverts commit 25a03f5a5736ed70791a8dde31605ed4cee9bbd9, reversing
changes made to 8351600bc628278960390d747f45593a50b7c1ea.
2016-10-14 20:20:35 +01:00
Sascha Brawer
0588502771 Add otConverters.NameID (#708)
When writing XML, this produces a comment with the English name.
If the name ID is missing from the name table, it logs a warning.
2016-10-14 21:04:35 +02:00
Cosimo Lupo
718201471a {subset,builder}_test: fix order of fromfile/tofile in expect_ttx
The order of the arguments for difflib.unified_diff was inverted in feaLib.builder_test.
The same snippet was probably copy-pasted to the subset_test.

See https://docs.python.org/3/library/difflib.html#difflib.unified_diff
2016-10-09 11:54:48 +01:00
moyogo
62894667f6 feaLib: fix code to use hex version instead of float 2016-09-29 20:43:50 +01:00
Behdad Esfahbod
3ec06df194 Fix failing tests 2016-09-27 19:53:58 +02:00
Behdad Esfahbod
a30b6250cb . 2016-09-27 19:49:41 +02:00
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
Denis Moyogo Jacquerye
7930106740 feaLib: limit language statements to 1 feature block (#658)
* feaLib: limit language statements to 1 feature block

language exclude_dflt statements should only apply to lookups
defined in their feature block and not to lookups defined
in previous blocks sharing the same feature tag

* feaLib: add BuilderTest::test_FeatureFile_multiple_feature_blocks
2016-08-30 19:44:33 +02:00
Cosimo Lupo
53232c02bd [feaLib.parser_test] test for stray semicolons 2016-07-27 09:55:11 +01:00
Cosimo Lupo
e9c3686b18 [feaLib.parser] ignore top-level empty statements made up of a single semicolon
makeotf doesn't complain about them either.

Fixes #641
2016-07-27 09:54:08 +01:00
James Godfrey-Kittle
5c723ebfb0 [feaLib] Don't assume feature has lookups in DFLT
It's possible for all of a feature's lookups to be in specific script
and/or language systems, so this code could crash.
2016-06-22 16:19:45 -07:00
James Godfrey-Kittle
e2186dec53 [feaLib] Don't set language when script is unset
Before, if someone tried to set the language before setting the script
a None/language language system would be created (with actual tag
"None" stored in the feature table). This defaults to tag DFLT and
fails when a non-dflt language is set for DFLT, since that's illegal.
2016-06-22 11:29:42 -07:00
James Godfrey-Kittle
aaf9294d97 [feaLib] Add another test for language systems 2016-06-21 16:40:17 -07:00
James Godfrey-Kittle
d1af1cfd4a [feaLib] Fix exclude_dflt handling
This is to fix what I think was a misunderstanding of the exclude_dflt
keyword (and the implicit include_dflt option active by default).

Rather than including the following lookups in the default language
systems, I think it is used to include the lookups specific to default
language systems in the system defined by the current language
statement. Thus instead of registering a lookup in all default
systems when include_dflt is true, we should exclude the lookups
registered with default systems from the current system when
include_dflt is false.
2016-06-21 16:39:27 -07:00
moyogo
70a60433f8 [feaLib]: fix unescape_mac_name_string() and unescape_windows_name_string() 2016-06-01 17:33:15 +01:00
moyogo
84e7423a6e [feaLib] use OrderedDict instead of dict in MarkClass 2016-04-26 06:58:46 +01:00
moyogo
4ec59b27dd [feaLib] add test for issue #504 2016-04-25 22:37:58 +01:00
moyogo
17c8e582d0 [feaLib] glyph class as list and tuple instead of set and frozenset 2016-04-25 22:36:56 +01:00
Khaled Hosny
cdda278bd4 Use ttLib.newTable when possible
I learnt about it from [1] and seems like a nice thing to use.

1. https://github.com/behdad/fonttools/pull/586#issuecomment-213285350
2016-04-23 02:00:24 +02:00
Cosimo Lupo
47039f709b feaLib.lexer_test: add test for newlines in string token 2016-04-17 22:21:40 +01:00
Cosimo Lupo
cd8457f091 feaLib.lexer: strip newlines embedded within a string
Fixes #578
2016-04-17 22:21:24 +01:00
Sascha Brawer
967cf8bb15 Sort feature records by feature tag
Resolves https://github.com/behdad/fonttools/issues/568
2016-04-12 13:53:25 +02:00
Cosimo Lupo
2ac24ec27e feaLib.ast: fix 'TypeError: not enough arguments for format string' 2016-04-10 23:06:35 +01:00
Khaled Hosny
5ceaa43d27 [feaLib] Support hhea table 2016-04-09 18:02:40 +02: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
0a1f323835 [feaLib] Support OS/2 table 2016-03-23 15:42:00 +04:00
Khaled Hosny
fdcba0e130 [feaLib] Allow “/” in name tokens
For “OS/2” table.
2016-03-23 03:10:05 +04:00
Cosimo Lupo
9e8113718b [feaLib.builder] decode features string using tounicode before passing it to StringIO (for python2) 2016-03-21 19:39:07 +00:00
Cosimo Lupo
bb937e35e6 [feaLib.parser_test] fix up tests after changes to featurefile arg 2016-03-21 18:55:38 +00:00
Cosimo Lupo
3affc725aa [feaLib.lexer_test] fix up tests after changes to make_lexer_ 2016-03-21 18:55:35 +00: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
6a05367a2c [feaLib.parser] change argument name 2016-03-21 18:47:27 +00:00
Cosimo Lupo
06b9a808ad [feaLib.builder] make addOpenTypeFeatures take only one 'featurefile' argument; add addOpenTypeFeaturesFromString
'featurefile' can be either a path (string) or a file object, like in TTFont or XMLReader and XMLWriter constructors.

If a file object does not have a 'name' attribute, a default "<features>" name is
used and the current working directory is assumed as the root for relative includes.
2016-03-21 18:46:50 +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
Cosimo Lupo
694b9d6917 [feaLib.parser_test] add test for ignored nameIDs 1-6 2016-03-21 11:02:03 +00:00
Cosimo Lupo
5efc85873b [feaLib.parser] issue a warning and ignore 1 <= nameID <= 6 (like makeotf) 2016-03-21 11:01:33 +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
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
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