2012-12-14 20:26:40 +01:00
|
|
|
/* RetroArch - A frontend for libretro.
|
2014-01-01 01:50:59 +01:00
|
|
|
* Copyright (C) 2010-2014 - Hans-Kristian Arntzen
|
2015-01-07 18:06:50 +01:00
|
|
|
* Copyright (C) 2011-2015 - Daniel De Matteis
|
2012-12-14 20:26:40 +01: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 23:34:10 +01:00
|
|
|
#include "font_renderer_driver.h"
|
|
|
|
#include "../general.h"
|
2012-12-14 20:26:40 +01:00
|
|
|
|
|
|
|
#ifdef HAVE_CONFIG_H
|
2015-01-12 23:34:10 +01:00
|
|
|
#include "../config.h"
|
2012-12-14 20:26:40 +01:00
|
|
|
#endif
|
|
|
|
|
2012-12-15 00:27:30 +01:00
|
|
|
static const font_renderer_driver_t *font_backends[] = {
|
2012-12-14 20:26:40 +01:00
|
|
|
#ifdef HAVE_FREETYPE
|
2014-10-01 15:51:23 +02:00
|
|
|
&freetype_font_renderer,
|
2014-10-18 20:19:44 -04:00
|
|
|
#endif
|
|
|
|
#ifdef __APPLE__
|
|
|
|
&coretext_font_renderer,
|
2012-12-14 20:26:40 +01:00
|
|
|
#endif
|
2014-06-07 23:40:06 +02:00
|
|
|
&bitmap_font_renderer,
|
2014-02-05 12:30:55 -03:00
|
|
|
NULL
|
2012-12-14 20:26:40 +01:00
|
|
|
};
|
|
|
|
|
2014-09-09 06:59:17 +02:00
|
|
|
bool font_renderer_create_default(
|
2014-10-14 18:28:22 +02:00
|
|
|
const font_renderer_driver_t **drv, void **handle,
|
2014-06-07 21:18:58 +02:00
|
|
|
const char *font_path, unsigned font_size)
|
2012-12-14 20:26:40 +01:00
|
|
|
{
|
2013-10-22 15:08:17 +02:00
|
|
|
unsigned i;
|
2015-01-10 16:46:58 +01:00
|
|
|
|
2014-02-05 12:30:55 -03:00
|
|
|
for (i = 0; font_backends[i]; i++)
|
2012-12-14 20:26:40 +01:00
|
|
|
{
|
2014-06-07 21:27:52 +02:00
|
|
|
const char *path = font_path;
|
2015-01-10 16:46:58 +01:00
|
|
|
|
2014-06-07 21:27:52 +02:00
|
|
|
if (!path)
|
2014-06-07 21:18:58 +02:00
|
|
|
path = font_backends[i]->get_default_font();
|
|
|
|
if (!path)
|
2012-12-14 20:26:40 +01:00
|
|
|
continue;
|
|
|
|
|
2014-06-07 21:18:58 +02:00
|
|
|
*handle = font_backends[i]->init(path, font_size);
|
2012-12-14 20:26:40 +01:00
|
|
|
if (*handle)
|
|
|
|
{
|
2014-09-09 06:59:17 +02:00
|
|
|
RARCH_LOG("Using font rendering backend: %s.\n",
|
|
|
|
font_backends[i]->ident);
|
2014-10-14 18:28:22 +02:00
|
|
|
*drv = font_backends[i];
|
2012-12-14 20:26:40 +01:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else
|
2014-09-09 06:59:17 +02:00
|
|
|
RARCH_ERR("Failed to create rendering backend: %s.\n",
|
|
|
|
font_backends[i]->ident);
|
2012-12-14 20:26:40 +01:00
|
|
|
}
|
|
|
|
|
2014-10-14 18:28:22 +02:00
|
|
|
*drv = NULL;
|
2012-12-14 20:26:40 +01:00
|
|
|
*handle = NULL;
|
|
|
|
return false;
|
|
|
|
}
|