string_width_limit
/*
** Usage:
** string_width_limit(string,width,extension)
**
** Arguments:
** str string to limit
** width width in pixels to constrain the string to
** extension text to append to string if it is cut
**
** Returns:
** the string (including an extension if used)
** that fits within the given width when drawn
**
** GMLscripts.com
*/
{
var str,ext,wid;
str = argument0;
ext = argument2;
wid = max(argument1, string_width(ext));
if (string_width(str) <= wid) return str;
while (string_width(str + ext) > wid) {
str = string_delete(str, string_length(str), 1);
}
return str + ext;
}
** Usage:
** string_width_limit(string,width,extension)
**
** Arguments:
** str string to limit
** width width in pixels to constrain the string to
** extension text to append to string if it is cut
**
** Returns:
** the string (including an extension if used)
** that fits within the given width when drawn
**
** GMLscripts.com
*/
{
var str,ext,wid;
str = argument0;
ext = argument2;
wid = max(argument1, string_width(ext));
if (string_width(str) <= wid) return str;
while (string_width(str + ext) > wid) {
str = string_delete(str, string_length(str), 1);
}
return str + ext;
}
[Please Login]
Projects: 5
Contributors: IceMetalPunk, xot
comments powered by Disqus

Related: