Add separate function to load a system font

The other fonts are smaller, so when printing they're multiplied to be about the same as the standard
This commit is contained in:
Pk11
2021-03-20 17:49:32 -05:00
parent 12759353de
commit bb168fdab1
2 changed files with 45 additions and 1 deletions
+34 -1
View File
@@ -42,6 +42,7 @@ bool currentScreen = false;
bool fadeout = false, fadein = false, fadeout2 = false, fadein2 = false; bool fadeout = false, fadein = false, fadeout2 = false, fadein2 = false;
int fadealpha = 0; int fadealpha = 0;
int fadecolor = 0; int fadecolor = 0;
CFG_Region loadedSystemFont = (CFG_Region)-1;
/* /*
Clear the Text Buffer. Clear the Text Buffer.
@@ -73,6 +74,8 @@ void Gui::DrawSprite(C2D_SpriteSheet sheet, size_t imgindex, int x, int y, float
Contains initializing Citro2D, Citro3D and the screen targets. Contains initializing Citro2D, Citro3D and the screen targets.
Call this when initing the app. Call this when initing the app.
fontRegion: The region to use for the system font.
*/ */
Result Gui::init(CFG_Region fontRegion) { Result Gui::init(CFG_Region fontRegion) {
C3D_Init(C3D_DEFAULT_CMDBUF_SIZE); C3D_Init(C3D_DEFAULT_CMDBUF_SIZE);
@@ -86,10 +89,22 @@ Result Gui::init(CFG_Region fontRegion) {
/* Load Textbuffer. */ /* Load Textbuffer. */
TextBuf = C2D_TextBufNew(4096); TextBuf = C2D_TextBufNew(4096);
Font = C2D_FontLoadSystem(fontRegion); // Load System font. loadSystemFont(fontRegion);
return 0; return 0;
} }
/*
Load a system font.
fontRegion: The region to use for the system font.
*/
void Gui::loadSystemFont(CFG_Region fontRegion) {
if(loadedSystemFont != fontRegion) {
Font = C2D_FontLoadSystem(fontRegion);
loadedSystemFont = fontRegion;
}
}
/* /*
Load a bcfnt font. Load a bcfnt font.
@@ -151,6 +166,8 @@ void Gui::exit(void) {
/* /*
Reinitialize the GUI. Reinitialize the GUI.
fontRegion: The region to use for the system font.
*/ */
Result Gui::reinit(CFG_Region fontRegion) { Result Gui::reinit(CFG_Region fontRegion) {
C2D_TextBufDelete(TextBuf); C2D_TextBufDelete(TextBuf);
@@ -198,6 +215,22 @@ void Gui::DrawString(float x, float y, float size, u32 color, std::string Text,
C2D_TextOptimize(&c2d_text); C2D_TextOptimize(&c2d_text);
if(!fnt) {
switch(loadedSystemFont) {
case CFG_REGION_CHN:
size *= 1.13f;
break;
case CFG_REGION_TWN:
size *= 1.5f;
break;
case CFG_REGION_KOR:
size *= 1.1f;
break;
default:
break;
}
}
float heightScale; float heightScale;
if (maxHeight == 0) { if (maxHeight == 0) {
+11
View File
@@ -53,9 +53,18 @@ namespace Gui {
/* /*
Initialize the GUI with Citro2D & Citro3D and initialize the Textbuffer. Initialize the GUI with Citro2D & Citro3D and initialize the Textbuffer.
call this when initializing. call this when initializing.
fontRegion: The region to use for the system font.
*/ */
Result init(CFG_Region fontRegion = CFG_REGION_USA); Result init(CFG_Region fontRegion = CFG_REGION_USA);
/*
Load a system font.
fontRegion: The region to use for the system font.
*/
void loadSystemFont(CFG_Region fontRegion = CFG_REGION_USA);
/* /*
Load a Font. (BCFNT) Load a Font. (BCFNT)
@@ -95,6 +104,8 @@ namespace Gui {
/* /*
Reinit the GUI. Reinit the GUI.
fontRegion: The region to use for the system font.
*/ */
Result reinit(CFG_Region fontRegion = CFG_REGION_USA); Result reinit(CFG_Region fontRegion = CFG_REGION_USA);