diff --git a/gfx/common/metal_common.m b/gfx/common/metal_common.m index 25d3dcd128..5ebaeac1e4 100644 --- a/gfx/common/metal_common.m +++ b/gfx/common/metal_common.m @@ -367,7 +367,7 @@ { float r, g, b, a; int msg_width = - font_driver_get_message_width(NULL, msg, (unsigned)strlen(msg), 1.0f); + font_driver_get_message_width(NULL, msg, strlen(msg), 1.0f); float font_size = settings->floats.video_font_size; unsigned bgcolor_red = settings->uints.video_msg_bgcolor_red; diff --git a/gfx/drivers/gl2.c b/gfx/drivers/gl2.c index beb7c156fa..1dade658a4 100644 --- a/gfx/drivers/gl2.c +++ b/gfx/drivers/gl2.c @@ -2318,7 +2318,7 @@ static void gl2_render_osd_background(gl2_t *gl, const char *msg) settings_t *settings = config_get_ptr(); float video_font_size = settings->floats.video_font_size; int msg_width = - font_driver_get_message_width(NULL, msg, (unsigned)strlen(msg), 1.0f); + font_driver_get_message_width(NULL, msg, strlen(msg), 1.0f); /* shader driver expects vertex coords as 0..1 */ float x = settings->floats.video_msg_pos_x; diff --git a/gfx/drivers_font/caca_font.c b/gfx/drivers_font/caca_font.c index 81920a9862..b800a9bd96 100644 --- a/gfx/drivers_font/caca_font.c +++ b/gfx/drivers_font/caca_font.c @@ -72,7 +72,7 @@ static void caca_font_free(void *data, bool is_threaded) } static int caca_font_get_message_width(void *data, const char *msg, - unsigned msg_len, float scale) + size_t msg_len, float scale) { return 0; } diff --git a/gfx/drivers_font/ctr_font.c b/gfx/drivers_font/ctr_font.c index 8bd6eead65..722bb1f675 100644 --- a/gfx/drivers_font/ctr_font.c +++ b/gfx/drivers_font/ctr_font.c @@ -122,9 +122,9 @@ static void ctr_font_free(void* data, bool is_threaded) } static int ctr_font_get_message_width(void* data, const char* msg, - unsigned msg_len, float scale) + size_t msg_len, float scale) { - unsigned i; + int i; int delta_x = 0; const struct font_glyph* glyph_q = NULL; ctr_font_t* font = (ctr_font_t*)data; @@ -159,7 +159,7 @@ static int ctr_font_get_message_width(void* data, const char* msg, static void ctr_font_render_line( ctr_video_t *ctr, - ctr_font_t* font, const char* msg, unsigned msg_len, + ctr_font_t* font, const char* msg, size_t msg_len, float scale, const unsigned int color, float pos_x, float pos_y, unsigned width, unsigned height, unsigned text_align) @@ -309,7 +309,7 @@ static void ctr_font_render_message( if (!font->font_driver->get_line_metrics || !font->font_driver->get_line_metrics(font->font_data, &line_metrics)) { - unsigned msg_len = strlen(msg); + size_t msg_len = strlen(msg); ctr_font_render_line(ctr, font, msg, msg_len, scale, color, pos_x, pos_y, width, height, text_align); @@ -321,8 +321,8 @@ static void ctr_font_render_message( for (;;) { const char* delim = strchr(msg, '\n'); - unsigned msg_len = delim ? - (unsigned)(delim - msg) : strlen(msg); + size_t msg_len = delim ? + (delim - msg) : strlen(msg); /* Draw the line */ ctr_font_render_line(ctr, font, msg, msg_len, diff --git a/gfx/drivers_font/d3d10_font.c b/gfx/drivers_font/d3d10_font.c index 21d26399a7..b23efd3ca8 100644 --- a/gfx/drivers_font/d3d10_font.c +++ b/gfx/drivers_font/d3d10_font.c @@ -85,9 +85,9 @@ static void d3d10_font_free(void* data, bool is_threaded) free(font); } -static int d3d10_font_get_message_width(void* data, const char* msg, unsigned msg_len, float scale) +static int d3d10_font_get_message_width(void* data, const char* msg, size_t msg_len, float scale) { - unsigned i; + int i; int delta_x = 0; const struct font_glyph* glyph_q = NULL; d3d10_font_t* font = (d3d10_font_t*)data; @@ -122,7 +122,7 @@ static void d3d10_font_render_line( d3d10_video_t *d3d10, d3d10_font_t* font, const char* msg, - unsigned msg_len, + size_t msg_len, float scale, const unsigned int color, float pos_x, @@ -250,7 +250,7 @@ static void d3d10_font_render_message( if (!font->font_driver->get_line_metrics || !font->font_driver->get_line_metrics(font->font_data, &line_metrics)) { - unsigned msg_len = strlen(msg); + size_t msg_len = strlen(msg); if (msg_len <= (unsigned)d3d10->sprites.capacity) d3d10_font_render_line(d3d10, font, msg, msg_len, scale, color, pos_x, pos_y, @@ -263,8 +263,8 @@ static void d3d10_font_render_message( for (;;) { const char* delim = strchr(msg, '\n'); - unsigned msg_len = delim ? - (unsigned)(delim - msg) : strlen(msg); + size_t msg_len = delim ? + (delim - msg) : strlen(msg); /* Draw the line */ if (msg_len <= (unsigned)d3d10->sprites.capacity) diff --git a/gfx/drivers_font/d3d11_font.c b/gfx/drivers_font/d3d11_font.c index 76962cd85b..0bbb3910c6 100644 --- a/gfx/drivers_font/d3d11_font.c +++ b/gfx/drivers_font/d3d11_font.c @@ -83,14 +83,13 @@ static void d3d11_font_free(void* data, bool is_threaded) free(font); } -static int d3d11_font_get_message_width(void* data, const char* msg, unsigned msg_len, float scale) +static int d3d11_font_get_message_width(void* data, const char* msg, size_t msg_len, float scale) { + int i; + int delta_x = 0; const struct font_glyph* glyph_q = NULL; d3d11_font_t* font = (d3d11_font_t*)data; - unsigned i; - int delta_x = 0; - if (!font) return 0; @@ -121,7 +120,7 @@ static void d3d11_font_render_line( d3d11_video_t* d3d11, d3d11_font_t* font, const char* msg, - unsigned msg_len, + size_t msg_len, float scale, const unsigned int color, float pos_x, @@ -130,7 +129,8 @@ static void d3d11_font_render_line( unsigned height, unsigned text_align) { - unsigned i, count; + int i; + unsigned count; D3D11_MAPPED_SUBRESOURCE mapped_vbo; d3d11_sprite_t *v = NULL; const struct font_glyph* glyph_q = NULL; @@ -254,7 +254,7 @@ static void d3d11_font_render_message( if (!font->font_driver->get_line_metrics || !font->font_driver->get_line_metrics(font->font_data, &line_metrics)) { - unsigned msg_len = strlen(msg); + size_t msg_len = strlen(msg); if (msg_len <= (unsigned)d3d11->sprites.capacity) d3d11_font_render_line(d3d11, font, msg, msg_len, scale, color, pos_x, pos_y, @@ -267,8 +267,8 @@ static void d3d11_font_render_message( for (;;) { const char* delim = strchr(msg, '\n'); - unsigned msg_len = delim ? - (unsigned)(delim - msg) : strlen(msg); + size_t msg_len = delim ? + (delim - msg) : strlen(msg); /* Draw the line */ if (msg_len <= (unsigned)d3d11->sprites.capacity) diff --git a/gfx/drivers_font/d3d12_font.c b/gfx/drivers_font/d3d12_font.c index f62a438b05..3a12742749 100644 --- a/gfx/drivers_font/d3d12_font.c +++ b/gfx/drivers_font/d3d12_font.c @@ -85,10 +85,9 @@ static void d3d12_font_free(void* data, bool is_threaded) } static int d3d12_font_get_message_width(void* data, - const char* msg, unsigned msg_len, float scale) + const char* msg, size_t msg_len, float scale) { - unsigned i; - int delta_x = 0; + int i, delta_x = 0; const struct font_glyph* glyph_q = NULL; d3d12_font_t* font = (d3d12_font_t*)data; @@ -122,7 +121,7 @@ static void d3d12_font_render_line( d3d12_video_t *d3d12, d3d12_font_t* font, const char* msg, - unsigned msg_len, + size_t msg_len, float scale, const unsigned int color, float pos_x, @@ -131,8 +130,9 @@ static void d3d12_font_render_line( unsigned height, unsigned text_align) { + int i; D3D12_RANGE range; - unsigned i, count; + unsigned count; const struct font_glyph* glyph_q = NULL; void* mapped_vbo = NULL; d3d12_sprite_t* v = NULL; @@ -256,8 +256,8 @@ static void d3d12_font_render_message( if (!font->font_driver->get_line_metrics || !font->font_driver->get_line_metrics(font->font_data, &line_metrics)) { - unsigned msg_len = strlen(msg); - if (msg_len <= (unsigned)d3d12->sprites.capacity) + size_t msg_len = strlen(msg); + if (msg_len <= d3d12->sprites.capacity) d3d12_font_render_line(d3d12, font, msg, msg_len, scale, color, pos_x, pos_y, width, height, text_align); @@ -269,11 +269,11 @@ static void d3d12_font_render_message( for (;;) { const char* delim = strchr(msg, '\n'); - unsigned msg_len = delim ? - (unsigned)(delim - msg) : strlen(msg); + size_t msg_len = delim ? + (delim - msg) : strlen(msg); /* Draw the line */ - if (msg_len <= (unsigned)d3d12->sprites.capacity) + if (msg_len <= d3d12->sprites.capacity) d3d12_font_render_line(d3d12, font, msg, msg_len, scale, color, pos_x, pos_y - (float)lines * line_height, width, height, text_align); diff --git a/gfx/drivers_font/d3d_w32_font.c b/gfx/drivers_font/d3d_w32_font.c index eb4d9c9c8c..9d50ddd9bd 100644 --- a/gfx/drivers_font/d3d_w32_font.c +++ b/gfx/drivers_font/d3d_w32_font.c @@ -111,7 +111,7 @@ static void d3d_win32_font_free(void *data, bool is_threaded) } static int d3d_win32_font_get_message_width(void* data, const char* msg, - unsigned msg_len, float scale) + size_t msg_len, float scale) { RECT box = {0,0,0,0}; d3dfonts_t *d3dfonts = (d3dfonts_t*)data; @@ -120,7 +120,7 @@ static int d3d_win32_font_get_message_width(void* data, const char* msg, return 0; d3d9x_font_draw_text(d3dfonts->font, NULL, (void*)msg, - msg_len? msg_len : -1, &box, DT_CALCRECT, 0); + msg_len ? msg_len : -1, &box, DT_CALCRECT, 0); return box.right - box.left; } diff --git a/gfx/drivers_font/gdi_font.c b/gfx/drivers_font/gdi_font.c index f7bf98472a..bc25cd7494 100644 --- a/gfx/drivers_font/gdi_font.c +++ b/gfx/drivers_font/gdi_font.c @@ -83,10 +83,11 @@ static void gdi_font_render_msg( const char *msg, const struct font_params *params) { + int i; char* msg_local; + size_t msg_len; float x, y, scale, drop_mod, drop_alpha; - int drop_x, drop_y, msg_strlen; - unsigned i; + int drop_x, drop_y; unsigned new_x, new_y, new_drop_x, new_drop_y; unsigned align; unsigned red, green, blue; @@ -137,9 +138,9 @@ static void gdi_font_render_msg( } msg_local = utf8_to_local_string_alloc(msg); - msg_strlen = strlen(msg_local); + msg_len = strlen(msg_local); - GetTextExtentPoint32(font->gdi->memDC, msg_local, msg_strlen, &text_size); + GetTextExtentPoint32(font->gdi->memDC, msg_local, (int)msg_len, &text_size); switch (align) { diff --git a/gfx/drivers_font/gl1_raster_font.c b/gfx/drivers_font/gl1_raster_font.c index faad0785e0..3c3cd5efe5 100644 --- a/gfx/drivers_font/gl1_raster_font.c +++ b/gfx/drivers_font/gl1_raster_font.c @@ -174,10 +174,10 @@ error: } static int gl1_raster_font_get_message_width(void *data, const char *msg, - unsigned msg_len, float scale) + size_t msg_len, float scale) { const struct font_glyph* glyph_q = NULL; - gl1_raster_t *font = (gl1_raster_t*)data; + gl1_raster_t *font = (gl1_raster_t*)data; const char* msg_end = msg + msg_len; int delta_x = 0; @@ -264,11 +264,11 @@ static void gl1_raster_font_draw_vertices(gl1_raster_t *font, } static void gl1_raster_font_render_line(gl1_t *gl, - gl1_raster_t *font, const char *msg, unsigned msg_len, + gl1_raster_t *font, const char *msg, size_t msg_len, GLfloat scale, const GLfloat color[4], GLfloat pos_x, GLfloat pos_y, unsigned text_align) { - unsigned i; + int i; struct video_coords coords; const struct font_glyph* glyph_q = NULL; GLfloat font_tex_coords[2 * 6 * MAX_MSG_LEN_CHUNK]; @@ -370,8 +370,8 @@ static void gl1_raster_font_render_message( for (;;) { const char *delim = strchr(msg, '\n'); - unsigned msg_len = delim - ? (unsigned)(delim - msg) : (unsigned)strlen(msg); + size_t msg_len = delim + ? (delim - msg) : strlen(msg); /* Draw the line */ gl1_raster_font_render_line(font->gl, font, diff --git a/gfx/drivers_font/gl2_raster_font.c b/gfx/drivers_font/gl2_raster_font.c index 7ff7dfe869..8a54b6ea3e 100644 --- a/gfx/drivers_font/gl2_raster_font.c +++ b/gfx/drivers_font/gl2_raster_font.c @@ -85,7 +85,7 @@ static void gl2_raster_font_free(void *data, static bool gl2_raster_font_upload_atlas(gl2_raster_t *font) { - unsigned i, j; + int i, j; GLint gl_internal = GL_LUMINANCE_ALPHA; GLenum gl_format = GL_LUMINANCE_ALPHA; size_t ncomponents = 2; @@ -178,7 +178,7 @@ error: } static int gl2_raster_font_get_message_width(void *data, const char *msg, - unsigned msg_len, float scale) + size_t msg_len, float scale) { const struct font_glyph* glyph_q = NULL; gl2_raster_t *font = (gl2_raster_t*)data; @@ -230,11 +230,11 @@ static void gl2_raster_font_draw_vertices(gl2_raster_t *font, } static void gl2_raster_font_render_line(gl2_t *gl, - gl2_raster_t *font, const char *msg, unsigned msg_len, + gl2_raster_t *font, const char *msg, size_t msg_len, GLfloat scale, const GLfloat color[4], GLfloat pos_x, GLfloat pos_y, unsigned text_align) { - unsigned i; + int i; struct video_coords coords; const struct font_glyph* glyph_q = NULL; GLfloat font_tex_coords[2 * 6 * MAX_MSG_LEN_CHUNK]; @@ -326,7 +326,7 @@ static void gl2_raster_font_render_message( !font->font_driver->get_line_metrics(font->font_data, &line_metrics)) { gl2_raster_font_render_line(font->gl, font, - msg, (unsigned)strlen(msg), scale, color, pos_x, + msg, strlen(msg), scale, color, pos_x, pos_y, text_align); return; } @@ -336,8 +336,8 @@ static void gl2_raster_font_render_message( for (;;) { const char *delim = strchr(msg, '\n'); - unsigned msg_len = delim - ? (unsigned)(delim - msg) : (unsigned)strlen(msg); + size_t msg_len = delim + ? (delim - msg) : strlen(msg); /* Draw the line */ gl2_raster_font_render_line(font->gl, font, diff --git a/gfx/drivers_font/gl3_raster_font.c b/gfx/drivers_font/gl3_raster_font.c index 70fda7861a..aa8dc6e263 100644 --- a/gfx/drivers_font/gl3_raster_font.c +++ b/gfx/drivers_font/gl3_raster_font.c @@ -137,7 +137,7 @@ error: } static int gl3_raster_font_get_message_width(void *data, const char *msg, - unsigned msg_len, float scale) + size_t msg_len, float scale) { const struct font_glyph* glyph_q = NULL; gl3_raster_t *font = (gl3_raster_t*)data; @@ -208,11 +208,11 @@ static void gl3_raster_font_draw_vertices(gl3_raster_t *font, } static void gl3_raster_font_render_line(gl3_t *gl, - gl3_raster_t *font, const char *msg, unsigned msg_len, + gl3_raster_t *font, const char *msg, size_t msg_len, GLfloat scale, const GLfloat color[4], GLfloat pos_x, GLfloat pos_y, unsigned text_align) { - unsigned i; + int i; struct video_coords coords; const struct font_glyph* glyph_q = NULL; GLfloat font_tex_coords[2 * 6 * MAX_MSG_LEN_CHUNK]; @@ -303,7 +303,7 @@ static void gl3_raster_font_render_message( !font->font_driver->get_line_metrics(font->font_data, &line_metrics)) { gl3_raster_font_render_line(font->gl, font, - msg, (unsigned)strlen(msg), scale, color, pos_x, + msg, strlen(msg), scale, color, pos_x, pos_y, text_align); return; } @@ -313,8 +313,8 @@ static void gl3_raster_font_render_message( for (;;) { const char *delim = strchr(msg, '\n'); - unsigned msg_len = delim - ? (unsigned)(delim - msg) : (unsigned)strlen(msg); + size_t msg_len = delim + ? (delim - msg) : strlen(msg); /* Draw the line */ gl3_raster_font_render_line(font->gl, font, diff --git a/gfx/drivers_font/metal_raster_font.m b/gfx/drivers_font/metal_raster_font.m index 72966ebaf1..dcaf5d3a89 100644 --- a/gfx/drivers_font/metal_raster_font.m +++ b/gfx/drivers_font/metal_raster_font.m @@ -101,11 +101,12 @@ } else { + int i; _buffer = [_context.device newBufferWithLength:(NSUInteger)(_stride * _atlas->height) options:PLATFORM_METAL_RESOURCE_STORAGE_MODE]; void *dst = _buffer.contents; void *src = _atlas->buffer; - for (unsigned i = 0; i < _atlas->height; i++) + for (i = 0; i < _atlas->height; i++) { memcpy(dst, src, _atlas->width); dst += _stride; @@ -242,7 +243,7 @@ static INLINE void write_quad6(SpriteVertex *pv, float tex_x, float tex_y, float tex_width, float tex_height, const vector_float4 *color) { - unsigned i; + int i; static const float strip[2 * 6] = { 0.0f, 0.0f, 0.0f, 1.0f, @@ -526,10 +527,10 @@ static void metal_raster_font_free(void *data, bool is_threaded) } static int metal_raster_font_get_message_width(void *data, const char *msg, - unsigned msg_len, float scale) + size_t msg_len, float scale) { MetalRaster *r = (__bridge MetalRaster *)data; - return [r getWidthForMessage:msg length:msg_len scale:scale]; + return [r getWidthForMessage:msg length:(unsigned)msg_len scale:scale]; } static void metal_raster_font_render_msg( diff --git a/gfx/drivers_font/ps2_font.c b/gfx/drivers_font/ps2_font.c index 5dab64d152..bd30edc5d2 100644 --- a/gfx/drivers_font/ps2_font.c +++ b/gfx/drivers_font/ps2_font.c @@ -104,10 +104,10 @@ static void ps2_font_free(void* data, bool is_threaded) } static int ps2_font_get_message_width(void* data, const char* msg, - unsigned msg_len, float scale) + size_t msg_len, float scale) { + int i; const struct font_glyph* glyph_q = NULL; - unsigned i; int delta_x = 0; ps2_font_t* font = (ps2_font_t*)data; @@ -140,12 +140,12 @@ static int ps2_font_get_message_width(void* data, const char* msg, static void ps2_font_render_line( ps2_video_t *ps2, - ps2_font_t* font, const char* msg, unsigned msg_len, + ps2_font_t* font, const char* msg, size_t msg_len, float scale, const unsigned int color, float pos_x, float pos_y, unsigned width, unsigned height, unsigned text_align) { - unsigned i; + int i; const struct font_glyph* glyph_q = NULL; int x = roundf(pos_x * width); int y = roundf((1.0f - pos_y) * height); @@ -258,8 +258,8 @@ static void ps2_font_render_message( for (;;) { const char* delim = strchr(msg, '\n'); - unsigned msg_len = delim ? - (unsigned)(delim - msg) : strlen(msg); + size_t msg_len = delim ? + (delim - msg) : strlen(msg); /* Draw the line */ ps2_font_render_line(ps2, font, msg, msg_len, diff --git a/gfx/drivers_font/rsx_font.c b/gfx/drivers_font/rsx_font.c index b45befc179..38a807b978 100644 --- a/gfx/drivers_font/rsx_font.c +++ b/gfx/drivers_font/rsx_font.c @@ -201,7 +201,7 @@ error: } static int rsx_font_get_message_width(void *data, const char *msg, - unsigned msg_len, float scale) + size_t msg_len, float scale) { const struct font_glyph* glyph_q = NULL; rsx_font_t *font = (rsx_font_t*)data; @@ -236,7 +236,7 @@ static int rsx_font_get_message_width(void *data, const char *msg, static void rsx_font_draw_vertices(rsx_font_t *font, const video_coords_t *coords) { - unsigned i; + int i; const float *vertex = coords->vertex; const float *tex_coord = coords->tex_coord; const float *color = coords->color; @@ -270,17 +270,17 @@ static void rsx_font_draw_vertices(rsx_font_t *font, } static void rsx_font_render_line( - rsx_font_t *font, const char *msg, unsigned msg_len, + rsx_font_t *font, const char *msg, size_t msg_len, float scale, const float color[4], float pos_x, float pos_y,unsigned text_align) { - unsigned i; + int i; struct video_coords coords; const struct font_glyph* glyph_q = NULL; float font_tex_coords[2 * 6 * MAX_MSG_LEN_CHUNK]; float font_vertex[2 * 6 * MAX_MSG_LEN_CHUNK]; float font_color[4 * 6 * MAX_MSG_LEN_CHUNK]; - rsx_t *rsx = font->rsx; + rsx_t *rsx = font->rsx; const char* msg_end = msg + msg_len; int x = roundf(pos_x * rsx->vp.width); int y = roundf(pos_y * rsx->vp.height); @@ -376,8 +376,8 @@ static void rsx_font_render_message( for (;;) { const char *delim = strchr(msg, '\n'); - unsigned msg_len = delim - ? (unsigned)(delim - msg) : (unsigned)strlen(msg); + size_t msg_len = delim + ? (delim - msg) : strlen(msg); /* Draw the line */ rsx_font_render_line(font, diff --git a/gfx/drivers_font/sixel_font.c b/gfx/drivers_font/sixel_font.c index ff65fd8ff0..8ed902e80c 100644 --- a/gfx/drivers_font/sixel_font.c +++ b/gfx/drivers_font/sixel_font.c @@ -70,7 +70,7 @@ static void sixel_font_free(void *data, bool is_threaded) } static int sixel_font_get_message_width(void *data, const char *msg, - unsigned msg_len, float scale) { return 0; } + size_t msg_len, float scale) { return 0; } static const struct font_glyph *sixel_font_get_glyph( void *data, uint32_t code) { return NULL; } diff --git a/gfx/drivers_font/switch_font.c b/gfx/drivers_font/switch_font.c index 7c03cbd124..3c1187d2a0 100644 --- a/gfx/drivers_font/switch_font.c +++ b/gfx/drivers_font/switch_font.c @@ -75,9 +75,9 @@ static void switch_font_free(void *data, bool is_threaded) } static int switch_font_get_message_width(void *data, const char *msg, - unsigned msg_len, float scale) + size_t msg_len, float scale) { - unsigned i; + int i; const struct font_glyph* glyph_q = NULL; int delta_x = 0; switch_font_t *font = (switch_font_t *)data; @@ -111,11 +111,11 @@ static int switch_font_get_message_width(void *data, const char *msg, static void switch_font_render_line( switch_video_t *sw, - switch_font_t *font, const char *msg, unsigned msg_len, + switch_font_t *font, const char *msg, size_t msg_len, float scale, const unsigned int color, float pos_x, float pos_y, unsigned text_align) { - unsigned i; + int i; const struct font_glyph* glyph_q = NULL; int delta_x = 0; int delta_y = 0; @@ -201,7 +201,7 @@ static void switch_font_render_message( if (!font->font_driver->get_line_metrics || !font->font_driver->get_line_metrics(font->font_data, &line_metrics)) { - int msg_len = strlen(msg); + size_t msg_len = strlen(msg); if (msg_len <= AVG_GLPYH_LIMIT) switch_font_render_line(sw, font, msg, msg_len, scale, color, pos_x, pos_y, text_align); @@ -213,8 +213,8 @@ static void switch_font_render_message( for (;;) { const char *delim = strchr(msg, '\n'); - unsigned msg_len = delim ? - (unsigned)(delim - msg) : strlen(msg); + size_t msg_len = delim ? + (delim - msg) : strlen(msg); /* Draw the line */ if (msg_len <= AVG_GLPYH_LIMIT) diff --git a/gfx/drivers_font/vga_font.c b/gfx/drivers_font/vga_font.c index c7179aa416..e6e2699fdb 100644 --- a/gfx/drivers_font/vga_font.c +++ b/gfx/drivers_font/vga_font.c @@ -72,7 +72,7 @@ static void vga_font_render_free(void *data, bool is_threaded) } static int vga_font_get_message_width(void *data, const char *msg, - unsigned msg_len, float scale) { return 0; } + size_t msg_len, float scale) { return 0; } static const struct font_glyph *vga_font_get_glyph( void *data, uint32_t code) { return NULL; } diff --git a/gfx/drivers_font/vita2d_font.c b/gfx/drivers_font/vita2d_font.c index 519e905499..25dddb0dcb 100644 --- a/gfx/drivers_font/vita2d_font.c +++ b/gfx/drivers_font/vita2d_font.c @@ -107,9 +107,9 @@ static void vita2d_font_free(void *data, bool is_threaded) } static int vita2d_font_get_message_width(void *data, const char *msg, - unsigned msg_len, float scale) + size_t msg_len, float scale) { - unsigned i; + int i; const struct font_glyph* glyph_q = NULL; int delta_x = 0; vita_font_t *font = (vita_font_t*)data; @@ -141,12 +141,12 @@ static int vita2d_font_get_message_width(void *data, const char *msg, } static void vita2d_font_render_line( - vita_font_t *font, const char *msg, unsigned msg_len, + vita_font_t *font, const char *msg, size_t msg_len, float scale, const unsigned int color, float pos_x, float pos_y, unsigned width, unsigned height, unsigned text_align) { - unsigned i; + int i; const struct font_glyph* glyph_q = NULL; int x = roundf(pos_x * width); int y = roundf((1.0f - pos_y) * height); @@ -244,8 +244,8 @@ static void vita2d_font_render_message( for (;;) { const char *delim = strchr(msg, '\n'); - unsigned msg_len = (delim) ? - (unsigned)(delim - msg) : strlen(msg); + size_t msg_len = (delim) ? + (delim - msg) : strlen(msg); /* Draw the line */ vita2d_font_render_line(font, msg, msg_len, diff --git a/gfx/drivers_font/vulkan_raster_font.c b/gfx/drivers_font/vulkan_raster_font.c index 032508f85c..b17d8c08af 100644 --- a/gfx/drivers_font/vulkan_raster_font.c +++ b/gfx/drivers_font/vulkan_raster_font.c @@ -110,7 +110,7 @@ static void *vulkan_font_init(void *data, } static int vulkan_get_message_width(void *data, const char *msg, - unsigned msg_len, float scale) + size_t msg_len, float scale) { const struct font_glyph* glyph_q = NULL; vulkan_raster_t *font = (vulkan_raster_t*)data; @@ -149,7 +149,7 @@ static int vulkan_get_message_width(void *data, const char *msg, } static void vulkan_font_render_line(vk_t *vk, - vulkan_raster_t *font, const char *msg, unsigned msg_len, + vulkan_raster_t *font, const char *msg, size_t msg_len, float scale, const float color[4], float pos_x, float pos_y, unsigned text_align) { @@ -258,8 +258,8 @@ static void vulkan_font_render_message( for (;;) { const char *delim = strchr(msg, '\n'); - unsigned msg_len = delim - ? (unsigned)(delim - msg) : (unsigned)strlen(msg); + size_t msg_len = delim + ? (delim - msg) : strlen(msg); /* Draw the line */ vulkan_font_render_line(font->vk, font, msg, msg_len, diff --git a/gfx/drivers_font/wiiu_font.c b/gfx/drivers_font/wiiu_font.c index a2c06dd3ee..48e57abb63 100644 --- a/gfx/drivers_font/wiiu_font.c +++ b/gfx/drivers_font/wiiu_font.c @@ -112,9 +112,9 @@ static void wiiu_font_free(void* data, bool is_threaded) } static int wiiu_font_get_message_width(void* data, const char* msg, - unsigned msg_len, float scale) + size_t msg_len, float scale) { - unsigned i; + int i; int delta_x = 0; const struct font_glyph* glyph_q = NULL; wiiu_font_t *font = (wiiu_font_t*)data; @@ -148,12 +148,12 @@ static int wiiu_font_get_message_width(void* data, const char* msg, static void wiiu_font_render_line( wiiu_video_t *wiiu, - wiiu_font_t* font, const char* msg, unsigned msg_len, + wiiu_font_t* font, const char* msg, size_t msg_len, float scale, const unsigned int color, float pos_x, float pos_y, unsigned width, unsigned height, unsigned text_align) { - unsigned i; + int i; int count; sprite_vertex_t *v; const struct font_glyph* glyph_q = NULL; @@ -259,7 +259,7 @@ static void wiiu_font_render_message( if (!font->font_driver->get_line_metrics || !font->font_driver->get_line_metrics(font->font_data, &line_metrics)) { - unsigned msg_len = strlen(msg); + size_t msg_len = strlen(msg); if (wiiu->vertex_cache.current + (msg_len * 4) <= wiiu->vertex_cache.size) wiiu_font_render_line(wiiu, font, msg, msg_len, scale, color, pos_x, pos_y, @@ -272,8 +272,8 @@ static void wiiu_font_render_message( for (;;) { const char* delim = strchr(msg, '\n'); - unsigned msg_len = delim ? - (unsigned)(delim - msg) : strlen(msg); + size_t msg_len = delim ? + (delim - msg) : strlen(msg); /* Draw the line */ if (wiiu->vertex_cache.current + (msg_len * 4) <= wiiu->vertex_cache.size) diff --git a/gfx/font_driver.c b/gfx/font_driver.c index e1ebaed204..d451b248cf 100644 --- a/gfx/font_driver.c +++ b/gfx/font_driver.c @@ -1014,7 +1014,7 @@ int font_driver_get_message_width(void *font_data, if (len == 0 && msg) len = strlen(msg); if (font && font->renderer && font->renderer->get_message_width) - return font->renderer->get_message_width(font->renderer_data, msg, (unsigned)len, scale); + return font->renderer->get_message_width(font->renderer_data, msg, len, scale); return -1; } diff --git a/gfx/font_driver.h b/gfx/font_driver.h index 1555efef8b..9c83c322de 100644 --- a/gfx/font_driver.h +++ b/gfx/font_driver.h @@ -106,7 +106,7 @@ typedef struct font_renderer void (*bind_block)(void *data, void *block); void (*flush)(unsigned width, unsigned height, void *data); - int (*get_message_width)(void *data, const char *msg, unsigned msg_len_full, float scale); + int (*get_message_width)(void *data, const char *msg, size_t msg_len, float scale); bool (*get_line_metrics)(void* data, struct font_line_metrics **metrics); } font_renderer_t; diff --git a/gfx/gfx_widgets.c b/gfx/gfx_widgets.c index 96db5a3fc1..68a7cbed82 100644 --- a/gfx/gfx_widgets.c +++ b/gfx/gfx_widgets.c @@ -260,7 +260,7 @@ void gfx_widgets_msg_queue_push( { title = msg_widget->msg = strdup(task->title); msg_widget->msg_new = strdup(title); - msg_widget->msg_len = (unsigned)strlen(title); + msg_widget->msg_len = strlen(title); msg_widget->task_error = !string_is_empty(task->error); msg_widget->task_cancelled = task->cancelled; @@ -286,7 +286,7 @@ void gfx_widgets_msg_queue_push( /* Compute rect width, wrap if necessary */ /* Single line text > two lines text > two lines * text with expanded width */ - unsigned title_length = (unsigned)strlen(title); + size_t title_length = strlen(title); char *msg = NULL; size_t msg_len = 0; unsigned width = menu_is_alive @@ -346,7 +346,8 @@ void gfx_widgets_msg_queue_push( if (!string_is_equal(task->title, msg_widget->msg_new)) { - unsigned len, new_width; + size_t len; + unsigned new_width; if (msg_widget->msg_new) { @@ -356,7 +357,7 @@ void gfx_widgets_msg_queue_push( title = msg_widget->msg_new = strdup(task->title); - len = (unsigned)strlen(title); + len = strlen(title); new_width = font_driver_get_message_width( p_dispwidget->gfx_widget_fonts.msg_queue.font, title, @@ -1110,7 +1111,7 @@ static int gfx_widgets_draw_indicator( width = font_driver_get_message_width( p_dispwidget->gfx_widget_fonts.regular.font, txt, - (unsigned)strlen(txt), 1.0f) + strlen(txt), 1.0f) + p_dispwidget->simple_widget_padding * 2; gfx_display_draw_quad( @@ -1630,7 +1631,7 @@ void gfx_widgets_frame(void *data) int text_width = font_driver_get_message_width( p_dispwidget->gfx_widget_fonts.regular.font, text, - (unsigned)strlen(text), 1.0f); + strlen(text), 1.0f); int total_width = text_width + p_dispwidget->simple_widget_padding * 2; diff --git a/gfx/gfx_widgets.h b/gfx/gfx_widgets.h index 5b3389c076..16223cceee 100644 --- a/gfx/gfx_widgets.h +++ b/gfx/gfx_widgets.h @@ -117,7 +117,7 @@ typedef struct disp_widget_msg retro_task_t *task_ptr; uint32_t task_ident; - unsigned msg_len; + size_t msg_len; unsigned duration; unsigned text_height; unsigned width; diff --git a/gfx/widgets/gfx_widget_generic_message.c b/gfx/widgets/gfx_widget_generic_message.c index 4d674d042c..a4a7890a2a 100644 --- a/gfx/widgets/gfx_widget_generic_message.c +++ b/gfx/widgets/gfx_widget_generic_message.c @@ -178,7 +178,7 @@ void gfx_widget_set_generic_message( /* Get background width */ text_width = font_driver_get_message_width( font_msg_queue->font, state->message, - (unsigned)strlen(state->message), 1.0f); + strlen(state->message), 1.0f); if (text_width < 0) text_width = 0; state->bg_width = (state->text_padding * 2) + (unsigned)text_width; @@ -272,7 +272,7 @@ static void gfx_widget_generic_message_layout( { text_width = font_driver_get_message_width( font_msg_queue->font, state->message, - (unsigned)strlen(state->message), 1.0f); + strlen(state->message), 1.0f); if (text_width < 0) text_width = 0; diff --git a/gfx/widgets/gfx_widget_libretro_message.c b/gfx/widgets/gfx_widget_libretro_message.c index ea11319d34..61440521fc 100644 --- a/gfx/widgets/gfx_widget_libretro_message.c +++ b/gfx/widgets/gfx_widget_libretro_message.c @@ -172,7 +172,7 @@ void gfx_widget_set_libretro_message( state->bg_width = (state->text_padding * 2) + font_driver_get_message_width( font_msg_queue->font, state->message, - (unsigned)strlen(state->message), 1.0f); + strlen(state->message), 1.0f); /* If a 'slide in' animation is already in * progress, no further action is required; @@ -236,7 +236,7 @@ static void gfx_widget_libretro_message_layout( if (!string_is_empty(state->message)) state->bg_width += font_driver_get_message_width( font_msg_queue->font, state->message, - (unsigned)strlen(state->message), 1.0f); + strlen(state->message), 1.0f); } /* Widget iterate() */ diff --git a/gfx/widgets/gfx_widget_load_content_animation.c b/gfx/widgets/gfx_widget_load_content_animation.c index eacc92daf0..f2c07be6a1 100644 --- a/gfx/widgets/gfx_widget_load_content_animation.c +++ b/gfx/widgets/gfx_widget_load_content_animation.c @@ -598,10 +598,10 @@ static void gfx_widget_load_content_animation_iterate(void *user_data, /* Get overall text width */ content_name_width = font_driver_get_message_width( font_bold->font, state->content_name, - (unsigned)strlen(state->content_name), 1.0f); + strlen(state->content_name), 1.0f); system_name_width = font_driver_get_message_width( font_regular->font, state->system_name, - (unsigned)strlen(state->system_name), 1.0f); + strlen(state->system_name), 1.0f); state->content_name_width = (content_name_width > 0) ? (unsigned)content_name_width : 0; diff --git a/gfx/widgets/gfx_widget_progress_message.c b/gfx/widgets/gfx_widget_progress_message.c index 5ee2dae1d2..52f2dddfa9 100644 --- a/gfx/widgets/gfx_widget_progress_message.c +++ b/gfx/widgets/gfx_widget_progress_message.c @@ -151,7 +151,7 @@ void gfx_widget_set_progress_message( state->text_width = font_driver_get_message_width( font_regular->font, state->message, - (unsigned)strlen(state->message), + strlen(state->message), 1.0f); /* Kill any existing timer/animation */ diff --git a/menu/drivers/materialui.c b/menu/drivers/materialui.c index 173dce319b..af6e8d0509 100644 --- a/menu/drivers/materialui.c +++ b/menu/drivers/materialui.c @@ -2665,7 +2665,7 @@ static void materialui_render_messagebox( if (!string_is_empty(line)) { int width = font_driver_get_message_width( - mui->font_data.list.font, line, (unsigned)strlen(line), 1.0f); + mui->font_data.list.font, line, strlen(line), 1.0f); longest_width = (width > longest_width) ? width : longest_width; } @@ -5662,7 +5662,7 @@ static void materialui_render_header( font_driver_get_message_width( mui->font_data.hint.font, mui->sys_bar_cache.battery_percent_str, - (unsigned)strlen(mui->sys_bar_cache.battery_percent_str), + strlen(mui->sys_bar_cache.battery_percent_str), 1.0f); } @@ -5755,7 +5755,7 @@ static void materialui_render_header( = font_driver_get_message_width( mui->font_data.hint.font, mui->sys_bar_cache.timedate_str, - (unsigned)strlen(mui->sys_bar_cache.timedate_str), + strlen(mui->sys_bar_cache.timedate_str), 1.0f); } @@ -7821,7 +7821,7 @@ static void materialui_init_font( if (wideglyph_str) { int wideglyph_width = - font_driver_get_message_width(font_data->font, wideglyph_str, (unsigned)strlen(wideglyph_str), 1.0f); + font_driver_get_message_width(font_data->font, wideglyph_str, strlen(wideglyph_str), 1.0f); if (wideglyph_width > 0 && char_width > 0) font_data->wideglyph_width = wideglyph_width * 100 / char_width; diff --git a/menu/drivers/ozone.c b/menu/drivers/ozone.c index a3afe1d150..89db5dda5c 100644 --- a/menu/drivers/ozone.c +++ b/menu/drivers/ozone.c @@ -5374,7 +5374,7 @@ border_iterate: { /* Note: This entry can never be selected, so ticker_x_offset * is irrelevant here (i.e. this text will never scroll) */ - unsigned text_width = font_driver_get_message_width(ozone->fonts.entries_label.font, rich_label, (unsigned)strlen(rich_label), 1.0f); + unsigned text_width = font_driver_get_message_width(ozone->fonts.entries_label.font, rich_label, strlen(rich_label), 1.0f); x_offset = (video_info_width - (unsigned) ozone->dimensions_sidebar_width - entry_padding * 2) / 2 - text_width / 2 - 60 * scale_factor; @@ -6379,7 +6379,7 @@ static void ozone_draw_osk(ozone_handle_t *ozone, ? 0 : font_driver_get_message_width( ozone->fonts.entries_label.font, msg, - (unsigned)strlen(msg), 1.0f); + strlen(msg), 1.0f); gfx_display_draw_quad( p_disp, userdata, @@ -6491,7 +6491,7 @@ static void ozone_draw_messagebox( if (!string_is_empty(msg)) { int width = font_driver_get_message_width( - ozone->fonts.footer.font, msg, (unsigned)strlen(msg), 1.0f); + ozone->fonts.footer.font, msg, strlen(msg), 1.0f); if (width > longest_width) longest_width = width; @@ -8167,7 +8167,7 @@ static bool ozone_init_font( if (wideglyph_str) { int wideglyph_width = - font_driver_get_message_width(font_data->font, wideglyph_str, (unsigned)strlen(wideglyph_str), 1.0f); + font_driver_get_message_width(font_data->font, wideglyph_str, strlen(wideglyph_str), 1.0f); if (wideglyph_width > 0 && glyph_width > 0) font_data->wideglyph_width = wideglyph_width * 100 / glyph_width; @@ -8185,7 +8185,7 @@ static void ozone_cache_footer_label(ozone_handle_t *ozone, { const char *str = msg_hash_to_str(enum_idx); /* Determine pixel width */ - unsigned length = (unsigned)strlen(str); + size_t length = strlen(str); /* Assign string */ label->str = str; diff --git a/menu/drivers/xmb.c b/menu/drivers/xmb.c index 3db461c1fe..f5702be97a 100644 --- a/menu/drivers/xmb.c +++ b/menu/drivers/xmb.c @@ -1036,7 +1036,7 @@ static void xmb_render_messagebox_internal( if (!string_is_empty(msg)) { int width = font_driver_get_message_width( - xmb->font, msg, (unsigned)strlen(msg), 1); + xmb->font, msg, strlen(msg), 1); if (width > longest_width) longest_width = width; } @@ -5676,7 +5676,7 @@ static void xmb_frame(void *data, video_frame_info_t *video_info) percent_width = (unsigned) font_driver_get_message_width( - xmb->font, msg, (unsigned)strlen(msg), 1); + xmb->font, msg, strlen(msg), 1); xmb_draw_text(xmb_shadows_enable, xmb, settings, msg, video_width - xmb->margins_title_left - x_pos, @@ -6920,7 +6920,7 @@ static void xmb_context_reset_internal(xmb_handle_t *xmb, int char_width = font_driver_get_message_width(xmb->font, "a", 1, 1); int wideglyph_width = - font_driver_get_message_width(xmb->font, wideglyph_str, (unsigned)strlen(wideglyph_str), 1); + font_driver_get_message_width(xmb->font, wideglyph_str, strlen(wideglyph_str), 1); if (wideglyph_width > 0 && char_width > 0) xmb->wideglyph_width = wideglyph_width * 100 / char_width; diff --git a/network/netplay/netplay_frontend.c b/network/netplay/netplay_frontend.c index 697fcbd535..1d49b381e7 100644 --- a/network/netplay/netplay_frontend.c +++ b/network/netplay/netplay_frontend.c @@ -9198,7 +9198,7 @@ static void gfx_widget_netplay_chat_frame(void *data, void *userdata) size_t i; char formatted_nick[NETPLAY_CHAT_MAX_SIZE]; char formatted_msg[NETPLAY_CHAT_MAX_SIZE]; - int formatted_nick_len; + size_t formatted_nick_len; int formatted_nick_width; video_frame_info_t *video_info = (video_frame_info_t*)data; dispgfx_widget_t *p_dispwidget = (dispgfx_widget_t*)userdata; @@ -9222,7 +9222,7 @@ static void gfx_widget_netplay_chat_frame(void *data, void *userdata) continue; /* Truncate the message, if necessary. */ - formatted_nick_len = snprintf(formatted_nick, sizeof(formatted_nick), + formatted_nick_len = (size_t)snprintf(formatted_nick, sizeof(formatted_nick), "%s: ", nick); strlcpy(formatted_msg, msg, sizeof(formatted_msg) - formatted_nick_len); @@ -9299,7 +9299,7 @@ static void gfx_widget_netplay_ping_frame(void *data, void *userdata) if (ping >= 0) { char ping_str[16]; - int ping_len; + size_t ping_len; int ping_width, total_width; video_frame_info_t *video_info = (video_frame_info_t*)data; dispgfx_widget_t *p_dispwidget = (dispgfx_widget_t*)userdata; @@ -9312,7 +9312,8 @@ static void gfx_widget_netplay_ping_frame(void *data, void *userdata) if (ping > 999) ping = 999; - ping_len = snprintf(ping_str, sizeof(ping_str), "PING: %d", ping); + ping_len = (size_t)snprintf(ping_str, + sizeof(ping_str), "PING: %d", ping); ping_width = font_driver_get_message_width( font->font, ping_str, ping_len, 1.0f);