convbdf: Replace magic number with #define shared with main code

Change-Id: Id46d5f2fe88fdaac94d00b1a4810ab161baad35b
This commit is contained in:
Solomon Peachy 2025-05-23 18:03:01 -04:00
parent 5efb6d7fac
commit 33c74d948c

View file

@ -37,6 +37,7 @@ typedef unsigned short bitmap_t; /* bitmap image unit size */
#define BITMAP_TESTBIT(m) ((m) & BITMAP_FIRSTBIT) #define BITMAP_TESTBIT(m) ((m) & BITMAP_FIRSTBIT)
#define BITMAP_SHIFTBIT(m) ((bitmap_t) ((m) << 1)) #define BITMAP_SHIFTBIT(m) ((bitmap_t) ((m) << 1))
#define MAX_FONTSIZE_FOR_16_BIT_OFFSETS 0xFFDB
/* builtin C-based proportional/fixed font structure */ /* builtin C-based proportional/fixed font structure */
/* based on The Microwindows Project http://microwindows.org */ /* based on The Microwindows Project http://microwindows.org */
@ -1347,7 +1348,7 @@ int gen_c_source(struct font* pf, char *path)
if (pf->offset) { if (pf->offset) {
/* output offset table */ /* output offset table */
fprintf(ofp, "/* Character->glyph mapping. */\n" fprintf(ofp, "/* Character->glyph mapping. */\n"
"static const unsigned %s _sysfont_offset[] = {\n", pf->bits_size > 0xffdb ? "long" : "short"); "static const unsigned %s _sysfont_offset[] = {\n", pf->bits_size > MAX_FONTSIZE_FOR_16_BIT_OFFSETS ? "long" : "short");
for (i=0; i<pf->size; ++i) { for (i=0; i<pf->size; ++i) {
int offset = pf->offset[i]; int offset = pf->offset[i];
@ -1592,7 +1593,7 @@ int gen_fnt_file(struct font* pf, char *path)
ofr += size; ofr += size;
} }
if ( pf->bits_size < 0xFFDB ) if ( pf->bits_size < MAX_FONTSIZE_FOR_16_BIT_OFFSETS )
{ {
/* bitmap offset is small enough, use unsigned short for offset */ /* bitmap offset is small enough, use unsigned short for offset */
if (ftell(ofp) & 1) if (ftell(ofp) & 1)
@ -1600,7 +1601,7 @@ int gen_fnt_file(struct font* pf, char *path)
} }
else else
{ {
/* bitmap offset is large then 64K, use unsigned int for offset */ /* bitmap offset is larger then 64K, use unsigned int for offset */
while (ftell(ofp) & 3) while (ftell(ofp) & 3)
writebyte(ofp, 0); /* pad to 32-bit boundary */ writebyte(ofp, 0); /* pad to 32-bit boundary */
} }
@ -1613,7 +1614,7 @@ int gen_fnt_file(struct font* pf, char *path)
if (pf->offset[i] == -1) { if (pf->offset[i] == -1) {
offrot = pf->offrot[pf->defaultchar - pf->firstchar]; offrot = pf->offrot[pf->defaultchar - pf->firstchar];
} }
if ( pf->bits_size < 0xFFDB ) if ( pf->bits_size < MAX_FONTSIZE_FOR_16_BIT_OFFSETS )
writeshort(ofp, offrot); writeshort(ofp, offrot);
else else
writeint(ofp, offrot); writeint(ofp, offrot);