Fonts
A Font is a collection of images that can be used to represent text on a screen.
There are various font classes that you can use, each with it's own advantages and disadvantages
The Default Font (provided by
The Native Font (provided by
The Freetype Font (provided by
The texture font (provided by
The vector font (provided by
Constructing fonts
All fonts use a common font description class
CL_FontDescription desc;
font_desc.set_typeface_name("tahoma");
CL_Font_Native native_font(gc, font_desc);
native_font.draw_text(gc, 100, 100, "Hello World");
CL_FontDescription desc;
font_desc.set_typeface_name("myfont.ttf");
CL_Font_Freetype freetype_font(font_desc);
freetype_font.draw_text(gc, 100, 100, "Hello World");
// To use a native font as CL_Textures's
CL_FontDescription desc;
font_desc.set_typeface_name("tahoma");
CL_Font_Texture texture_font(gc, font_desc);
texture_font.draw_text(gc, 100, 100, "Hello World");
// To use a font from a png
CL_FontDescription desc;
font_desc.set_typeface_name("tahoma");
CL_Font_Texture texture_font(gc, &pixel_buffer_font, font_positions);
texture_font.load_font(gc, font_desc); // Use tahoma for unknown glyphs
texture_font.draw_text(gc, 100, 100, "Hello World");
CL_FontDescription desc;
font_desc.set_typeface_name("myfont.ttf");
CL_Font_Vector vector_font(font_desc);
vector_font.draw_text(gc, 100, 100, "Hello World");
ClanGUI and Fonts
If you want ClanGUI to use a custom font, instead of a native font, you will first need to register the font as follows
CL_FontDescription font_desc;
font_desc.set_typeface_name("GUI Font Name");
font_desc.set_height(-21);
font_desc.set_weight(700);
CL_Font_Texture font_texture(gc, font_desc);
font_desc.set_typeface_name("Custom Font Name (usually the same)");
gui->set_named_font(font_texture, font_desc);
