googlefonts / nanoemoji

A wee tool to build color fonts.
Apache License 2.0
239 stars 21 forks source link

Bitmap tables need glyph ids sorted #385

Closed rsheeter closed 2 years ago

rsheeter commented 2 years ago

Seeing error of the following form:

Traceback (most recent call last):
  File "/usr/lib/python3.9/runpy.py", line 197, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/usr/lib/python3.9/runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "/usr/local/google/home/rsheeter/oss/noto-emoji/venv/lib/python3.9/site-packages/nanoemoji/write_font.py", line 824, in <module>
    app.run(main)
  File "/usr/local/google/home/rsheeter/oss/noto-emoji/venv/lib/python3.9/site-packages/absl/app.py", line 312, in run
    _run_main(main, args)
  File "/usr/local/google/home/rsheeter/oss/noto-emoji/venv/lib/python3.9/site-packages/absl/app.py", line 258, in _run_main
    sys.exit(main(argv))
  File "/usr/local/google/home/rsheeter/oss/noto-emoji/venv/lib/python3.9/site-packages/nanoemoji/write_font.py", line 818, in main
    _write(ufo, ttfont, font_config.output_file)
  File "/usr/local/google/home/rsheeter/oss/noto-emoji/venv/lib/python3.9/site-packages/nanoemoji/write_font.py", line 263, in _write
    ttfont.save(output_file)
  File "/usr/local/google/home/rsheeter/oss/noto-emoji/venv/lib/python3.9/site-packages/fontTools/ttLib/ttFont.py", line 181, in save
    writer_reordersTables = self._save(tmp)
  File "/usr/local/google/home/rsheeter/oss/noto-emoji/venv/lib/python3.9/site-packages/fontTools/ttLib/ttFont.py", line 221, in _save
    self._writeTable(tag, writer, done, tableCache)
  File "/usr/local/google/home/rsheeter/oss/noto-emoji/venv/lib/python3.9/site-packages/fontTools/ttLib/ttFont.py", line 634, in _writeTable
    tabledata = self.getTableData(tag)
  File "/usr/local/google/home/rsheeter/oss/noto-emoji/venv/lib/python3.9/site-packages/fontTools/ttLib/ttFont.py", line 656, in getTableData
    return self.tables[tag].compile(self)
  File "/usr/local/google/home/rsheeter/oss/noto-emoji/venv/lib/python3.9/site-packages/fontTools/ttLib/tables/E_B_L_C_.py", line 181, in compile
    data = indexSubTable.compile(ttFont)
  File "/usr/local/google/home/rsheeter/oss/noto-emoji/venv/lib/python3.9/site-packages/fontTools/ttLib/tables/E_B_L_C_.py", line 456, in compile
    assert all(glyphIds[i] < glyphIds[i+1] for i in range(len(glyphIds)-1))
AssertionError
ninja: build stopped: subcommand failed.

Looks to me like sorted color_glyphs on glyph_id in make_cbdt_table would fix this.

rsheeter commented 2 years ago

Must have made a mistake in verification as this does not appear to actually fix the problem.