Appendix A: System Routines — Display
445
TI
-
89 / TI
-
92 Plus Developer Guide
Not for Distribution
Beta Version January 26, 2001
sf_width
Declaration:
UCHAR
sf_width
(UCHAR
ch
)
Category(ies):
Display
Description:
Return the width in pixels of a small font character.
Inputs:
ch
— Character to get width of.
Outputs:
Width of given character in the small font.
Assumptions:
Note that the small font (4x6) is the only proportional font; all the other
fonts (large and huge) are fixed width.
Side Effects:
None
Availability:
On AMS 2.00 and higher.
TI
-
89 / TI
-
92 Plus
Plus Differences:
The small font is generally used more on the TI
-
89 than on the TI
-
92 Plus.
It allows for more characters to fit on a line since it is proportional.
See Also: DrawStrWidth, DrawStrWidthP
Example:
The
DrawStrWidth
function uses
sf_width
to compute the width of small
(4x6) font characters.
/* Return the length of the given string in pixels.
For the 8x10/6x8 font this is just 8/6 times the length of the string,
but the 4x6 font is proportional.
*/
WORD DrawStrWidth( const char *Str, BYTE FontType )
{ register BYTE c;
register WORD Width;
switch( FontType ) {
case F_4x6:
Width = 0;
while (c = *Str++)
Width += sf_width (c); /* proportional font */
return Width;
case F_6x8: return (6 * strlen((char *) Str));
case F_8x10: return (strlen(Str) << 3);
}
}