Code:
int str_widthpart( STRING* str, FONT* font, int len ) {
	STRING* temp="";
	str_cpy(temp, str);
	str_trunc( temp, str_len(str) - len );
	return str_width( temp, font );
}

int str_fit( STRING* str, FONT* font, int width ) {
	STRING* temp="";
	str_cpy(temp, str);
	
	var length=str_width(st, font);
	while( length > width && str_len( temp ) > 0) {
		str_trunc (temp, 1);
		length = str_width( temp, font );
	}
	
	return str_len( temp );
}

I don't have the option to use str_width, so I can't test. But that should work.

Last edited by Joozey; 12/18/08 12:23.

Click and join the 3dgs irc community!
Room: #3dgs