From 1a6d5ad7e3f28e01e747f634384e3775c562e119 Mon Sep 17 00:00:00 2001 From: Vicki Pfau Date: Sun, 30 Jun 2019 17:36:00 -0700 Subject: [PATCH] 3DS: Update font code for ctrulib 1.6 --- src/platform/3ds/gui-font.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/src/platform/3ds/gui-font.c b/src/platform/3ds/gui-font.c index 67d44f4c9..761cd7c55 100644 --- a/src/platform/3ds/gui-font.c +++ b/src/platform/3ds/gui-font.c @@ -14,6 +14,7 @@ #define FONT_SIZE 15.6f struct GUIFont { + CFNT_s* font; C3D_Tex* sheets; C3D_Tex icons; float size; @@ -27,14 +28,15 @@ struct GUIFont* GUIFontCreate(void) { } C3D_Tex* tex; - TGLP_s* glyphInfo = fontGetGlyphInfo(); + guiFont->font = fontGetSystemFont(); + TGLP_s* glyphInfo = fontGetGlyphInfo(guiFont->font); guiFont->size = FONT_SIZE / glyphInfo->cellHeight; guiFont->sheets = malloc(sizeof(*guiFont->sheets) * glyphInfo->nSheets); int i; for (i = 0; i < glyphInfo->nSheets; ++i) { tex = &guiFont->sheets[i]; - tex->data = fontGetGlyphSheetTex(i); + tex->data = fontGetGlyphSheetTex(guiFont->font, i); tex->fmt = glyphInfo->sheetFmt; tex->size = glyphInfo->sheetSize; tex->width = glyphInfo->sheetWidth; @@ -59,12 +61,12 @@ void GUIFontDestroy(struct GUIFont* font) { } unsigned GUIFontHeight(const struct GUIFont* font) { - return fontGetInfo()->lineFeed * font->size; + return fontGetInfo(font->font)->lineFeed * font->size; } unsigned GUIFontGlyphWidth(const struct GUIFont* font, uint32_t glyph) { - int index = fontGlyphIndexFromCodePoint(glyph); - charWidthInfo_s* info = fontGetCharWidthInfo(index); + int index = fontGlyphIndexFromCodePoint(font->font, glyph); + charWidthInfo_s* info = fontGetCharWidthInfo(font->font, index); if (info) { return info->charWidth * font->size; } @@ -91,9 +93,9 @@ void GUIFontIconMetrics(const struct GUIFont* font, enum GUIIcon icon, unsigned* } void GUIFontDrawGlyph(const struct GUIFont* font, int glyph_x, int glyph_y, uint32_t color, uint32_t glyph) { - int index = fontGlyphIndexFromCodePoint(glyph); + int index = fontGlyphIndexFromCodePoint(font->font, glyph); fontGlyphPos_s data; - fontCalcGlyphPos(&data, index, 0, 1.0, 1.0); + fontCalcGlyphPos(&data, font->font, index, 0, 1.0, 1.0); C3D_Tex* tex = &font->sheets[data.sheetIndex]; ctrActivateTexture(tex);