aboutsummaryrefslogtreecommitdiff
path: root/Lib/fontTools/feaLib/parser.py
diff options
context:
space:
mode:
Diffstat (limited to 'Lib/fontTools/feaLib/parser.py')
-rw-r--r--Lib/fontTools/feaLib/parser.py36
1 files changed, 19 insertions, 17 deletions
diff --git a/Lib/fontTools/feaLib/parser.py b/Lib/fontTools/feaLib/parser.py
index fd53573d..04ff6030 100644
--- a/Lib/fontTools/feaLib/parser.py
+++ b/Lib/fontTools/feaLib/parser.py
@@ -73,6 +73,7 @@ class Parser(object):
self.next_token_location_ = None
lexerClass = IncludingLexer if followIncludes else NonIncludingLexer
self.lexer_ = lexerClass(featurefile, includeDir=includeDir)
+ self.missing = {}
self.advance_lexer_(comments=True)
def parse(self):
@@ -125,6 +126,16 @@ class Parser(object):
),
self.cur_token_location_,
)
+ # Report any missing glyphs at the end of parsing
+ if self.missing:
+ error = [
+ " %s (first found at %s)" % (name, loc)
+ for name, loc in self.missing.items()
+ ]
+ raise FeatureLibError(
+ "The following glyph names are referenced but are missing from the "
+ "glyph set:\n" + ("\n".join(error)), None
+ )
return self.doc_
def parse_anchor_(self):
@@ -1242,14 +1253,6 @@ class Parser(object):
raise FeatureLibError(
"Name id value cannot be greater than 32767", self.cur_token_location_
)
- if 1 <= nameID <= 6:
- log.warning(
- "Name id %d cannot be set from the feature file. "
- "Ignoring record" % nameID
- )
- self.parse_name_() # skip to the next record
- return None
-
platformID, platEncID, langID, string = self.parse_name_()
return self.ast.NameRecord(
nameID, platformID, platEncID, langID, string, location=location
@@ -2073,19 +2076,18 @@ class Parser(object):
raise FeatureLibError("Expected a glyph name or CID", self.cur_token_location_)
def check_glyph_name_in_glyph_set(self, *names):
- """Raises if glyph name (just `start`) or glyph names of a
- range (`start` and `end`) are not in the glyph set.
+ """Adds a glyph name (just `start`) or glyph names of a
+ range (`start` and `end`) which are not in the glyph set
+ to the "missing list" for future error reporting.
If no glyph set is present, does nothing.
"""
if self.glyphNames_:
- missing = [name for name in names if name not in self.glyphNames_]
- if missing:
- raise FeatureLibError(
- "The following glyph names are referenced but are missing from the "
- f"glyph set: {', '.join(missing)}",
- self.cur_token_location_,
- )
+ for name in names:
+ if name in self.glyphNames_:
+ continue
+ if name not in self.missing:
+ self.missing[name] = self.cur_token_location_
def expect_markClass_reference_(self):
name = self.expect_class_name_()