(font_renderer) Cleanups

This commit is contained in:
twinaphex 2017-01-10 21:50:59 +01:00
parent 20b5543420
commit a153d600e4
4 changed files with 52 additions and 52 deletions

View File

@ -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,
unsigned atlas_x, unsigned atlas_y)
{
unsigned y, x, xo, yo;
unsigned y, x;
uint8_t *target = handle->atlas.buffer + atlas_x +
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++)
{
unsigned xo, yo;
unsigned font_pixel = x + y * FONT_WIDTH;
uint8_t rem = 1 << (font_pixel & 7);
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++)
{
unsigned x = (i % BMP_ATLAS_COLS) * handle->scale_factor * FONT_WIDTH;
unsigned y = (i / BMP_ATLAS_COLS) * handle->scale_factor * FONT_HEIGHT;
unsigned x = (i % BMP_ATLAS_COLS) *
handle->scale_factor * FONT_WIDTH;
unsigned y = (i / BMP_ATLAS_COLS) *
handle->scale_factor * FONT_HEIGHT;
char_to_texture(handle, i, x, y);

View File

@ -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);
if (!cf_font_path)
{
err = 1;

View File

@ -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)
{
int i;
stbtt_pack_context pc = {NULL};
stbtt_packedchar chardata[256];
stbtt_pack_context pc = {NULL};
if (width > 2048 || height > 2048)
{

View File

@ -162,10 +162,7 @@ static const struct font_glyph *font_renderer_stb_unicode_get_glyph(
unsigned id;
stb_unicode_font_renderer_t *self = (stb_unicode_font_renderer_t*)data;
if (!self)
return NULL;
if(code > 0xFFFF)
if(!self || code > 0xFFFF)
return NULL;
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++;
return &self->glyphs[id];
}
static void *font_renderer_stb_unicode_init(const char *font_path, float font_size)