Main Page | Class Hierarchy | Class List | Directories | File List | Class Members | File Members | Related Pages

GFont Class Reference

Font class. Allows you to select a type and measure / draw with it. More...

#include <GFont.h>

Inheritance diagram for GFont:

GTypeFace List of all members.

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.
GFontoperator= (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

Detailed Description

Font class. Allows you to select a type and measure / draw with it.

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:

These functions are designed to be very lightweight, as they are called quite often. The GDisplayString will call these directly but the legecy font API will no longer implement this functionality directly but it will go through the GDisplayString object. All parameters must validated before calling these.


Constructor & Destructor Documentation

GFont::GFont char *  face = 0,
int  point = -1
 

Construct from face/pt size.

Parameters:
face  Font face name
point  Point size of the font


Member Function Documentation

int GFont::CharAt int  x,
char *  Str,
int  Len = -1,
int  TabOffset = 0
 

Gets the number of characters that will fit in 'x' pixels.

Parameters:
x  The maximum width available
Str  The utf-8 string to clip
Len  The length of 'Str' in bytes or -1 for NULL terminated.
TabOffset  The origin of the tab-stops

int GFont::CharAtW int  x,
char16 Str,
int  Len = -1,
int  TabOffset = 0
 

Gets the number of characters that will fit in 'x' pixels.

Parameters:
x  The maximum width available
Str  The wide string to clip
Len  The number of char16's in 'Str' or -1 for NULL terminated.
TabOffset  The origin of the tab-stops

bool GFont::Create char *  Face = 0,
int  PtSize = -1,
int  Param = 0
 

Creates a new font handle with the specified face / pt size.

Parameters:
face  The new font face
height  The pt size
Param  An OS specific parameter. This is typically a Win32 HDC when creating a font for printing.

void GFont::Size int *  x,
int *  y,
char *  Str,
int  Len = -1,
int  Flags = 0
 

Gets the pixel size of a utf-8 string.

Parameters:
x  Returns the width
y  Returns the height
Str  The utf-8 string to measure
Len  The number of bytes in 'Str' or -1 for NULL terminated.
Flags  Unused

void GFont::SizeW int *  x,
int *  y,
char16 Str,
int  Len = -1,
int  Flags = 0
 

Measures a wide character string.

Parameters:
x  Returns the width
y  Returns the height
Str  The wide string to measure
Len  The number of char16's in 'Str' or -1 for NULL terminated.
Flags  Unused

void GFont::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.

Parameters:
pDC  The output surface
x  'x' start point
y  'y' start point
Str  The utf-8 string
Len  Number of bytes in 'Str' or -1 for NULL terminated.
r  An optional clipping rectange. Null if no clipping is desired.
TabOrigin  The origin of the tab-stops

void GFont::TextW GSurface pDC,
int  x,
int  y,
char16 Str,
int  Len = -1,
GRect r = 0,
int  TabOrigin = 0
 

Draws a wide character string.

Parameters:
pDC  The output surface
x  'x' start point
y  'x' start point
Str  The wide string to draw
Len  The number of char16's in 'Str' or -1 for NULL terminated.
r  Optional clipping rectangle.
TabOrigin  The origin of the tab-stops


The documentation for this class was generated from the following files:
Generated on Wed Oct 26 14:46:59 2005 for Lgi by  doxygen 1.4.1