Font Functions

1. There is a predefined, tiny, white, variable-width font built-in to the engine. For any of these font functions, use the font handle 0 (zero) to access this font.
  • EnableVariableWidth() Turns variable-width mode on for the specified font.
  • FontHeight() Returns the height of a font
  • FreeFont() Frees a font that you have previously loaded
  • LoadFont() Loads a font from an image file and returns a FONT handle to be used by other font functions..
  • LoadFontEx() Loads a font from an image file and returns a FONT handle to be used by other font functions.. (advanced)
  • PrintCenter() Prints a center-justified string at the specified coordinates.
  • PrintRight() Prints a right-justified string with the rightmost point at the given coordinates.
  • PrintString() Prints a left-justified string at the given coordinates.
  • SetCharacterWidth() Forces a character in the font to be a specific width.
  • TextWidth() Returns the width of a string rendered in a specific font.
  • WrapText() Wraps a string in a certain font to fit a specific width.
  • Talkback

    Post a new comment?

    Talkback #1 written by blues_zodiakos on 2004-06-03.

    To Center some text horizontally on the screen, you can use the following code.
    Example:


    // This will center the text "This is a test" in the exact middle of the screen
    TextCenter( "This is a test", 0, ImageHeight(screen)/2 );

    void TextCenter( string text, int font, int y )
    {
    int x;

    x = TextWidth(text)/2 + ImageWidth(screen)/2;
    PrintString(x, y, screen, font, text);
    }


    [Edit: added pre-tag -Grue]

    Post a new comment?

    Ben McGraw's lovingly crafted this website from scratch for years.
    It's a lot prettier this go around because of Jon Wofford.
    Verge-rpg.com is a member of the lunarnet irc network, and would like to take this opportunity to remind you that regardless how babies taste, it is wrong to eat them.