mirror of https://github.com/mgba-emu/mgba.git
PSP2: Use PGF fonts
This commit is contained in:
parent
690346fd4e
commit
f4e26656e4
1
CHANGES
1
CHANGES
|
@ -26,6 +26,7 @@ Misc:
|
|||
- 3DS: Allow UTF-16 filenames
|
||||
- 3DS: Port to using citro3D
|
||||
- 3DS: Use system font for menus
|
||||
- PSP2: Use system font for menus
|
||||
|
||||
0.4.1: (2016-07-11)
|
||||
Bugfixes:
|
||||
|
|
|
@ -15,7 +15,7 @@ source_group("PS Vita-specific code" FILES ${OS_SRC})
|
|||
list(APPEND CORE_VFS_SRC ${CMAKE_CURRENT_SOURCE_DIR}/sce-vfs.c)
|
||||
set(CORE_VFS_SRC ${CORE_VFS_SRC} PARENT_SCOPE)
|
||||
|
||||
set(OS_LIB -lvita2d -lSceCtrl_stub -lSceGxm_stub -lSceDisplay_stub -lSceAudio_stub -lSceCommonDialog_stub -lSceMotion_stub -lScePower_stub -lSceSysmodule_stub -lSceTouch_stub -l${M_LIBRARY})
|
||||
set(OS_LIB -lvita2d -lSceCtrl_stub -lScePgf_stub -lSceGxm_stub -lSceDisplay_stub -lSceAudio_stub -lSceCommonDialog_stub -lSceMotion_stub -lScePower_stub -lSceSysmodule_stub -lSceTouch_stub -l${M_LIBRARY})
|
||||
set(OBJCOPY_CMD ${OBJCOPY} -I binary -O elf32-littlearm -B arm)
|
||||
|
||||
list(APPEND GUI_SRC ${CMAKE_CURRENT_SOURCE_DIR}/gui-font.c)
|
||||
|
|
|
@ -10,13 +10,12 @@
|
|||
|
||||
#define CELL_HEIGHT 32
|
||||
#define CELL_WIDTH 32
|
||||
#define GLYPH_HEIGHT 24
|
||||
#define FONT_SIZE 1.2f
|
||||
|
||||
extern const uint8_t _binary_font2x_png_start[];
|
||||
extern const uint8_t _binary_icons2x_png_start[];
|
||||
|
||||
struct GUIFont {
|
||||
vita2d_texture* tex;
|
||||
vita2d_pgf* pgf;
|
||||
vita2d_texture* icons;
|
||||
};
|
||||
|
||||
|
@ -25,28 +24,27 @@ struct GUIFont* GUIFontCreate(void) {
|
|||
if (!font) {
|
||||
return 0;
|
||||
}
|
||||
font->tex = vita2d_load_PNG_buffer(_binary_font2x_png_start);
|
||||
font->pgf = vita2d_load_default_pgf();
|
||||
font->icons = vita2d_load_PNG_buffer(_binary_icons2x_png_start);
|
||||
return font;
|
||||
}
|
||||
|
||||
void GUIFontDestroy(struct GUIFont* font) {
|
||||
vita2d_free_texture(font->tex);
|
||||
vita2d_free_pgf(font->pgf);
|
||||
vita2d_free_texture(font->icons);
|
||||
free(font);
|
||||
}
|
||||
|
||||
unsigned GUIFontHeight(const struct GUIFont* font) {
|
||||
UNUSED(font);
|
||||
return GLYPH_HEIGHT;
|
||||
return vita2d_pgf_text_height(font->pgf, FONT_SIZE, "M") + 8;
|
||||
}
|
||||
|
||||
unsigned GUIFontGlyphWidth(const struct GUIFont* font, uint32_t glyph) {
|
||||
UNUSED(font);
|
||||
if (glyph > 0x7F) {
|
||||
glyph = '?';
|
||||
}
|
||||
return defaultFontMetrics[glyph].width * 2;
|
||||
char base[5] = { glyph };
|
||||
return vita2d_pgf_text_width(font->pgf, FONT_SIZE, base);
|
||||
}
|
||||
|
||||
void GUIFontIconMetrics(const struct GUIFont* font, enum GUIIcon icon, unsigned* w, unsigned* h) {
|
||||
|
@ -72,13 +70,8 @@ void GUIFontDrawGlyph(const struct GUIFont* font, int x, int y, uint32_t color,
|
|||
if (glyph > 0x7F) {
|
||||
glyph = '?';
|
||||
}
|
||||
struct GUIFontGlyphMetric metric = defaultFontMetrics[glyph];
|
||||
vita2d_draw_texture_tint_part(font->tex, x, y - GLYPH_HEIGHT + metric.padding.top * 2,
|
||||
(glyph & 15) * CELL_WIDTH + metric.padding.left * 2,
|
||||
(glyph >> 4) * CELL_HEIGHT + metric.padding.top * 2,
|
||||
CELL_WIDTH - (metric.padding.left + metric.padding.right) * 2,
|
||||
CELL_HEIGHT - (metric.padding.top + metric.padding.bottom) * 2,
|
||||
color);
|
||||
char base[5] = { glyph };
|
||||
vita2d_pgf_draw_text(font->pgf, x, y, color, FONT_SIZE, base);
|
||||
}
|
||||
|
||||
void GUIFontDrawIcon(const struct GUIFont* font, int x, int y, enum GUIAlignment align, enum GUIOrientation orient, uint32_t color, enum GUIIcon icon) {
|
||||
|
|
Loading…
Reference in New Issue