RetroArch/gfx/font_renderer_driver.c

67 lines
1.8 KiB
C
Raw Normal View History

2012-12-14 19:26:40 +00:00
/* RetroArch - A frontend for libretro.
2014-01-01 00:50:59 +00:00
* Copyright (C) 2010-2014 - Hans-Kristian Arntzen
2015-01-07 17:06:50 +00:00
* Copyright (C) 2011-2015 - Daniel De Matteis
2012-12-14 19:26:40 +00:00
*
* RetroArch is free software: you can redistribute it and/or modify it under the terms
* of the GNU General Public License as published by the Free Software Found-
* ation, either version 3 of the License, or (at your option) any later version.
*
* RetroArch is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with RetroArch.
* If not, see <http://www.gnu.org/licenses/>.
*/
2015-01-12 22:34:10 +00:00
#include "font_renderer_driver.h"
#include "../general.h"
2012-12-14 19:26:40 +00:00
#ifdef HAVE_CONFIG_H
2015-01-12 22:34:10 +00:00
#include "../config.h"
2012-12-14 19:26:40 +00:00
#endif
static const font_renderer_driver_t *font_backends[] = {
2012-12-14 19:26:40 +00:00
#ifdef HAVE_FREETYPE
2014-10-01 13:51:23 +00:00
&freetype_font_renderer,
#endif
#ifdef __APPLE__
&coretext_font_renderer,
2012-12-14 19:26:40 +00:00
#endif
2014-06-07 21:40:06 +00:00
&bitmap_font_renderer,
NULL
2012-12-14 19:26:40 +00:00
};
2014-09-09 04:59:17 +00:00
bool font_renderer_create_default(
const font_renderer_driver_t **drv, void **handle,
const char *font_path, unsigned font_size)
2012-12-14 19:26:40 +00:00
{
unsigned i;
for (i = 0; font_backends[i]; i++)
2012-12-14 19:26:40 +00:00
{
2014-06-07 19:27:52 +00:00
const char *path = font_path;
2014-06-07 19:27:52 +00:00
if (!path)
path = font_backends[i]->get_default_font();
if (!path)
2012-12-14 19:26:40 +00:00
continue;
*handle = font_backends[i]->init(path, font_size);
2012-12-14 19:26:40 +00:00
if (*handle)
{
2014-09-09 04:59:17 +00:00
RARCH_LOG("Using font rendering backend: %s.\n",
font_backends[i]->ident);
*drv = font_backends[i];
2012-12-14 19:26:40 +00:00
return true;
}
else
2014-09-09 04:59:17 +00:00
RARCH_ERR("Failed to create rendering backend: %s.\n",
font_backends[i]->ident);
2012-12-14 19:26:40 +00:00
}
*drv = NULL;
2012-12-14 19:26:40 +00:00
*handle = NULL;
return false;
}