What are these functions for?

These are for finding the pixel size of strings, and 
trimming a string to a specified pixel size (or less).
There are 2 functions, as follows:

String::FindPixelWidth(%STRING);
String::TrimToPixelWidth(%STRING,%INTEGER)

%STRING is the string you wish to know the size of, or
to trim to the pixel width listed in %INTEGER.  So, the
line:
 
String::FindPixelWidth("Now is the time for all good men...");

would return the value 224, as that is how wide it would
appear inside Tribes when printed to the screen, a HUD,
or whatever.  Next, the line:

String::TrimToPixelWidth("Now is the time for all good men...",200)

will return "Now is the time for all good ", as the next
character, "m" is 10 pixels wide and would bump your 
string up to a total of 201 pixels wide.

My hope is that it can be used to stop HUD's from text
wrapping and therefor scrolling stuff off the bottom of
the HUD.  Very annoying.  With any luck at all, people 
will find lots of other uses for it as well.

Feel free to modify the code if you like, and you know
what you're doing, of course.

If you have questions, I can be contacted through the
scripting forum at PlanetStarSiege, or by email at
stewartd1@home.com.
_______________________________________________________

Required Stuff:
  Presto Pack 0.93+
  Zear's Presto compatible extra string functions
_______________________________________________________

Installation:

Add the following line to your autoexec.cs file.  

Include("GrimJack\\string_lengths.cs");

This function depends on a function written by Zear, namely 
String::Ascii().  So, needless to say, you'll need to have 
Zear's presto compatible string functions installed and 
working as well.  

This also requires the Presto Pack, if only for the 
INCLUDE function.

Other than that, it is currently setup to work from your 
TRIBES\CONFIG\GRIMJACK folder.  Drop both files in there.

______________________________________________________

Bugfixes:

There was a nasty habit of creating an endless loop in the
Trim function, as I didn't check to see if the string that
was submitted was already shorter than the max. :(  So now
the very first thing is a check to see if this is the case,
if so it simply returns the original string, unmodified.

Also, I had the space character - " " incorrectly measured
in the Char_lengths.cs file, so it was tacking on an extra
pixel for each space you had in the string.
______________________________________________________

Known issues:

If I missed a character (rather unlikely) it will count it as
a single pixel wide.  I have run through every character in the
ASCII sequence I could make Tribes print sucessfully, and most
of the ones it won't print properly as well.

I am thinking of checking for a zero length return on a character
and arbitrarily assigning it a value of 8 or so, but I haven't
done it yet.

Have fun with it, folks.

Dave Stewart, aka GrimJack
SQA Engineer
-Will work for bug free code-
stewartd1@home.com