question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

FEA parser and glyph names containing hyphens

See original GitHub issue

Consider this feature file,

@A_CLASS = [ pre-post ];

I get a traceback when trying to parse it with this snippet,

from fontTools.feaLib.parser import Parser

with open('file.fea') as fea_file:
    parser = Parser(fea_file)
    doc = parser.parse()
    print(doc.asFea())
Traceback (most recent call last):
  File "fea_parse.py", line 7, in <module>
    doc = parser.parse()
  File "fontTools/feaLib/parser.py", line 61, in parse
    statements.append(self.parse_glyphclass_definition_())
  File "fontTools/feaLib/parser.py", line 221, in parse_glyphclass_definition_
    glyphs = self.parse_glyphclass_(accept_glyphname=False)
  File "fontTools/feaLib/parser.py", line 294, in parse_glyphclass_
    start, limit = self.split_glyph_range_(glyph, location)
  File "fontTools/feaLib/parser.py", line 259, in split_glyph_range_
    "into a range of known glyphs" % name, location)
fontTools.feaLib.error.FeatureLibError: file.fea:2:14: "pre-post" is not a glyph in the font, and it can not be split into a range of known glyphs

However, all is fine if I initialize the parser with the glyphNames argument,

parser = Parser(fea_file, glyphNames=['pre-post'])

Is this by design, or does the parser not fully support glyph names that contain hyphens?

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:13 (5 by maintainers)

github_iconTop GitHub Comments

4reactions
justvanrossumcommented, Dec 3, 2019

It seems odd that the parser needs to know ahead of time which tokens may be glyph names, but I’ll take it. Thanks for confirming it.

I think it’s a logical consequence of changing the language to allow hyphens so late in the game. The hyphen had a meaning before (a range) and now there’s an ambiguity that can only be resolved in a bw compatible way with knowledge of the glyph set.

2reactions
brawercommented, Apr 3, 2020

Personally, I wouldn’t have strong opinions, but (as with similar requests) I don’t think we should make incompatible changes without very good reasons. So, my process recommendation would be:

  1. Make a concrete proposal for changing the spec;
  2. get consensus with Adobe (in past discussions, they’ve always been very reasonable);
  3. only then, change the implementation.

Otherwise, you’ll fragment the file format, which would hurt everyone.

Read more comments on GitHub >

github_iconTop Results From Across the Web

feaLib: Read/write OpenType feature files - fontTools
fontTools' feaLib allows for the creation and parsing of Adobe Font Development Kit for ... help to disambiguate ranges from glyph names containing...
Read more >
End-of-line hyphenation of chemical names (IUPAC ...
A chemical name containing hyphens should preferably be divided at a hyphen that is part of the name. However, not every hyphen in...
Read more >
Hyphens in glyph names are illegal
I'd like to use cross-app-compatible friendly glyph names, unfortunately hyphens can't be used…
Read more >
Editing Fonts > Editing Fonts > Glyph Names - High-Logic
If a glyph name is used in an OpenType script, it could cause issues with the parser if it contains specific characters. One...
Read more >
OpenType Feature File Specification | afdko - GitHub Pages
An OpenType feature file is a text file that contains the typographic layout ... Distinguishes glyph names from an identical keyword - hyphen...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found