(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
|
OBJ += griffin/griffin.o
|
||||||
DEFINES += -DHAVE_GRIFFIN=1 -DHAVE_MENU -DHAVE_RGUI -DHAVE_LIBRETRODB
|
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_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
|
# DEFINES += -DHAVE_XMB -DHAVE_MATERIALUI
|
||||||
else
|
else
|
||||||
HAVE_MENU_COMMON = 1
|
HAVE_MENU_COMMON = 1
|
||||||
|
@ -52,6 +54,8 @@ else
|
||||||
HAVE_ZARCH = 0
|
HAVE_ZARCH = 0
|
||||||
HAVE_MATERIALUI = 0
|
HAVE_MATERIALUI = 0
|
||||||
HAVE_XMB = 0
|
HAVE_XMB = 0
|
||||||
|
HAVE_STB_FONT = 1
|
||||||
|
# HAVE_FREETYPE = 1
|
||||||
|
|
||||||
include Makefile.common
|
include Makefile.common
|
||||||
BLACKLIST :=
|
BLACKLIST :=
|
||||||
|
|
|
@ -24,6 +24,10 @@
|
||||||
#include <file/file_path.h>
|
#include <file/file_path.h>
|
||||||
#include <retro_miscellaneous.h>
|
#include <retro_miscellaneous.h>
|
||||||
|
|
||||||
|
#ifdef WIIU
|
||||||
|
#include <wiiu/os.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#include FT_FREETYPE_H
|
#include FT_FREETYPE_H
|
||||||
#include "../font_driver.h"
|
#include "../font_driver.h"
|
||||||
|
|
||||||
|
@ -217,9 +221,26 @@ static void *font_renderer_ft_init(const char *font_path, float font_size)
|
||||||
if (err)
|
if (err)
|
||||||
goto error;
|
goto error;
|
||||||
|
|
||||||
err = FT_New_Face(handle->lib, font_path, 0, &handle->face);
|
#ifdef WIIU
|
||||||
if (err)
|
if(!*font_path)
|
||||||
goto error;
|
{
|
||||||
|
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);
|
err = FT_Select_Charmap(handle->face, FT_ENCODING_UNICODE);
|
||||||
if (err)
|
if (err)
|
||||||
|
@ -266,6 +287,9 @@ static const char *font_paths[] = {
|
||||||
/* Highly OS/platform dependent. */
|
/* Highly OS/platform dependent. */
|
||||||
static const char *font_renderer_ft_get_default_font(void)
|
static const char *font_renderer_ft_get_default_font(void)
|
||||||
{
|
{
|
||||||
|
#ifdef WIIU
|
||||||
|
return "";
|
||||||
|
#else
|
||||||
size_t i;
|
size_t i;
|
||||||
|
|
||||||
for (i = 0; i < ARRAY_SIZE(font_paths); 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;
|
return NULL;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
static int font_renderer_ft_get_line_height(void* data)
|
static int font_renderer_ft_get_line_height(void* data)
|
||||||
|
|
|
@ -20,6 +20,10 @@
|
||||||
#include <streams/file_stream.h>
|
#include <streams/file_stream.h>
|
||||||
#include <retro_miscellaneous.h>
|
#include <retro_miscellaneous.h>
|
||||||
|
|
||||||
|
#ifdef WIIU
|
||||||
|
#include <wiiu/os.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#include "../font_driver.h"
|
#include "../font_driver.h"
|
||||||
#include "../../verbosity.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 */
|
/* See https://github.com/nothings/stb/blob/master/stb_truetype.h#L539 */
|
||||||
font_size = STBTT_POINT_SIZE(font_size);
|
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))
|
if (!filestream_read_file(font_path, (void**)&self->font_data, NULL))
|
||||||
goto error;
|
goto error;
|
||||||
|
|
||||||
|
@ -245,6 +258,9 @@ error:
|
||||||
|
|
||||||
static const char *font_renderer_stb_unicode_get_default_font(void)
|
static const char *font_renderer_stb_unicode_get_default_font(void)
|
||||||
{
|
{
|
||||||
|
#ifdef WIIU
|
||||||
|
return "";
|
||||||
|
#else
|
||||||
static const char *paths[] = {
|
static const char *paths[] = {
|
||||||
#if defined(_WIN32)
|
#if defined(_WIN32)
|
||||||
"C:\\Windows\\Fonts\\consola.ttf",
|
"C:\\Windows\\Fonts\\consola.ttf",
|
||||||
|
@ -286,6 +302,7 @@ static const char *font_renderer_stb_unicode_get_default_font(void)
|
||||||
return *p;
|
return *p;
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
static int font_renderer_stb_unicode_get_line_height(void* data)
|
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,
|
&coretext_font_renderer,
|
||||||
#endif
|
#endif
|
||||||
#ifdef HAVE_STB_FONT
|
#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,
|
&stb_unicode_font_renderer,
|
||||||
#else
|
#else
|
||||||
&stb_font_renderer,
|
&stb_font_renderer,
|
||||||
|
|
|
@ -5,6 +5,16 @@
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#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 *OSBlockMove(void *dst, const void *src, uint32_t size, BOOL flush);
|
||||||
void *OSBlockSet(void *dst, uint8_t val, uint32_t size);
|
void *OSBlockSet(void *dst, uint8_t val, uint32_t size);
|
||||||
uint32_t OSEffectiveToPhysical(void *vaddr);
|
uint32_t OSEffectiveToPhysical(void *vaddr);
|
||||||
|
|
|
@ -29,6 +29,7 @@ IMPORT(OSYieldThread);
|
||||||
IMPORT(OSGetSystemTime);
|
IMPORT(OSGetSystemTime);
|
||||||
IMPORT(OSGetSystemTick);
|
IMPORT(OSGetSystemTick);
|
||||||
IMPORT(OSGetSymbolName);
|
IMPORT(OSGetSymbolName);
|
||||||
|
IMPORT(OSGetSharedData);
|
||||||
IMPORT(OSEffectiveToPhysical);
|
IMPORT(OSEffectiveToPhysical);
|
||||||
|
|
||||||
IMPORT(exit);
|
IMPORT(exit);
|
||||||
|
|
Loading…
Reference in New Issue