mirror of
https://github.com/libretro/RetroArch
synced 2025-02-20 15:40:44 +00:00
(WiiU) add freetype and stb font support.
freetype disabled by default due to requiring an external library.
This commit is contained in:
parent
1f13d616cc
commit
b17e76d8b7
@ -37,6 +37,8 @@ ifeq ($(GRIFFIN_BUILD), 1)
|
||||
OBJ += griffin/griffin.o
|
||||
DEFINES += -DHAVE_GRIFFIN=1 -DHAVE_MENU -DHAVE_RGUI -DHAVE_LIBRETRODB
|
||||
DEFINES += -DHAVE_ZLIB -DHAVE_RPNG -DHAVE_RJPEG -DHAVE_RBMP -DHAVE_RTGA -DWANT_ZLIB -DHAVE_CC_RESAMPLER
|
||||
DEFINES += -DHAVE_STB_FONT
|
||||
# DEFINES += -DHAVE_FREETYPE
|
||||
# DEFINES += -DHAVE_XMB -DHAVE_MATERIALUI
|
||||
else
|
||||
HAVE_MENU_COMMON = 1
|
||||
@ -52,6 +54,8 @@ else
|
||||
HAVE_ZARCH = 0
|
||||
HAVE_MATERIALUI = 0
|
||||
HAVE_XMB = 0
|
||||
HAVE_STB_FONT = 1
|
||||
# HAVE_FREETYPE = 1
|
||||
|
||||
include Makefile.common
|
||||
BLACKLIST :=
|
||||
|
@ -24,6 +24,10 @@
|
||||
#include <file/file_path.h>
|
||||
#include <retro_miscellaneous.h>
|
||||
|
||||
#ifdef WIIU
|
||||
#include <wiiu/os.h>
|
||||
#endif
|
||||
|
||||
#include FT_FREETYPE_H
|
||||
#include "../font_driver.h"
|
||||
|
||||
@ -217,9 +221,26 @@ static void *font_renderer_ft_init(const char *font_path, float font_size)
|
||||
if (err)
|
||||
goto error;
|
||||
|
||||
err = FT_New_Face(handle->lib, font_path, 0, &handle->face);
|
||||
if (err)
|
||||
goto error;
|
||||
#ifdef WIIU
|
||||
if(!*font_path)
|
||||
{
|
||||
void* font_data = NULL;
|
||||
uint32_t font_size = 0;
|
||||
|
||||
if(!OSGetSharedData(SHARED_FONT_DEFAULT, 0, &font_data, &font_size))
|
||||
goto error;
|
||||
|
||||
err = FT_New_Memory_Face(handle->lib, font_data, font_size, 0, &handle->face);
|
||||
if (err)
|
||||
goto error;
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
err = FT_New_Face(handle->lib, font_path, 0, &handle->face);
|
||||
if (err)
|
||||
goto error;
|
||||
}
|
||||
|
||||
err = FT_Select_Charmap(handle->face, FT_ENCODING_UNICODE);
|
||||
if (err)
|
||||
@ -266,6 +287,9 @@ static const char *font_paths[] = {
|
||||
/* Highly OS/platform dependent. */
|
||||
static const char *font_renderer_ft_get_default_font(void)
|
||||
{
|
||||
#ifdef WIIU
|
||||
return "";
|
||||
#else
|
||||
size_t i;
|
||||
|
||||
for (i = 0; i < ARRAY_SIZE(font_paths); i++)
|
||||
@ -275,6 +299,7 @@ static const char *font_renderer_ft_get_default_font(void)
|
||||
}
|
||||
|
||||
return NULL;
|
||||
#endif
|
||||
}
|
||||
|
||||
static int font_renderer_ft_get_line_height(void* data)
|
||||
|
@ -20,6 +20,10 @@
|
||||
#include <streams/file_stream.h>
|
||||
#include <retro_miscellaneous.h>
|
||||
|
||||
#ifdef WIIU
|
||||
#include <wiiu/os.h>
|
||||
#endif
|
||||
|
||||
#include "../font_driver.h"
|
||||
#include "../../verbosity.h"
|
||||
|
||||
@ -216,6 +220,15 @@ static void *font_renderer_stb_unicode_init(const char *font_path, float font_si
|
||||
/* See https://github.com/nothings/stb/blob/master/stb_truetype.h#L539 */
|
||||
font_size = STBTT_POINT_SIZE(font_size);
|
||||
|
||||
#ifdef WIIU
|
||||
if(!*font_path)
|
||||
{
|
||||
uint32_t size = 0;
|
||||
if (!OSGetSharedData(SHARED_FONT_DEFAULT, 0, &self->font_data, &size))
|
||||
goto error;
|
||||
}
|
||||
else
|
||||
#endif
|
||||
if (!filestream_read_file(font_path, (void**)&self->font_data, NULL))
|
||||
goto error;
|
||||
|
||||
@ -245,6 +258,9 @@ error:
|
||||
|
||||
static const char *font_renderer_stb_unicode_get_default_font(void)
|
||||
{
|
||||
#ifdef WIIU
|
||||
return "";
|
||||
#else
|
||||
static const char *paths[] = {
|
||||
#if defined(_WIN32)
|
||||
"C:\\Windows\\Fonts\\consola.ttf",
|
||||
@ -286,6 +302,7 @@ static const char *font_renderer_stb_unicode_get_default_font(void)
|
||||
return *p;
|
||||
|
||||
return NULL;
|
||||
#endif
|
||||
}
|
||||
|
||||
static int font_renderer_stb_unicode_get_line_height(void* data)
|
||||
|
@ -34,7 +34,7 @@ static const font_renderer_driver_t *font_backends[] = {
|
||||
&coretext_font_renderer,
|
||||
#endif
|
||||
#ifdef HAVE_STB_FONT
|
||||
#if defined(VITA) || defined(ANDROID) || defined(_WIN32) && !defined(_XBOX)
|
||||
#if defined(VITA) || defined(WIIU) || defined(ANDROID) || defined(_WIN32) && !defined(_XBOX)
|
||||
&stb_unicode_font_renderer,
|
||||
#else
|
||||
&stb_font_renderer,
|
||||
|
@ -5,6 +5,16 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef enum shared_data_type_t
|
||||
{
|
||||
SHARED_FONT_CHINESE,
|
||||
SHARED_FONT_KOREAN,
|
||||
SHARED_FONT_DEFAULT,
|
||||
SHARED_FONT_TAIWAN
|
||||
} shared_data_type_t;
|
||||
|
||||
BOOL OSGetSharedData(shared_data_type_t type, uint32_t flags, void **dst, uint32_t *size);
|
||||
|
||||
void *OSBlockMove(void *dst, const void *src, uint32_t size, BOOL flush);
|
||||
void *OSBlockSet(void *dst, uint8_t val, uint32_t size);
|
||||
uint32_t OSEffectiveToPhysical(void *vaddr);
|
||||
|
@ -29,6 +29,7 @@ IMPORT(OSYieldThread);
|
||||
IMPORT(OSGetSystemTime);
|
||||
IMPORT(OSGetSystemTick);
|
||||
IMPORT(OSGetSymbolName);
|
||||
IMPORT(OSGetSharedData);
|
||||
IMPORT(OSEffectiveToPhysical);
|
||||
|
||||
IMPORT(exit);
|
||||
|
Loading…
x
Reference in New Issue
Block a user