The way i think str_width works (simplified):

function str_width(string, font)
{
while (i < str_len(string) )
{
width += Char_Size[ string[i] ] //Adding the width of each char of the string
i++
}
return width
}

so an internal solution could do the following

Give the number of chars that fit in [max_width]:
function str_widthanything (string, font, max_width)
{
while (width < max_width && i < str_len(string) )
{
width += Char_Size[ string[i] ] //Adding the width of each char of the string
i++
}
return i - 1
}

Adds the sizes of the first [char_num] chars:
function str_widthanything (string, font, char_num)
{
while ( i < char_num )
{
width += Char_Size[ string[i] ] //Adding the width of each char of the string
i++
}
return width
}


So, if str_width works this way - don't u think it would be senseless calling str_width that many times instead of adding two modified versions of it?
Tell me if im wrong...

Last edited by FlorianP; 12/18/08 20:28.

I <3 LINQ