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
|
|
|
|
|
2012-12-14 23:27:30 +00:00
|
|
|
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,
|
2014-10-19 00:19:44 +00:00
|
|
|
#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,
|
2014-02-05 15:30:55 +00:00
|
|
|
NULL
|
2012-12-14 19:26:40 +00:00
|
|
|
};
|
|
|
|
|
2014-09-09 04:59:17 +00:00
|
|
|
bool font_renderer_create_default(
|
2014-10-14 16:28:22 +00:00
|
|
|
const font_renderer_driver_t **drv, void **handle,
|
2014-06-07 19:18:58 +00:00
|
|
|
const char *font_path, unsigned font_size)
|
2012-12-14 19:26:40 +00:00
|
|
|
{
|
2013-10-22 13:08:17 +00:00
|
|
|
unsigned i;
|
2015-01-10 15:46:58 +00:00
|
|
|
|
2014-02-05 15:30:55 +00:00
|
|
|
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;
|
2015-01-10 15:46:58 +00:00
|
|
|
|
2014-06-07 19:27:52 +00:00
|
|
|
if (!path)
|
2014-06-07 19:18:58 +00:00
|
|
|
path = font_backends[i]->get_default_font();
|
|
|
|
if (!path)
|
2012-12-14 19:26:40 +00:00
|
|
|
continue;
|
|
|
|
|
2014-06-07 19:18:58 +00:00
|
|
|
*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);
|
2014-10-14 16:28:22 +00:00
|
|
|
*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
|
|
|
}
|
|
|
|
|
2014-10-14 16:28:22 +00:00
|
|
|
*drv = NULL;
|
2012-12-14 19:26:40 +00:00
|
|
|
*handle = NULL;
|
|
|
|
return false;
|
|
|
|
}
|