Closed roytam1 closed 6 years ago
proposed patch:
diff --git a/src/platform/3ds/gui-font.c b/src/platform/3ds/gui-font.c
index 3c1abc0a..61b16753 100644
--- a/src/platform/3ds/gui-font.c
+++ b/src/platform/3ds/gui-font.c
@@ -18,6 +18,7 @@
struct GUIFont {
C3D_Tex* sheets;
C3D_Tex icons;
+ float textScale;
};
struct GUIFont* GUIFontCreate(void) {
@@ -29,6 +30,7 @@ struct GUIFont* GUIFontCreate(void) {
C3D_Tex* tex;
TGLP_s* glyphInfo = fontGetGlyphInfo();
+ guiFont->textScale = 30.0f / (glyphInfo->cellHeight); // 30 is cellHeight in J machines
guiFont->sheets = malloc(sizeof(*guiFont->sheets) * glyphInfo->nSheets);
int i;
@@ -59,16 +61,16 @@ void GUIFontDestroy(struct GUIFont* font) {
}
unsigned GUIFontHeight(const struct GUIFont* font) {
- UNUSED(font);
- return fontGetInfo()->lineFeed * FONT_SIZE;
+// UNUSED(font);
+ return fontGetInfo()->lineFeed * FONT_SIZE * font->textScale;
}
unsigned GUIFontGlyphWidth(const struct GUIFont* font, uint32_t glyph) {
- UNUSED(font);
+// UNUSED(font);
int index = fontGlyphIndexFromCodePoint(glyph);
charWidthInfo_s* info = fontGetCharWidthInfo(index);
if (info) {
- return info->charWidth * FONT_SIZE;
+ return info->charWidth * FONT_SIZE * font->textScale;
}
return 0;
}
@@ -108,8 +110,8 @@ void GUIFontDrawGlyph(const struct GUIFont* font, int glyph_x, int glyph_y, uint
u16 v = tex->height * data.texcoord.bottom;
ctrAddRectEx(color, x, y,
- tex->width * width * FONT_SIZE, tex->height * height * -FONT_SIZE,
- u, v, tex->width * width, tex->height * height, 0);
+ font->textScale * tex->width * width * FONT_SIZE, font->textScale * tex->height * height * -FONT_SIZE,
+ u, v, font->textScale * tex->width * width, font->textScale * tex->height * height, 0);
}
void GUIFontDrawIcon(const struct GUIFont* font, int x, int y, enum GUIAlignment align, enum GUIOrientation orient, uint32_t color, enum GUIIcon icon) {
it builds, but untested. (I need to test it after off from work tonight)
Try this diff; it works on my U console.
diff --git a/src/platform/3ds/gui-font.c b/src/platform/3ds/gui-font.c
index 3c1abc0a0..fa9873f3b 100644
--- a/src/platform/3ds/gui-font.c
+++ b/src/platform/3ds/gui-font.c
@@ -13,11 +13,12 @@
#define CELL_HEIGHT 16
#define CELL_WIDTH 16
-#define FONT_SIZE 0.52f
+#define FONT_SIZE 15.6f
struct GUIFont {
C3D_Tex* sheets;
C3D_Tex icons;
+ float size;
};
struct GUIFont* GUIFontCreate(void) {
@@ -29,6 +30,7 @@ struct GUIFont* GUIFontCreate(void) {
C3D_Tex* tex;
TGLP_s* glyphInfo = fontGetGlyphInfo();
+ guiFont->size = FONT_SIZE / glyphInfo->cellHeight;
guiFont->sheets = malloc(sizeof(*guiFont->sheets) * glyphInfo->nSheets);
int i;
@@ -59,16 +61,14 @@ void GUIFontDestroy(struct GUIFont* font) {
}
unsigned GUIFontHeight(const struct GUIFont* font) {
- UNUSED(font);
- return fontGetInfo()->lineFeed * FONT_SIZE;
+ return fontGetInfo()->lineFeed * font->size;
}
unsigned GUIFontGlyphWidth(const struct GUIFont* font, uint32_t glyph) {
- UNUSED(font);
int index = fontGlyphIndexFromCodePoint(glyph);
charWidthInfo_s* info = fontGetCharWidthInfo(index);
if (info) {
- return info->charWidth * FONT_SIZE;
+ return info->charWidth * font->size;
}
return 0;
}
@@ -108,7 +108,7 @@ void GUIFontDrawGlyph(const struct GUIFont* font, int glyph_x, int glyph_y, uint
u16 v = tex->height * data.texcoord.bottom;
ctrAddRectEx(color, x, y,
- tex->width * width * FONT_SIZE, tex->height * height * -FONT_SIZE,
+ tex->width * width * font->size, tex->height * height * -font->size,
u, v, tex->width * width, tex->height * height, 0);
}
Try this diff; it works on my U console.
Since J/U/E, C, K devices shares same font metrics, they will work. While T devices has unique(i.e. smaller) font metrics, I need testing after off from work.
Try this diff; it works on my U console.
OK fixed confirmed.
CHT devices(Sell officially in Hong Kong and Taiwan) has smaller font size (20x24px) than others (25x30px) for more spaces to contain larger amount characters. (Source: converted bitmap from official cbf_zh-Hant-TW.bcfnt / cbf_std.bcfnt with ctr_FontConverter)
Same problem exists in other homebrew programs. I created a fix like: https://github.com/Steveice10/FBI/issues/423#issuecomment-357501263