all repos — mgba @ fec11012a5440b959149f39b7dde9f2af094c7b4

mGBA Game Boy Advance Emulator

Wii: Lowercase and font metrics
Jeffrey Pfau jeffrey@endrift.com
Sun, 23 Aug 2015 01:45:50 -0700
commit

fec11012a5440b959149f39b7dde9f2af094c7b4

parent

f6e1d9d741d36532dc227b4648923af1fae464d6

3 files changed, 15 insertions(+), 15 deletions(-)

jump to
M src/platform/wii/gui-font.csrc/platform/wii/gui-font.c

@@ -4,13 +4,12 @@ * This Source Code Form is subject to the terms of the Mozilla Public

* License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ #include "util/gui/font.h" +#include "util/gui/font-metrics.h" #include "font.h" #include <ogc/tpl.h> -#define GLYPH_HEIGHT 11 -#define GLYPH_WIDTH 14 -#define FONT_TRACKING 10 +#define GLYPH_HEIGHT 12 #define CELL_HEIGHT 16 #define CELL_WIDTH 16

@@ -67,21 +66,22 @@ char c = buffer[i];

if (c > 0x7F) { c = 0; } - s16 tx = (c & 15) * CELL_WIDTH + ((CELL_WIDTH - GLYPH_WIDTH) >> 1); - s16 ty = (c >> 4) * CELL_HEIGHT + ((CELL_HEIGHT - GLYPH_HEIGHT) >> 1) - 1; + struct GUIFontGlyphMetric metric = defaultFontMetrics[c]; + s16 tx = (c & 15) * CELL_WIDTH + metric.padding.left; + s16 ty = (c >> 4) * CELL_HEIGHT + metric.padding.top; GX_Begin(GX_QUADS, GX_VTXFMT0, 4); - GX_Position2s16(x, y - GLYPH_HEIGHT); + GX_Position2s16(x, y - GLYPH_HEIGHT + metric.padding.top); GX_TexCoord2f32(tx / 256.f, ty / 128.f); - GX_Position2s16(x + GLYPH_WIDTH, y - GLYPH_HEIGHT); - GX_TexCoord2f32((tx + CELL_WIDTH) / 256.f, ty / 128.f); + GX_Position2s16(x + CELL_WIDTH - (metric.padding.left + metric.padding.right), y - GLYPH_HEIGHT + metric.padding.top); + GX_TexCoord2f32((tx + CELL_WIDTH - (metric.padding.left + metric.padding.right)) / 256.f, ty / 128.f); - GX_Position2s16(x + GLYPH_WIDTH, y); - GX_TexCoord2f32((tx + CELL_WIDTH) / 256.f, (ty + CELL_HEIGHT) / 128.f); + GX_Position2s16(x + CELL_WIDTH - (metric.padding.left + metric.padding.right), y - GLYPH_HEIGHT + CELL_HEIGHT - metric.padding.bottom); + GX_TexCoord2f32((tx + CELL_WIDTH - (metric.padding.left + metric.padding.right)) / 256.f, (ty + CELL_HEIGHT - (metric.padding.top + metric.padding.bottom)) / 128.f); - GX_Position2s16(x, y); - GX_TexCoord2f32(tx / 256.f, (ty + CELL_HEIGHT) / 128.f); + GX_Position2s16(x, y - GLYPH_HEIGHT + CELL_HEIGHT - metric.padding.bottom); + GX_TexCoord2f32(tx / 256.f, (ty + CELL_HEIGHT - (metric.padding.top + metric.padding.bottom)) / 128.f); GX_End(); - x += FONT_TRACKING; + x += metric.width; } }
M src/platform/wii/main.csrc/platform/wii/main.c

@@ -161,11 +161,11 @@ blip_set_rates(context.gba->audio.right, GBA_ARM7TDMI_FREQUENCY, 48000);

#endif char path[256]; - guOrtho(proj, -20, 220, 0, 400, 0, 300); + guOrtho(proj, -20, 240, 0, 352, 0, 300); GX_LoadProjectionMtx(proj, GX_ORTHOGRAPHIC); struct GUIParams params = { - 400, 230, + 352, 230, font, _drawStart, _drawEnd, _pollInput }; if (!selectFile(&params, "/", path, sizeof(path), "gba") || !GBAWiiLoadGame(path)) {