Repository navigation
Conversation
The glyph cache bitmap was created with 1 << bits_per_pixel as its bits per value. That is the number of values, so 1, 2 and 4 bpp fonts used 2, 4 and 16 bits per pixel, and an 8 bpp font failed with "Invalid bits per value". Round the font's bpp up to a power of two instead.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
common_hal_lvfontio_ondiskfont_construct()creates the glyph cache bitmap with1 << self->header.bits_per_pixelas the bits per value.common_hal_displayio_bitmap_construct_from_buffer()takes bits per value, so this passes the number of values instead (the PythonBitmap()constructor convertsvalue_countto bits before calling it). As a result:NotImplementedError: Invalid bits per value.This rounds the font's bpp up to a power of two (1, 2, 3→4, 4, 8) and uses it both for the buffer stride and for the bitmap.
Testing: I don't have a board with a display at hand, so I built
shared-module/lvfontio/OnDiskFont.cand the bitmap functions fromshared-module/displayio/legacy/Bitmap.con the host with small stubs for the VM and the supervisor file API, under ASan/UBSan, and loaded small generated.lvfontbinfiles:NotImplementedError(8 glyph cache slots of 4x4 px.) In every case the pixel values read back from the bitmap after caching a glyph match the font data. Nothing else reads
bits_per_valueof the font bitmap;terminalioand the supervisor display only use the pixel values.The bug and fix were found and tested with Claude Code (Claude Opus 5.5); I reviewed the change.