Skip to content
This repository has been archived by the owner on Apr 5, 2021. It is now read-only.

Commit

Permalink
Get rid of custom Font and use the System Font instead. (#82)
Browse files Browse the repository at this point in the history
  • Loading branch information
SuperSaiyajinStackZ authored and RocketRobz committed Aug 14, 2019
1 parent 35dd07a commit ed8fb54
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 36 deletions.
2 changes: 0 additions & 2 deletions include/gui.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,6 @@ namespace Gui {

void Draw_EndFrame(void);
void Draw_Text(float x, float y, float size, u32 color, const char *text);
void Draw_Text_Small(float x, float y, float size, u32 color, const char *text);
void Draw_Text_System(float x, float y, float size, u32 color, const char *text);
void Draw_Textf(float x, float y, float size, u32 color, const char* text, ...);
void Draw_GetTextSize(float size, float *width, float *height, const char *text);
float Draw_GetTextWidth(float size, const char *text);
Expand Down
Binary file removed romfs/gfx/Font.bcfnt
Binary file not shown.
Binary file removed romfs/gfx/smallFont.bcfnt
Binary file not shown.
28 changes: 2 additions & 26 deletions source/gui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,10 @@ C3D_RenderTarget* top;
C3D_RenderTarget* bottom;

static C2D_SpriteSheet sprites;
C2D_TextBuf dynamicBuf, sizeBuf;
C2D_Font defaultFont;
C2D_Font smallFont;
C2D_TextBuf sizeBuf;
C2D_Font systemFont;

void Gui::clearTextBufs(void) {
C2D_TextBufClear(dynamicBuf);
C2D_TextBufClear(sizeBuf);
}

Expand All @@ -50,11 +47,8 @@ Result Gui::init(void) {
C2D_Prepare();
top = C2D_CreateScreenTarget(GFX_TOP, GFX_LEFT);
bottom = C2D_CreateScreenTarget(GFX_BOTTOM, GFX_LEFT);
dynamicBuf = C2D_TextBufNew(4096);
sizeBuf = C2D_TextBufNew(4096);
sprites = C2D_SpriteSheetLoad("romfs:/gfx/sprites.t3x");
defaultFont = C2D_FontLoad("romfs:/gfx/Font.bcfnt");
smallFont = C2D_FontLoad("romfs:/gfx/smallFont.bcfnt");
systemFont = C2D_FontLoadSystem(CFG_REGION_USA);
return 0;
}
Expand All @@ -63,10 +57,7 @@ void Gui::exit(void) {
if (sprites) {
C2D_SpriteSheetFree(sprites);
}
C2D_TextBufDelete(dynamicBuf);
C2D_TextBufDelete(sizeBuf);
C2D_FontFree(defaultFont);
C2D_FontFree(smallFont);
C2D_Fini();
C3D_Fini();
}
Expand Down Expand Up @@ -113,26 +104,11 @@ void displayBottomMsg(const char* text) {
}

void Draw_EndFrame(void) {
C2D_TextBufClear(dynamicBuf);
C2D_TextBufClear(sizeBuf);
C3D_FrameEnd(0);
}

void Draw_Text(float x, float y, float size, u32 color, const char *text) {
C2D_Text c2d_text;
C2D_TextFontParse(&c2d_text, defaultFont, sizeBuf, text);
C2D_TextOptimize(&c2d_text);
C2D_DrawText(&c2d_text, C2D_WithColor, x, y, 0.5f, size, size, color);
}

void Draw_Text_Small(float x, float y, float size, u32 color, const char *text) {
C2D_Text c2d_text;
C2D_TextFontParse(&c2d_text, smallFont, sizeBuf, text);
C2D_TextOptimize(&c2d_text);
C2D_DrawText(&c2d_text, C2D_WithColor, x, y, 0.5f, size, size, color);
}

void Draw_Text_System(float x, float y, float size, u32 color, const char *text) {
C2D_Text c2d_text;
C2D_TextFontParse(&c2d_text, systemFont, sizeBuf, text);
C2D_TextOptimize(&c2d_text);
Expand All @@ -150,7 +126,7 @@ void Draw_Textf(float x, float y, float size, u32 color, const char* text, ...)

void Draw_GetTextSize(float size, float *width, float *height, const char *text) {
C2D_Text c2d_text;
C2D_TextFontParse(&c2d_text, defaultFont, sizeBuf, text);
C2D_TextFontParse(&c2d_text, systemFont, sizeBuf, text);
C2D_TextGetDimensions(&c2d_text, size, size, width, height);
}

Expand Down
16 changes: 8 additions & 8 deletions source/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,14 +72,14 @@ const char *button_titles2[] = {
};

const int title_spacing[] = {
0,
1,
0,
1,
0,
1,
4,
5,
6,
10,
6,
10,
6,
10,
10,
17,
};

const char *row_titles2[] = {
Expand Down

0 comments on commit ed8fb54

Please sign in to comment.