From cc1a752ed07f4b6a327b0987dfc2f956e516ae2f Mon Sep 17 00:00:00 2001 From: Chris Feger Date: Mon, 29 Sep 2025 15:49:32 -0400 Subject: [PATCH] Load requested font unconditionally Instead of loading the system font if CFG:U is uninitialized, only deduplicate when CFG:U *is* initialized. --- include/c2d/font.h | 3 ++- source/font.c | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/include/c2d/font.h b/include/c2d/font.h index 130aa8e..7a8265f 100644 --- a/include/c2d/font.h +++ b/include/c2d/font.h @@ -44,8 +44,9 @@ C2D_Font C2D_FontLoadFromHandle(FILE* f); /** @brief Load corresponding font from system archive * @param[in] region Region to get font from * @returns Font handle - * @retval NULL Error + * @retval NULL Currently loaded system font * @remark JPN, USA, EUR, and AUS all use the same font. + * @remark If region is an arbitrary region including possibly the current one, it's recommended to initialize cfgu first. This allows much lower RAM usage for the system font. */ C2D_Font C2D_FontLoadSystem(CFG_Region region); diff --git a/source/font.c b/source/font.c index 5d1b61d..b356aba 100644 --- a/source/font.c +++ b/source/font.c @@ -184,7 +184,7 @@ C2D_Font C2D_FontLoadSystem(CFG_Region region) u8 systemRegion = 0; Result rc = CFGU_SecureInfoGetRegion(&systemRegion); - if (R_FAILED(rc) || fontIdx == C2Di_RegionToFontIndex((CFG_Region)systemRegion)) + if (R_SUCCEEDED(rc) && fontIdx == C2Di_RegionToFontIndex((CFG_Region)systemRegion)) { fontEnsureMapped(); return NULL;