ebmDevMag.com home
ebm Developer's Magazine
links

developer's mag
main page

article
part 1
part 2
part 3
part 4
part 5
part 6
part 7
part 8
part 9


7 - Text handling routines

The key to the ResizeText() function is the call used to calculate text length:
  int len=GUI_TruncateText(m_font,m_dispText,m_width,false);
It requires the font pointer, the text string, a size (in pixels), and finally the ellipsis flag. It returns the number of characters that fit in that space. If the ellipsis flag is true, then it also accounts for the width of the three periods that comprise the ellipsis character (however, you have to add the character yourself). In this case, we aren't using it, so the parameter of false is fine.

A couple of other GUI functions for analyzing text are:
  U16 GUI_FontHeight( const FONT *font );
  S32 GUI_TextWidth( const FONT *font, const char *text, S32 length=-1 );
These two and GUI_TruncateText() are generally the most useful. The names explain their purpose, and the return results are in pixels. They can be used to handle string justification, or to break up text into paragraphs, among other things.

Previous Section
Next Section

Copyright © 2001-2006 ebmDevMag.com - Legal Notice