Skip to content

Sprite sheet generation can go out of bounds #6

@pushfoo

Description

@pushfoo

TL;DR: Font indices go OOB when writing fonts

Reported on Windows (ty @DragonMoffon) and confirmed on Linux.

Replication steps:

  1. Install main branch from source in a fresh venv
  2. Go to https://int10h.org/oldschool-pc-fonts/download/
  3. Download the latest font pack
  4. Navigate into the ttf - Mx (mixed outline+bitmap) folder of the zip
  5. Extract MxPlus_IBM_BIOS.ttf
  6. fontknife convert -g " ! ~\$%&'()+*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_\'abcdefghijklmnopqrstuvwxyz{|}~ ÇüéâäàåçêëèïîìÄÅÉæÆôöòûùÿÖÜ¢£¥₧ƒáíóúñѪº¿⌐¬½¼¡«»░▒▓│┤╡╢╖╕╣║╗╝╜╛┐└┴┬├─┼╞╟╚╔╩╦╠═╬╧╨╤╥╙╘╒╓╫╪┘┌█▄▌▐▀αßΓπΣσµτΦΘΩδ∞φε∩≡±≥≤⌠⌡÷≈°∙·√ⁿ²■ " /home/user/Downloads/MxPlus_IBM_BIOS.ttf test.png
  7. Observe issue below:
$ fontknife convert -g " ! ~\$%&'()+*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_\'abcdefghijklmnopqrstuvwxyz{|}~ ÇüéâäàåçêëèïîìÄÅÉæÆôöòûùÿÖÜ¢£¥₧ƒáíóúñѪº¿⌐¬½¼¡«»░▒▓│┤╡╢╖╕╣║╗╝╜╛┐└┴┬├─┼╞╟╚╔╩╦╠═╬╧╨╤╥╙╘╒╓╫╪┘┌█▄▌▐▀αßΓπΣσµτΦΘΩδ∞φε∩≡±≥≤⌠⌡÷≈°∙·√ⁿ²■ " /home/user/Downloads/MxPlus_IBM_BIOS.ttf test.png
Traceback (most recent call last):
  File "/home/user/Projects/Fontknife/.venv/bin/fontknife", line 8, in <module>
    sys.exit(main())
  File "/home/user/Projects/Fontknife/fontknife/frontend/__main__.py", line 117, in main
    args.callback(font, output_path, output_kwargs)
  File "/home/user/Projects/Fontknife/fontknife/frontend/commands/convert.py", line 20, in main
    write_font(font, output, **output_args)
  File "/home/user/Projects/Fontknife/fontknife/formats/__init__.py", line 105, in write_font
    writer.write_output(font, output, **kwargs)
  File "/home/user/Projects/Fontknife/fontknife/formats/writers/spritesheet.py", line 62, in write_output
    paste_bbox = grid_mapper.bbox_for_sheet_index(index)
  File "/home/user/Projects/Fontknife/fontknife/formats/common/spritesheet.py", line 193, in bbox_for_sheet_index
    coord = self.coord_for_sheet_index(index)
  File "/home/user/Projects/Fontknife/fontknife/formats/common/spritesheet.py", line 185, in coord_for_sheet_index
    raise e
KeyError: 'Index 96 not in grid'

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingwaiting for releasemerged into main, yet not on PyPI

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions