all repos — mgba @ 1a6d5ad7e3f28e01e747f634384e3775c562e119

mGBA Game Boy Advance Emulator

3DS: Update font code for ctrulib 1.6
Vicki Pfau vi@endrift.com
Sun, 30 Jun 2019 17:36:00 -0700
commit

1a6d5ad7e3f28e01e747f634384e3775c562e119

parent

6bd38d1565a4e19d86c840240e2f97dc2fdc4d58

1 files changed, 9 insertions(+), 7 deletions(-)

jump to
M src/platform/3ds/gui-font.csrc/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 @@ return 0;

} 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 @@ free(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 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);