#include <font.h>
Public Types | |
typedef Resource< Font > | Resource |
refcounted resource | |
Public Member Functions | |
Font (const std::string &fontfilename, unsigned ptsize=12, const Color &color=textColor(), unsigned face_index=0) throw (BadFont) | |
Constructor. | |
Font (const unsigned char *buffer, unsigned buf_size, unsigned ptsize=12, const Color &color=textColor(), unsigned face_index=0) throw (BadFont) | |
load a font from memory | |
Font (const Font &f) | |
Copy a Font (inexpensive, fonts are refcounted). | |
Font () | |
Create an invalid Font. | |
Font & | operator= (const Font &f) |
Copy another Font into this one. | |
const Glyph & | getChar (unsigned char c) const |
return surface representation of a char. | |
Surface * | getString (const std::string &txt) const |
return bitmap representation of a string. | |
Surface * | getString (const std::string &, Point &) const |
Get the string blitted to a surface, and the offset from the starting pen position to the upper left hand corner. | |
int | blitString (const std::string &txt, Surface &target, const Point &pos) const |
Draw a string on the surface, with the pen starting at pos. | |
int | blitString (const std::string &txt, Surface &target, const Point &pos, const Region &mask, bool copy=false) const |
Draw a string on the surface, with the pen starting at pos, with a masking region taken relative to the target. | |
Rect | getExtents (const std::string &) const |
Get the area covered by a string, with (0, 0) being the starting pen position. | |
int | getHeight () const |
the font height in pixels | |
const Metrics & | metrics () const |
get the font's metrics | |
bool | valid () const |
Return true if the font is valid. | |
Color | color () const |
Return the foreground color of the font. | |
void | setColor (const Color &) |
Set the color of the font. | |
Static Public Member Functions | |
const Font & | textFont () |
The font specified by the resource "text_font". | |
const Color & | textColor () |
Get the default text color, specified by the resource "text_color". | |
Static Public Attributes | |
ResourceRegistry< Font, ResLoad, ResInval > | registry |
Load font from truetype file and associate with a named resource. | |
Friends | |
class | FontData |
internal type |
This class uses the benefit of truetype fonts (antialiasing, *many* free fonts) as well as the speed gain of surface fonts. When creating an object of Font the surfaces for the characters are all rendered in best quality. When the font-object is asked to create a surface from a string it just blits these character surfaces, which is quite fast.
|
Constructor. fontfilename has to be the name of a truetype font file. The alpha channel of the color is ignored. |
|
return surface representation of a char. if no font is loaded, the surface returned is empty. |
|
return bitmap representation of a string. if no font is loaded, the bitmap returned is empty. |
|
Load font from truetype file and associate with a named resource.
Use the load() function to load a font from a file on disk and register it with wftk's Resources engine. The font specification is a string, formatted thus:
Font::registry.load("button_font", "wf_opal.ttf, 16, 0xF0F0F0"); Use the find() function to retrieve a font. If the named font has not been registered, find() will return the default text font. MultiLineEdit* title = new MultiLineEdit(bg, 50, 10, 400, 70, Font::registry.find("button_font")); |
This document is licensed under the terms of the GNU Free Documentation License and may be freely distributed under the conditions given by this license.