Skip to content

Commit

Permalink
smaller font for game id
Browse files Browse the repository at this point in the history
  • Loading branch information
KrahJohlito committed Nov 16, 2024
1 parent becbfcf commit bed1dfb
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 5 deletions.
1 change: 1 addition & 0 deletions misc/conf_theme_OPL.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ main5:
type=ItemText
x=-124
y=-155
font=1
appsMain5:
type=ItemText
x=-124
Expand Down
1 change: 1 addition & 0 deletions misc/conf_theme_OPL_CF.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ main4:
type=ItemText
x=POS_MID
y=340
font=1
main5:
type=HintText
aligned=1
Expand Down
23 changes: 18 additions & 5 deletions src/fntsys.c
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,8 @@ static FT_Vector delta;

#define GLYPH_PAGE_OK(font, page) ((pageid <= font->cacheMaxPageID) && (font->glyphCache[page]))

static int fntLoadDefaultInternal(char *path, int fontSize, int slot);

static void fntCacheFlushPage(fnt_glyph_cache_entry_t *page)
{
int i;
Expand Down Expand Up @@ -285,7 +287,8 @@ void fntInit()
for (; i < FNT_MAX_COUNT; ++i)
fntInitSlot(&fonts[i]);

fntLoadDefault(NULL);
fntLoadDefaultInternal(NULL, FNTSYS_DEFAULT_SIZE, FNT_DEFAULT);
fntLoadDefaultInternal(NULL, 12, 1);
}

int fntLoadFile(char *path, int fontSize)
Expand All @@ -304,17 +307,22 @@ int fntLoadFile(char *path, int fontSize)
return FNT_ERROR;
}

int fntLoadDefault(char *path)
static int fntLoadDefaultInternal(char *path, int fontSize, int slot)
{
font_t newFont, oldFont;

if (fntLoadSlot(&newFont, path, FNTSYS_DEFAULT_SIZE) != FNT_ERROR) {
if (slot < 0 || slot >= FNT_MAX_COUNT) {
LOG("FNTSYS Invalid font slot: %d\n", slot);
return -1;
}

if (fntLoadSlot(&newFont, path, fontSize) != FNT_ERROR) {
// copy over the new font definition
// we have to lock this phase, as the old font may still be used
// Note: No check for concurrency is done here, which is kinda funky!
WaitSema(gFontSemaId);
memcpy(&oldFont, &fonts[FNT_DEFAULT], sizeof(font_t));
memcpy(&fonts[FNT_DEFAULT], &newFont, sizeof(font_t));
memcpy(&oldFont, &fonts[slot], sizeof(font_t));
memcpy(&fonts[slot], &newFont, sizeof(font_t));
SignalSema(gFontSemaId);

// delete the old font
Expand All @@ -326,6 +334,11 @@ int fntLoadDefault(char *path)
return -1;
}

int fntLoadDefault(char *path)
{
return fntLoadDefaultInternal(path, FNTSYS_DEFAULT_SIZE, FNT_DEFAULT);
}

void fntEnd()
{
LOG("FNTSYS End\n");
Expand Down

0 comments on commit bed1dfb

Please sign in to comment.