all repos — mgba @ 59b9dedea32b229dc217c24fe688437638f025c8

mGBA Game Boy Advance Emulator

PSP2: Use font metrics
Jeffrey Pfau jeffrey@endrift.com
Sun, 23 Aug 2015 00:57:34 -0700
commit

59b9dedea32b229dc217c24fe688437638f025c8

parent

af81b47df2e4767b6e16a035f555b163ed36f053

1 files changed, 10 insertions(+), 8 deletions(-)

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

@@ -4,15 +4,14 @@ * 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 <vita2d.h> -#define GLYPH_HEIGHT 11 -#define GLYPH_WIDTH 14 -#define FONT_TRACKING 10 #define CELL_HEIGHT 16 #define CELL_WIDTH 16 +#define GLYPH_HEIGHT 12 struct GUIFont { vita2d_texture* tex;

@@ -50,10 +49,13 @@ char c = buffer[i];

if (c > 0x7F) { c = 0; } - vita2d_draw_texture_tint_part(font->tex, x, y - GLYPH_HEIGHT, - (c & 15) * CELL_WIDTH + ((CELL_WIDTH - GLYPH_WIDTH) >> 1), - (c >> 4) * CELL_HEIGHT + ((CELL_HEIGHT - GLYPH_HEIGHT) >> 1), - GLYPH_WIDTH, GLYPH_HEIGHT, color); - x += FONT_TRACKING; + struct GUIFontGlyphMetric metric = defaultFontMetrics[c]; + vita2d_draw_texture_tint_part(font->tex, x, y - GLYPH_HEIGHT + metric.padding.top, + (c & 15) * CELL_WIDTH + metric.padding.left, + (c >> 4) * CELL_HEIGHT + metric.padding.top, + CELL_WIDTH - (metric.padding.left + metric.padding.right), + CELL_HEIGHT - (metric.padding.top + metric.padding.bottom), + color); + x += metric.width; } }