float DrawQ_TextWidth_Font_UntilWidth_TrackColors_Size(const char *text, float w, float h, size_t *maxlen, int *outcolor, qboolean ignorecolorcodes, const dp_font_t *fnt, float maxwidth)
{
+ const char *text_start = text;
int colorindex = STRING_COLOR_DEFAULT;
size_t i;
float x = 0;
int tempcolorindex;
float kx;
int map_index = 0;
+ size_t bytes_left;
ft2_font_map_t *fontmap = NULL;
ft2_font_map_t *map = NULL;
ft2_font_map_t *prevmap = NULL;
// maxwidth /= fnt->scale; // w and h are multiplied by it already
// ftbase_x = snap_to_pixel_x(0);
- for (i = 0;i < *maxlen && *text;)
+ for (i = 0;((bytes_left = *maxlen - (text - text_start)) > 0) && *text;)
{
- nextch = ch = u8_getchar(text, &text);
+ nextch = ch = u8_getnchar(text, &text, bytes_left);
//i = text - text_start;
if (!ch)
break;
ft2_font_t *ft2 = fnt->ft2;
qboolean snap = true;
float pix_x, pix_y;
+ size_t bytes_left;
int tw, th;
tw = R_TextureWidth(fnt->tex);
y += r_textshadow.value * vid.height / vid_conheight.value;
}
*/
- for (i = 0;i < maxlen && *text;)
+ for (i = 0;((bytes_left = maxlen - (text - text_start)) > 0) && *text;)
{
- nextch = ch = u8_getchar(text, &text);
+ nextch = ch = u8_getnchar(text, &text, bytes_left);
//i = text - text_start;
if (!ch)
break;