VSGL2 - Very Simple Graphic Library 2  2.0
 All Classes Namespaces Files Functions Variables Macros Pages
Functions
vsgl2::ttf_fonts Namespace Reference

Functions

string load_font (string font, int dim)
 
void draw_text (string font, int dim, string text, int x, int y, Color c)
 Use this function to display a text on the screen with the desired font and dimension. More...
 
int text_width (string font, int dim, string text)
 Use this function to retrieve the width of a string, given the font, the dimension and the text. It can be useful because each character has a different size in general, so it could be very tricky to calculate the actual width of a string. More...
 
int text_height (string font, int dim, string text)
 Use this function to retrieve the height of a string, given the font, the dimension and the text. It can be useful because each character has a different size in general, so it could be very tricky to calculate the actual height of a string. More...
 

Function Documentation

void draw_text ( string  font,
int  dim,
string  text,
int  x,
int  y,
Color  c 
)

Use this function to display a text on the screen with the desired font and dimension.

Parameters
fontThe filename of the font.
dimFont dimension
textThe text to be displayed
xThe x coordinate of the upper left corner of the text inside the window coordinates
yThe y coordinate of the upper left corner of the text inside the window coordinates
cThe color of the text
Warning
The font file have to be visible from the program
string vsgl2::ttf_fonts::load_font ( string  font,
int  dim 
)
int text_height ( string  font,
int  dim,
string  text 
)

Use this function to retrieve the height of a string, given the font, the dimension and the text. It can be useful because each character has a different size in general, so it could be very tricky to calculate the actual height of a string.

Parameters
fontThe filename of the font.
dimFont dimension
textThe string to be displayed
Returns
The height in pixel
int text_width ( string  font,
int  dim,
string  text 
)

Use this function to retrieve the width of a string, given the font, the dimension and the text. It can be useful because each character has a different size in general, so it could be very tricky to calculate the actual width of a string.

Parameters
fontThe filename of the font.
dimFont dimension
textThe string to be displayed
Returns
The width in pixel