Merge pull request #6915 from RobLoach/osd-font

freetype: Allow getting OSD Font from Assets Directory
This commit is contained in:
Twinaphex 2018-06-24 18:13:18 +02:00 committed by GitHub
commit 3bdc7ca352
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -24,6 +24,8 @@
#include <file/file_path.h>
#include <streams/file_stream.h>
#include <retro_miscellaneous.h>
#include <string/stdstring.h>
#include "../../configuration.h"
#ifdef WIIU
#include <wiiu/os.h>
@ -268,6 +270,8 @@ error:
* but should hopefully work ... */
static const char *font_paths[] = {
/* Assets directory OSD Font, @see font_renderer_ft_get_default_font() */
"assets://pkg/osd-font.ttf",
#if defined(_WIN32)
"C:\\Windows\\Fonts\\consola.ttf",
"C:\\Windows\\Fonts\\verdana.ttf",
@ -295,9 +299,18 @@ static const char *font_renderer_ft_get_default_font(void)
return "";
#else
size_t i;
settings_t *settings = config_get_ptr();
char asset_path[PATH_MAX_LENGTH];
for (i = 0; i < ARRAY_SIZE(font_paths); i++)
{
/* Check if we are getting the font from the assets directory. */
if (string_is_equal(font_paths[i], "assets://pkg/osd-font.ttf"))
{
fill_pathname_join(asset_path, settings->paths.directory_assets, "pkg/osd-font.ttf", PATH_MAX_LENGTH);
font_paths[i] = asset_path;
}
if (filestream_exists(font_paths[i]))
return font_paths[i];
}