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

Sprite sheet generation can go out of bounds #6

Open
pushfoo opened this issue Dec 29, 2024 · 0 comments
Open

Sprite sheet generation can go out of bounds #6

pushfoo opened this issue Dec 29, 2024 · 0 comments
Assignees
Labels
bug Something isn't working waiting for release merged into main, yet not on PyPI

Comments

@pushfoo
Copy link
Owner

pushfoo commented Dec 29, 2024

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'
@pushfoo pushfoo added the bug Something isn't working label Dec 29, 2024
@pushfoo pushfoo self-assigned this Dec 29, 2024
@pushfoo pushfoo added the waiting for release merged into main, yet not on PyPI label Jan 2, 2025
@pushfoo pushfoo changed the title Sprite sheet generation bounds can go out of bounds Sprite sheet generation can go out of bounds Jan 2, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working waiting for release merged into main, yet not on PyPI
Projects
None yet
Development

No branches or pull requests

1 participant