mirror of
https://github.com/libretro/RetroArch
synced 2025-02-22 12:40:09 +00:00
(font_renderer) Cleanups
This commit is contained in:
parent
20b5543420
commit
a153d600e4
@ -54,7 +54,7 @@ static const struct font_glyph *font_renderer_bmp_get_glyph(
|
|||||||
static void char_to_texture(bm_renderer_t *handle, uint8_t letter,
|
static void char_to_texture(bm_renderer_t *handle, uint8_t letter,
|
||||||
unsigned atlas_x, unsigned atlas_y)
|
unsigned atlas_x, unsigned atlas_y)
|
||||||
{
|
{
|
||||||
unsigned y, x, xo, yo;
|
unsigned y, x;
|
||||||
uint8_t *target = handle->atlas.buffer + atlas_x +
|
uint8_t *target = handle->atlas.buffer + atlas_x +
|
||||||
atlas_y * handle->atlas.width;
|
atlas_y * handle->atlas.width;
|
||||||
|
|
||||||
@ -62,6 +62,7 @@ static void char_to_texture(bm_renderer_t *handle, uint8_t letter,
|
|||||||
{
|
{
|
||||||
for (x = 0; x < FONT_WIDTH; x++)
|
for (x = 0; x < FONT_WIDTH; x++)
|
||||||
{
|
{
|
||||||
|
unsigned xo, yo;
|
||||||
unsigned font_pixel = x + y * FONT_WIDTH;
|
unsigned font_pixel = x + y * FONT_WIDTH;
|
||||||
uint8_t rem = 1 << (font_pixel & 7);
|
uint8_t rem = 1 << (font_pixel & 7);
|
||||||
unsigned offset = font_pixel >> 3;
|
unsigned offset = font_pixel >> 3;
|
||||||
@ -99,8 +100,10 @@ static void *font_renderer_bmp_init(const char *font_path, float font_size)
|
|||||||
|
|
||||||
for (i = 0; i < BMP_ATLAS_SIZE; i++)
|
for (i = 0; i < BMP_ATLAS_SIZE; i++)
|
||||||
{
|
{
|
||||||
unsigned x = (i % BMP_ATLAS_COLS) * handle->scale_factor * FONT_WIDTH;
|
unsigned x = (i % BMP_ATLAS_COLS) *
|
||||||
unsigned y = (i / BMP_ATLAS_COLS) * handle->scale_factor * FONT_HEIGHT;
|
handle->scale_factor * FONT_WIDTH;
|
||||||
|
unsigned y = (i / BMP_ATLAS_COLS) *
|
||||||
|
handle->scale_factor * FONT_HEIGHT;
|
||||||
|
|
||||||
char_to_texture(handle, i, x, y);
|
char_to_texture(handle, i, x, y);
|
||||||
|
|
||||||
|
@ -266,6 +266,7 @@ static void *font_renderer_ct_init(const char *font_path, float font_size)
|
|||||||
}
|
}
|
||||||
|
|
||||||
cf_font_path = CFStringCreateWithCString(NULL, font_path, kCFStringEncodingASCII);
|
cf_font_path = CFStringCreateWithCString(NULL, font_path, kCFStringEncodingASCII);
|
||||||
|
|
||||||
if (!cf_font_path)
|
if (!cf_font_path)
|
||||||
{
|
{
|
||||||
err = 1;
|
err = 1;
|
||||||
|
@ -66,8 +66,8 @@ static bool font_renderer_stb_create_atlas(stb_font_renderer_t *self,
|
|||||||
uint8_t *font_data, float font_size, unsigned width, unsigned height)
|
uint8_t *font_data, float font_size, unsigned width, unsigned height)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
stbtt_pack_context pc = {NULL};
|
|
||||||
stbtt_packedchar chardata[256];
|
stbtt_packedchar chardata[256];
|
||||||
|
stbtt_pack_context pc = {NULL};
|
||||||
|
|
||||||
if (width > 2048 || height > 2048)
|
if (width > 2048 || height > 2048)
|
||||||
{
|
{
|
||||||
|
@ -162,10 +162,7 @@ static const struct font_glyph *font_renderer_stb_unicode_get_glyph(
|
|||||||
unsigned id;
|
unsigned id;
|
||||||
stb_unicode_font_renderer_t *self = (stb_unicode_font_renderer_t*)data;
|
stb_unicode_font_renderer_t *self = (stb_unicode_font_renderer_t*)data;
|
||||||
|
|
||||||
if (!self)
|
if(!self || code > 0xFFFF)
|
||||||
return NULL;
|
|
||||||
|
|
||||||
if(code > 0xFFFF)
|
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
id = self->uc_to_id[code];
|
id = self->uc_to_id[code];
|
||||||
@ -176,7 +173,6 @@ static const struct font_glyph *font_renderer_stb_unicode_get_glyph(
|
|||||||
self->last_used[id] = self->usage_counter++;
|
self->last_used[id] = self->usage_counter++;
|
||||||
|
|
||||||
return &self->glyphs[id];
|
return &self->glyphs[id];
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void *font_renderer_stb_unicode_init(const char *font_path, float font_size)
|
static void *font_renderer_stb_unicode_init(const char *font_path, float font_size)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user