Esempio n. 1
0
static void *font_renderer_ft_init(const char *font_path, float font_size)
{
   FT_Error err;

   ft_font_renderer_t *handle = (ft_font_renderer_t*)
      calloc(1, sizeof(*handle));

   if (!handle)
      goto error;

   err = FT_Init_FreeType(&handle->lib);
   if (err)
      goto error;

   err = FT_New_Face(handle->lib, font_path, 0, &handle->face);
   if (err)
      goto error;

   err = FT_Set_Pixel_Sizes(handle->face, 0, font_size);
   if (err)
      goto error;

   if (!font_renderer_create_atlas(handle))
      goto error;

   return handle;

error:
   font_renderer_ft_free(handle);
   return NULL;
}
Esempio n. 2
0
static void *font_renderer_ft_init(const char *font_path, float font_size)
{
   FT_Error err;

   ft_font_renderer_t *handle = (ft_font_renderer_t*)
      calloc(1, sizeof(*handle));

   if (!handle)
      goto error;

   if (font_size < 1.0)
      goto error;

   err = FT_Init_FreeType(&handle->lib);
   if (err)
      goto error;

#ifdef WIIU
   if(!*font_path)
   {
      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);
   if (err)
      goto error;

   err = FT_Set_Pixel_Sizes(handle->face, 0, font_size);
   if (err)
      goto error;

   if (!font_renderer_create_atlas(handle, font_size))
      goto error;

   return handle;

error:
   font_renderer_ft_free(handle);
   return NULL;
}