Text Subsystem



int nasfont_init(void);
Initializes the font system, returns 1 if everything went OK, 0 otherwise. Note: init_nas() calls this for you.

void nasfont_exit(void);
Shuts down the font system Note: nas_exit() calls this for you.

NASFONT_FONT *nasfont_load_font(const char *path, int font_size);
Loads and returns the font specified by path and sets its size through the font_size parameter. Returns NULL on error.  

int nasfont_destroy_font(ALFONT_FONT *fnt);
Destroys a font. Return value is 1 for success 0 on failure or if the font doesn't exist

void nasfont_set_aliased_mode(int mode);
Sets the antialiasing for the text to be drawn. The mode field can be set to one of these defines:

        NASFONT_AA_OFF - No antialiasing
        NASFONT_AA_ON  - Use antialiasing

int nasfont_get_aliased_mode(void);
Returns the current aliased mode.

int nasfont_text_length(ALFONT_FONT *fnt, AL_CONST char *s, int mode);
Returns the length of the string in pixels depending on the mode variable, if text is bold or shadowed, this will affect the length, this function returns the absolute length in pixels.

int nasfont_text_height(ALFONT_FONT *fnt, int mode);
Returns the height of the string in pixels depending on the mode variable, if the text contains special characters or underlining this will affect the height, this function returns the absolute height in pixels.

void nasfont_textout(BITMAP *dest, ALFONT_FONT *f, const char *s, int x, int y, int col);
Draws a text string onto the bitmap left justified.

void nasfont_textout_centre(BITMAP *dest, ALFONT_FONT *f, const char *s, int x, int y, int col);
Draws text centered onto the bitmap.

void nasfont_textout_right(BITMAP *dest, ALFONT_FONT *f, const char *s, int x, int y, int col);
Draws text right justified onto the bitmap.

int nasfont_textout_special_char(BITMAP *bmp, ALFONT_FONT *fnt, AL_CONST char *s, int x, int y, int color, int centre);
Draws a text string onto the bitmap, interpreting the '&' character as an underbar for displaying keyboard shortcuts. Returns the width of the output string in pixels. If centre is true then the text will be drawn centered between the x coordinate.

void nasfont_textout_shadow(BITMAP *bmp, ALFONT_FONT *fnt, AL_CONST char *s, int x, int y, int col[2], int mode);
Draws a text string onto the bitmap using col[0] as the font color and col[1] as the shadow color. This will be the function to use for all procedures.

int nasfont_is_shadowed(int col[2]);
Returns 1 if the text contains a shadow, otherwise 0.

Note: The mode fields used in these functions can be any of these defines and can be OR'ed together:

        NASFONT_NORMAL       - Normal text drawing mode
        NASFONT_LEFT         - Left justified text, same as normal
        NASFONT_CENTERED     - Centered text drawing mode
        NASFONT_RIGHT        - Right justified text drawing mode
        NASFONT_SPECIAL_CHAR - Special character "&&" drawing mode
        NASFONT_UNDERLINE    - Underlined text drawing mode NOT IMPLEMENTED
        NASFONT_BOLD         - Bold text drawing mode
        NASFONT_ITALIC       - Italic text drawing mode NOT IMPLEMENTED
        NASFONT_SHADOW       - Shadowed text drawing mode


Back to Contents