convbdf: Properly support a compiled sysfont of over 64K.

The 'struct font' definition says:

    const void *offset;           /* offsets into bitmap data,
                                     uint16_t if bits_size < 0xFFDB else uint32_t*/

However convbdf was unconditionally using 'unsigned short' without
checking bits_size. This generated a bogus table if used with an
uncapped SYSFONT due to offeset overflows.  And a pile of complier
warnings.

That said, we're still capping SYSFONT at 255 chars due to space
constraints -- 14-Rockbox-mix jumps from 2.6K to 1022K if left
uncapped.  Yowza.

Change-Id: I4577da08ab1633ab7abbc167523196f38c8a348a
This commit is contained in:
Solomon Peachy 2024-11-06 09:33:40 -05:00
parent 000a575d13
commit d1ffaa8949

View file

@ -1347,7 +1347,7 @@ int gen_c_source(struct font* pf, char *path)
if (pf->offset) {
/* output offset table */
fprintf(ofp, "/* Character->glyph mapping. */\n"
"static const unsigned short _sysfont_offset[] = {\n");
"static const unsigned %s _sysfont_offset[] = {\n", pf->bits_size > 0xffdb ? "long" : "short");
for (i=0; i<pf->size; ++i) {
int offset = pf->offset[i];