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;
int fadealpha = 0;
int fadecolor = 0;
CFG_Region loadedSystemFont = (CFG_Region)-1;
/*
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.
Call this when initing the app.
fontRegion: The region to use for the system font.
*/
Result Gui::init(CFG_Region fontRegion) {
C3D_Init(C3D_DEFAULT_CMDBUF_SIZE);
@@ -86,10 +89,22 @@ Result Gui::init(CFG_Region fontRegion) {
/* Load Textbuffer. */
TextBuf = C2D_TextBufNew(4096);
Font = C2D_FontLoadSystem(fontRegion); // Load System font.
loadSystemFont(fontRegion);
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.
@@ -151,6 +166,8 @@ void Gui::exit(void) {
/*
Reinitialize the GUI.
fontRegion: The region to use for the system font.
*/
Result Gui::reinit(CFG_Region fontRegion) {
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);
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;
if (maxHeight == 0) {