Merge remote-tracking branch 'upstream/master'

This commit is contained in:
Rod Sheeter 2019-02-12 11:53:52 -08:00
commit 4f318045fd
3 changed files with 8 additions and 4 deletions

View File

@ -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)

View File

@ -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

View File

@ -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,