diff --git a/Lib/fontTools/feaLib/__main__.py b/Lib/fontTools/feaLib/__main__.py index e446db622..da4eff6c7 100644 --- a/Lib/fontTools/feaLib/__main__.py +++ b/Lib/fontTools/feaLib/__main__.py @@ -1,7 +1,7 @@ from __future__ import print_function, division, absolute_import from fontTools.misc.py23 import * from fontTools.ttLib import TTFont -from fontTools.feaLib.builder import addOpenTypeFeatures +from fontTools.feaLib.builder import addOpenTypeFeatures, Builder from fontTools import configLogger from fontTools.misc.cliTools import makeOutputFileName import sys @@ -22,6 +22,9 @@ def main(args=None): parser.add_argument( "-o", "--output", dest="output_font", metavar="OUTPUT_FONT", help="Path to the output font.") + parser.add_argument( + "-t", "--tables", metavar="TABLE_TAG", choices=Builder.supportedTables, + nargs='+', help="Specify the table(s) to be built.") parser.add_argument( "-v", "--verbose", help="increase the logger verbosity. Multiple -v " "options are allowed.", action="count", default=0) @@ -34,7 +37,7 @@ def main(args=None): log.info("Compiling features to '%s'" % (output_font)) font = TTFont(options.input_font) - addOpenTypeFeatures(font, options.input_fea) + addOpenTypeFeatures(font, options.input_fea, tables=options.tables) font.save(output_font) diff --git a/Lib/fontTools/feaLib/lexer.py b/Lib/fontTools/feaLib/lexer.py index 18849ef07..095cb6684 100644 --- a/Lib/fontTools/feaLib/lexer.py +++ b/Lib/fontTools/feaLib/lexer.py @@ -28,7 +28,7 @@ class Lexer(object): CHAR_NAME_START_ = CHAR_LETTER_ + "_+*:.^~!\\" CHAR_NAME_CONTINUATION_ = CHAR_LETTER_ + CHAR_DIGIT_ + "_.+*:^~!/-" - RE_GLYPHCLASS = re.compile(r"^[A-Za-z_0-9.]+$") + RE_GLYPHCLASS = re.compile(r"^[A-Za-z_0-9.\-]+$") MODE_NORMAL_ = "NORMAL" MODE_FILENAME_ = "FILENAME" @@ -113,7 +113,7 @@ class Lexer(object): if not Lexer.RE_GLYPHCLASS.match(glyphclass): raise FeatureLibError( "Glyph class names must consist of letters, digits, " - "underscore, or period", location) + "underscore, period or hyphen", location) return (Lexer.GLYPHCLASS, glyphclass, location) if cur_char in Lexer.CHAR_NAME_START_: self.pos_ += 1 diff --git a/Tests/feaLib/lexer_test.py b/Tests/feaLib/lexer_test.py index 27e2da68a..1b28fa097 100644 --- a/Tests/feaLib/lexer_test.py +++ b/Tests/feaLib/lexer_test.py @@ -39,6 +39,7 @@ class LexerTest(unittest.TestCase): def test_glyphclass(self): self.assertEqual(lex("@Vowel.sc"), [(Lexer.GLYPHCLASS, "Vowel.sc")]) + self.assertEqual(lex("@Vowel-sc"), [(Lexer.GLYPHCLASS, "Vowel-sc")]) self.assertRaisesRegex(FeatureLibError, "Expected glyph class", lex, "@(a)") self.assertRaisesRegex(FeatureLibError,