You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When creating a text label: label processes each character at a time with get_glyph. If font glyphs are not preloaded, the adafruit_bitmap_font library function get_glyph calls the load_glyphs command on each individual character.
The load_glyphs function parses each line of the font file until the required glyph is found. So, if we process each character individually (like we do now), each new glyph that is encountered will require a new parsing of the font file.
I propose to perform the load_glyphs command on the full text input string prior to entering the character loop. By performing load_glyphs on the full input string will require a maximum of one time parsing through the font file.
When the glyphs are already loaded, this will add some time overhead due to checking if the glyphs are already present. But this checking adds only a small overhead (see snippet below from load_glyphs).
When creating a text label:
label
processes each character at a time withget_glyph
. If font glyphs are not preloaded, theadafruit_bitmap_font
library functionget_glyph
calls theload_glyphs
command on each individual character.The
load_glyphs
function parses each line of the font file until the required glyph is found. So, if we process each character individually (like we do now), each new glyph that is encountered will require a new parsing of the font file.I propose to perform the
load_glyphs
command on the full text input string prior to entering the character loop. By performingload_glyphs
on the full input string will require a maximum of one time parsing through the font file.When the glyphs are already loaded, this will add some time overhead due to checking if the glyphs are already present. But this checking adds only a small overhead (see snippet below from
load_glyphs
).https://github.com/adafruit/Adafruit_CircuitPython_Bitmap_Font/blob/784322cac41f3ae33385675e9977dd3957f6cecb/adafruit_bitmap_font/bdf.py#L100-L104
The text was updated successfully, but these errors were encountered: