Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"glyph names are referenced but are missing from the glyph set" with --color_format=glyf #114

Closed
mavit opened this issue Aug 21, 2020 · 2 comments · Fixed by #123
Closed

Comments

@mavit
Copy link
Contributor

mavit commented Aug 21, 2020

I'm asusing here that if I want to build a black and white font, then the way to do that is supposed to be --color_format=glyf.

> nanoemoji --color_format=glyf --build_dir=/tmp/build ~/src/openmoji/black/svg/*.svg
...
I0821 13:55:20.156143 140401459275584 __init__.py:198] Pre-processing glyphs
I0821 13:55:21.644322 140401459275584 __init__.py:201] Running DecomposeComponentsFilter on AnEmojiFamily-Regular
I0821 13:55:21.659806 140401459275584 __init__.py:201] Running CubicToQuadraticFilter on AnEmojiFamily-Regular
I0821 13:55:23.812396 140401459275584 cubicToQuadratic.py:48] New spline lengths: 1: 4989, 2: 2869, 3: 445, 4: 136, 5: 8, 6: 2
I0821 13:55:23.812526 140401459275584 __init__.py:217] Building OpenType tables
W0821 13:55:23.826405 140401459275584 ttGlyphPen.py:108] skipped non-existing component 'g_1f171.0'
W0821 13:55:23.826629 140401459275584 ttGlyphPen.py:108] skipped non-existing component 'g_1f171.0'
W0821 13:55:23.826847 140401459275584 ttGlyphPen.py:108] skipped non-existing component 'g_1f171.0'
W0821 13:55:23.827029 140401459275584 ttGlyphPen.py:108] skipped non-existing component 'g_1f171.0'
W0821 13:55:23.827389 140401459275584 ttGlyphPen.py:108] skipped non-existing component 'g_1f171.0'
W0821 13:55:23.828286 140401459275584 ttGlyphPen.py:108] skipped non-existing component 'g_1f171.0'
W0821 13:55:23.828396 140401459275584 ttGlyphPen.py:108] skipped non-existing component 'g_1f171.0'
W0821 13:55:23.828578 140401459275584 ttGlyphPen.py:108] skipped non-existing component 'g_1f171.0'
W0821 13:55:23.828719 140401459275584 ttGlyphPen.py:108] skipped non-existing component 'g_1f171.0'
W0821 13:55:23.829014 140401459275584 ttGlyphPen.py:108] skipped non-existing component 'g_1f171.0'
W0821 13:55:23.829285 140401459275584 ttGlyphPen.py:108] skipped non-existing component 'g_1f171.0'
W0821 13:55:23.831177 140401459275584 ttGlyphPen.py:108] skipped non-existing component 'g_1f30d.0'
W0821 13:55:23.831289 140401459275584 ttGlyphPen.py:108] skipped non-existing component 'g_1f30d.0'
W0821 13:55:23.831404 140401459275584 ttGlyphPen.py:108] skipped non-existing component 'g_1f30d.0'
W0821 13:55:23.831508 140401459275584 ttGlyphPen.py:108] skipped non-existing component 'g_1f30d.0'
W0821 13:55:23.831611 140401459275584 ttGlyphPen.py:108] skipped non-existing component 'g_1f30d.0'
W0821 13:55:23.831729 140401459275584 ttGlyphPen.py:108] skipped non-existing component 'g_1f311'
W0821 13:55:23.831841 140401459275584 ttGlyphPen.py:108] skipped non-existing component 'g_1f311'
W0821 13:55:23.831951 140401459275584 ttGlyphPen.py:108] skipped non-existing component 'g_1f311'
W0821 13:55:23.832069 140401459275584 ttGlyphPen.py:108] skipped non-existing component 'g_1f315'
W0821 13:55:23.832181 140401459275584 ttGlyphPen.py:108] skipped non-existing component 'g_1f315'
W0821 13:55:23.832290 140401459275584 ttGlyphPen.py:108] skipped non-existing component 'g_1f315'
W0821 13:55:23.837227 140401459275584 ttGlyphPen.py:108] skipped non-existing component 'g_1f315'
W0821 13:55:23.841771 140401459275584 ttGlyphPen.py:108] skipped non-existing component 'g_1f315'
W0821 13:55:23.856497 140401459275584 ttGlyphPen.py:108] skipped non-existing component 'g_1f3f3_fe0f_200d_1f7e6_200d_1f30c'
W0821 13:55:23.856644 140401459275584 ttGlyphPen.py:108] skipped non-existing component 'g_1f3f3_fe0f_200d_1f7e6_200d_1f30c'
W0821 13:55:23.935787 140401459275584 ttGlyphPen.py:108] skipped non-existing component 'g_1f493.2'
W0821 13:55:23.949187 140401459275584 ttGlyphPen.py:108] skipped non-existing component 'g_1f532.0'
W0821 13:55:23.958236 140401459275584 ttGlyphPen.py:108] skipped non-existing component 'g_1f3f4_e0075_e0073_e0074_e0078_e007f'
W0821 13:55:24.004620 140401459275584 ttGlyphPen.py:108] skipped non-existing component 'g_1f7e4'
W0821 13:55:24.070451 140401459275584 ttGlyphPen.py:108] skipped non-existing component 'g_23fc.1'
W0821 13:55:24.070948 140401459275584 ttGlyphPen.py:108] skipped non-existing component 'g_1f3f4_e0075_e0073_e0074_e0078_e007f'
W0821 13:55:24.071634 140401459275584 ttGlyphPen.py:108] skipped non-existing component 'g_1f7e4'
W0821 13:55:24.071752 140401459275584 ttGlyphPen.py:108] skipped non-existing component 'g_1f7e4'
W0821 13:55:24.091329 140401459275584 ttGlyphPen.py:108] skipped non-existing component 'g_2b1f.1'
W0821 13:55:24.091886 140401459275584 ttGlyphPen.py:108] skipped non-existing component 'g_2b2e.2'
Traceback (most recent call last):
  File "/usr/lib64/python3.8/runpy.py", line 194, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/usr/lib64/python3.8/runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "/usr/local/lib/python3.8/site-packages/nanoemoji/write_font.py", line 486, in <module>
    app.run(main)
  File "/usr/local/lib/python3.8/site-packages/absl/app.py", line 300, in run
    _run_main(main, args)
  File "/usr/local/lib/python3.8/site-packages/absl/app.py", line 251, in _run_main
    sys.exit(main(argv))
  File "/usr/local/lib/python3.8/site-packages/nanoemoji/write_font.py", line 480, in main
    ufo, ttfont = _generate_color_font(config, inputs)
  File "/usr/local/lib/python3.8/site-packages/nanoemoji/write_font.py", line 430, in _generate_color_font
    ttfont = _make_ttfont(config, ufo, color_glyphs)
  File "/usr/local/lib/python3.8/site-packages/nanoemoji/write_font.py", line 177, in _make_ttfont
    ttfont = ufo2ft.compileTTF(ufo, overlapsBackend="pathops")
  File "/usr/local/lib/python3.8/site-packages/ufo2ft/__init__.py", line 225, in compileTTF
    compileFeatures(
  File "/usr/local/lib/python3.8/site-packages/ufo2ft/__init__.py", line 550, in compileFeatures
    otFont = featureCompiler.compile()
  File "/usr/local/lib/python3.8/site-packages/ufo2ft/featureCompiler.py", line 125, in compile
    self.setupFeatures()
  File "/usr/local/lib/python3.8/site-packages/ufo2ft/featureCompiler.py", line 220, in setupFeatures
    featureFile = parseLayoutFeatures(self.ufo)
  File "/usr/local/lib/python3.8/site-packages/ufo2ft/featureCompiler.py", line 48, in parseLayoutFeatures
    doc = parser.parse()
  File "/usr/local/lib/python3.8/site-packages/fontTools/feaLib/parser.py", line 103, in parse
    statements.append(self.parse_feature_block_())
  File "/usr/local/lib/python3.8/site-packages/fontTools/feaLib/parser.py", line 1437, in parse_feature_block_
    self.parse_block_(block, vertical, stylisticset, size_feature, cv_feature)
  File "/usr/local/lib/python3.8/site-packages/fontTools/feaLib/parser.py", line 1623, in parse_block_
    statements.append(self.parse_substitute_())
  File "/usr/local/lib/python3.8/site-packages/fontTools/feaLib/parser.py", line 798, in parse_substitute_
    ) = self.parse_glyph_pattern_(vertical=False)
  File "/usr/local/lib/python3.8/site-packages/fontTools/feaLib/parser.py", line 420, in parse_glyph_pattern_
    gc = self.parse_glyphclass_(accept_glyphname=True)
  File "/usr/local/lib/python3.8/site-packages/fontTools/feaLib/parser.py", line 322, in parse_glyphclass_
    self.check_glyph_name_in_glyph_set(glyph)
  File "/usr/local/lib/python3.8/site-packages/fontTools/feaLib/parser.py", line 1749, in check_glyph_name_in_glyph_set
    raise FeatureLibError(
fontTools.feaLib.error.FeatureLibError: <features>:17:14: The following glyph names are referenced but are missing from the glyph set: g_1f3fb
ninja: build stopped: subcommand failed.
Traceback (most recent call last):
  File "/usr/local/bin/nanoemoji", line 11, in <module>
    load_entry_point('nanoemoji==0.3.2.dev2+gf4f3609', 'console_scripts', 'nanoemoji')()
  File "/usr/local/lib/python3.8/site-packages/nanoemoji/nanoemoji.py", line 239, in main
    app.run(_run)
  File "/usr/local/lib/python3.8/site-packages/absl/app.py", line 300, in run
    _run_main(main, args)
  File "/usr/local/lib/python3.8/site-packages/absl/app.py", line 251, in _run_main
    sys.exit(main(argv))
  File "/usr/local/lib/python3.8/site-packages/nanoemoji/nanoemoji.py", line 230, in _run
    subprocess.run(ninja_cmd, check=True)
  File "/usr/lib64/python3.8/subprocess.py", line 512, in run
    raise CalledProcessError(retcode, process.args,
subprocess.CalledProcessError: Command '['ninja', '-C', '/tmp/build']' returned non-zero exit status 1.
@anthrotype
Copy link
Member

it took me a while but now I see what's going on here.. It's complicated but I'll try to explain. I also have a fix coming later.

When building a b&w glyf-only font (in _glyf_ufo) for each input SVG a new composite glyph is made (and added to the UFO in _create_glyphs), referencing each layer sub-path as components. Then if the composite only contains a single component, it's not worth keeping and thus the composite is de-composed (i.e. the parent composite glyph is swapped with its only component).
The swap (which deletes a component glyph and replaces the parent with it) is being done within the same for loop that is computing the reused paths. Since the mapping (glyphs) that groups glyphs by their reuse key contains mutable references to Glyph objects, and setting a glyph in a ufoLib2.Font (via __setitem__ interface) also renames the glyph, we may end up deleting glyphs that were renamed in a previous loop run.

The fix is to undo the compositing for single-component composites in a separate loop, only after we have finished computing the inter-glyph reuses.

@anthrotype
Copy link
Member

I also noticed that, when we replace single-component composite glyphs with their component, we aren't keeping the original unicode value associated with them. I'll fix it in the same PR

mavit added a commit to mavit/openmoji that referenced this issue Sep 12, 2020
JeppeKlitgaard pushed a commit to JeppeKlitgaard/openmoji that referenced this issue Nov 16, 2022
JeppeKlitgaard pushed a commit to JeppeKlitgaard/openmoji that referenced this issue Dec 6, 2022
JeppeKlitgaard pushed a commit to JeppeKlitgaard/openmoji that referenced this issue Dec 6, 2022
JeppeKlitgaard pushed a commit to JeppeKlitgaard/openmoji that referenced this issue Jan 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants