#include <GFont.h>
Inheritance diagram for GFont:
Public Member Functions | |
GFont (char *face=0, int point=-1) | |
Construct from face/pt size. | |
GFont (OsFont Handle) | |
Construct from OS font handle. | |
GFont (GFontType &Type) | |
Construct from type information. | |
GFont (GFont &Fnt) | |
Copy constructor. | |
bool | Create (char *Face=0, int PtSize=-1, int Param=0) |
Creates a new font handle with the specified face / pt size. | |
bool | Create (GFontType *Type, int Param=0) |
Creates a new font from type infomation. | |
OsFont | Handle () |
Returns the OS font handle. | |
GFont & | operator= (GFont &f) |
Copies the font. | |
int | GetHeight () |
Returns the pixel height of the font. | |
int | GetParam () |
Gets the creation parameter passed in (0 by default). | |
void | Text (GSurface *pDC, int x, int y, char *Str, int Len=-1, GRect *r=0, int TabOrigin=0) |
Draws a utf-8 string on a surface. | |
void | Size (int *x, int *y, char *Str, int Len=-1, int Flags=0) |
Gets the pixel size of a utf-8 string. | |
int | X (char *Str, int Len=-1) |
Gets the width of a utf-8 string. | |
int | Y (char *Str, int Len=-1) |
Gets just the height of a utf-8 string. | |
int | CharAt (int x, char *Str, int Len=-1, int TabOffset=0) |
Gets the number of characters that will fit in 'x' pixels. | |
void | TextW (GSurface *pDC, int x, int y, char16 *Str, int Len=-1, GRect *r=0, int TabOrigin=0) |
Draws a wide character string. | |
void | SizeW (int *x, int *y, char16 *Str, int Len=-1, int Flags=0) |
Measures a wide character string. | |
int | XW (char16 *Str, int Len=-1) |
Measures a wide string's width. | |
int | YW (char16 *Str, int Len=-1) |
Measures a wide string's height. | |
int | CharAtW (int x, char16 *Str, int Len=-1, int TabOffset=0) |
Gets the number of characters that will fit in 'x' pixels. | |
Friends | |
class | GFontSystem |
class | GDisplayString |
Font objects can accept string data in either utf-8 or wide unicode characters. The actual size of wide unicode characters varies depending on the platform you're running on. On Windows they are 16-bit ucs-2 characters and on Linux wide characters are utf-32. BeOS tends to use utf-8 natively, but the wide character API is still supported with utf-32 characters.
The text output, measuring and charat functions available from this object will be deprecated at some point and be replace by the GDisplayString object which does a number of layout operations and caches their result. All UI elements should be migrated away from using GFont API calls to using GDisplayString's everywhere they need to measure or display text.
GFont objects keep track of which characters in the unicode range they can display in a glyph map. Each bit in the glyph map represents one unicode code point. If set, then the font can display the character. Not all of the unicode code range is supported by the Font's glyph map for memory conservation reasons. You should not try and access code points above MAX_UNICODE.
When a font can't display a character the GFontSystem object loads in other fonts installed on the system until it finds a font that can display the character. By using a LUT with an entry for each character it can quickly find a font that has a given character. Caching of character runs that can be displayed in with a single font is done by the GDisplayString object.
The core of the font object revolves around:
|
Construct from face/pt size.
|
|
Gets the number of characters that will fit in 'x' pixels.
|
|
Gets the number of characters that will fit in 'x' pixels.
|
|
Creates a new font handle with the specified face / pt size.
|
|
Gets the pixel size of a utf-8 string.
|
|
Measures a wide character string.
|
|
Draws a utf-8 string on a surface.
|
|
Draws a wide character string.
|