Pyro higlevel API
Public Types | Public Member Functions | Static Public Member Functions | Friends | List of all members

Text Font class. More...

Inheritance diagram for os::Font:
os::Flattenable

Public Types

typedef std::vector< float > size_list_t
 

Public Member Functions

 Font ()
 Default Constructor... More...
 
 Font (const Font &font)
 Constructor... More...
 
 Font (const font_properties &sProps)
 Constructor... More...
 
 Font (const String &cConfigName)
 Constructor... More...
 
void AddRef ()
 Adds a reference counter. More...
 
void Release ()
 Releases all instances of a Font. More...
 
status_t SetProperties (const font_properties &sProps)
 Sets the properties of the Font. More...
 
status_t SetProperties (const String &cConfigName)
 Sets the properties of the Font. More...
 
status_t SetProperties (float vSize, float vShear=0.0f, float vRotation=0.0f)
 Sets the properties of the Font. More...
 
status_t SetFamilyAndStyle (const char *pzFamily, const char *pzStyle)
 Sets the family and style of the Font. More...
 
void SetSize (float vSize)
 Sets the size... More...
 
void SetShear (float vShear)
 Sets the shear. More...
 
void SetRotation (float vRotation)
 Sets the rotation... More...
 
void SetSpacing (int nSpacing)
 Sets the spacing of a font. More...
 
void SetEncoding (int nEncoding)
 Sets the encoding of the Font. More...
 
void SetFace (uint16 nFace)
 Sets the face of the Font. More...
 
void SetFlags (uint32 nFlags)
 Sets the flags for the Font. More...
 
String GetStyle () const
 Gets the Style of the Font... More...
 
String GetFamily () const
 Gets the family of the Font... More...
 
float GetSize () const
 Gets the size of the Font... More...
 
float GetShear () const
 Gets the shear of the Font. More...
 
float GetRotation () const
 Gets the rotation of the Font. More...
 
int GetSpacing () const
 Gets the spacing of the Font. More...
 
int GetEncoding () const
 Gets the encoding of the Font. More...
 
uint32 GetFlags () const
 Gets the flags passed to the font. More...
 
font_direction GetDirection () const
 Gets the direction of the Font. More...
 
void GetTruncatedStrings (const char *stringArray[], int32 numStrings, uint32 mode, float width, char *resultArray[]) const
 Get truncated strings. More...
 
float GetStringWidth (const char *pzString, int nLength=-1) const
 Gets the strings width.... More...
 
float GetStringWidth (const String &cString) const
 Gets the strings width... More...
 
void GetStringWidths (const char **apzStringArray, const int *anLengthArray, int nStringCount, float *avWidthArray) const
 Gets multiple string widths. More...
 
Point GetTextExtent (const char *pzString, int nLength=-1, uint32 nFlags=0, int nTargetWidth=-1) const
 
Point GetTextExtent (const String &cString, uint32 nFlags=0, int nTargetWidth=-1) const
 
void GetTextExtents (const char **apzStringArray, const int *anLengthArray, int nStringCount, Point *acExtentArray, uint32 nFlags, int nTargetWidth=-1) const
 
int GetStringLength (const char *pzString, float vWidth, bool bIncludeLast=false) const
 Gets the length of a string. More...
 
int GetStringLength (const char *pzString, int nLength, float vWidth, bool bIncludeLast=false) const
 Gets the length of a string. More...
 
int GetStringLength (const String &cString, float vWidth, bool bIncludeLast=false) const
 Gets the length of a string. More...
 
void GetStringLengths (const char **apzStringArray, const int *anLengthArray, int nStringCount, float vWidth, int anMaxLengthArray[], bool bIncludeLast=false) const
 Gets the lengths of multiple strings. More...
 
void GetHeight (font_height *psHeight) const
 Gets the height of the Font. More...
 
std::vector< uint32 > GetSupportedCharacters () const
 Gets the supported characters of the Font. More...
 
int GetFontID (void) const
 Gets the Font handle ID. More...
 
bool operator== (const Font &cOther)
 
bool operator!= (const Font &cOther)
 
Fontoperator= (const Font &cOther)
 
virtual size_t GetFlattenedSize (void) const
 
virtual status_t Flatten (uint8 *pBuffer, size_t nSize) const
 
virtual status_t Unflatten (const uint8 *pBuffer)
 
virtual int GetType (void) const
 
- Public Member Functions inherited from os::Flattenable
virtual bool TypeIsCompatible (int nType) const
 

Static Public Member Functions

static status_t GetConfigNames (std::vector< String > *pcTable)
 Get a list of default font names. More...
 
static status_t GetDefaultFont (const String &cName, font_properties *psProps)
 Get the properties of a default font. More...
 
static status_t SetDefaultFont (const String &cName, const font_properties &sProps)
 Set the properties of a default font. More...
 
static status_t AddDefaultFont (const String &cName, const font_properties &sProps)
 Add a default font, or modify one if it already exists. More...
 
static int GetFamilyCount ()
 Get number of installed Font families. More...
 
static status_t GetFamilyInfo (int nIndex, char *pzFamily)
 Get the name of a given font family. More...
 
static int GetStyleCount (const char *pzFamily)
 Get number of styles in a given family. More...
 
static status_t GetStyleInfo (const char *pzFamily, int nIndex, char *pzStyle, uint32 *pnFlags=NULL)
 Get info about a given font style. More...
 
static status_t GetBitmapSizes (const String &cFamily, const String &cStyle, size_list_t *pcList)
 
static bool Rescan ()
 Scans for new fonts... More...
 

Friends

class View
 

Detailed Description

Description:
The os::View class needs a text font to be able to render text. The Font class represents all the properties of the text like width and height of each glyph, rotation/shearing of the glyps and most importantly the actual graphical "image" of each glyph.

Font objects are reference counted to ease sharing between views. If the same font is set on two views they will both be affected by subsequent changes to the font.

A Font keeps track of all view's it has been added to so it can notify them whenever one of the properties of the Font changes.

Syllable primarily uses scalable TrueType Fonts but can also use various bitmap Fonts. When using TrueType Font's the glyphs will be scaled to the requested point-size, but when using bitmap Fonts the size will be "snapped" to the closest size supported by the Font.

When rendering TrueType Fonts, the glyphs have the ability to be antialiazed to improve the quality of the fonts. The view can either antialiaze against a fixed background color to maximize speed or against the background it is actually rendered at.

See Also
os::Flattenable
Author
Kurt Skauen (kurt@.nosp@m.athe.nosp@m.os.cx) with modifications by the Syllable team.

Member Typedef Documentation

typedef std::vector<float> os::Font::size_list_t

Constructor & Destructor Documentation

Font::Font ( )
Description:
The Default Constructor will get all of its properties as it gets used,
Author
Kurt Skauen (kurt@.nosp@m.athe.nosp@m.os.cx) and Rick Caudill(sylla.nosp@m.ble_.nosp@m.deskt.nosp@m.op@h.nosp@m.otpop.nosp@m..com)
Font::Font ( const Font font)
Font::Font ( const font_properties sProps)
Description:
This constructor will get all of its major properties from the font_properties that you passed to it.
Author
Kurt Skauen (kurt@.nosp@m.athe.nosp@m.os.cx) and Rick Caudill(sylla.nosp@m.ble_.nosp@m.deskt.nosp@m.op@h.nosp@m.otpop.nosp@m..com)

References SetProperties().

Font::Font ( const String cConfigName)
Description:
This constructor will pull all of its major properties from the os::String you passed to it. The os::String should be a valid Font Config Name.
Author
Kurt Skauen (kurt@.nosp@m.athe.nosp@m.os.cx) and Rick Caudill(sylla.nosp@m.ble_.nosp@m.deskt.nosp@m.op@h.nosp@m.otpop.nosp@m..com)

References os::String::c_str(), GetDefaultFont(), os::font_properties::m_cFamily, os::font_properties::m_cStyle, SetFamilyAndStyle(), and SetProperties().

Member Function Documentation

status_t Font::AddDefaultFont ( const String cName,
const font_properties sProps 
)
static
Description:
Note:
Warning:
Parameters
\return
See Also
Author
Kurt Skauen (kurt@.nosp@m.athe.nosp@m.os.cx)

References os::Application::GetInstance().

void Font::AddRef ( void  )
Description:
Adds a reference counter. Please call this method after calling a constructor.
See Also
Release()
Author

Referenced by os::View::SetFont().

status_t Font::Flatten ( uint8 *  pBuffer,
size_t  nSize 
) const
virtual
status_t Font::GetBitmapSizes ( const String cFamily,
const String cStyle,
Font::size_list_t pcList 
)
static
status_t Font::GetConfigNames ( std::vector< String > *  pcTable)
static
Description:
This method will give you a list of all the default font names.
Parameters
pcTable- A vector pointer of os::String's to return all the config names in.
Returns
See Also
Author
Kurt Skauen (kurt@.nosp@m.athe.nosp@m.os.cx)

References os::Application::GetInstance().

status_t Font::GetDefaultFont ( const String cName,
font_properties psProps 
)
static
Description:
Gets the properties of the default font.
Parameters
cName- Name of the default fFont.
psProps- font_propties pointer which will contain the properties of the default Font.
Returns
See Also
Author
Kurt Skauen (kurt@.nosp@m.athe.nosp@m.os.cx)

References os::Application::GetInstance().

Referenced by Font(), and SetProperties().

font_direction Font::GetDirection ( ) const
Description:
Right now this function will always return FONT_LEFT_TO_RIGHT.
See Also
SetDirection()
Author
Kurt Skauen (kurt@.nosp@m.athe.nosp@m.os.cx) and Rick Caudill(sylla.nosp@m.ble_.nosp@m.deskt.nosp@m.op@h.nosp@m.otpop.nosp@m..com)

References os::FONT_LEFT_TO_RIGHT.

int Font::GetEncoding ( ) const
Description:
This method returns the encoding of the Font.
See Also
SetEncoding()
Author
Kurt Skauen (kurt@.nosp@m.athe.nosp@m.os.cx) and Rick Caudill(sylla.nosp@m.ble_.nosp@m.deskt.nosp@m.op@h.nosp@m.otpop.nosp@m..com)
String Font::GetFamily ( ) const
Description:
This returns the family of the Font(IE: Arial, Sans Serif...)
See Also
SetFamilyAndStyle()
Author
Kurt Skauen (kurt@.nosp@m.athe.nosp@m.os.cx) and Rick Caudill(sylla.nosp@m.ble_.nosp@m.deskt.nosp@m.op@h.nosp@m.otpop.nosp@m..com)

References os::font_properties::m_cFamily.

int Font::GetFamilyCount ( )
static
Description:
Returns the number of Font families
Parameters
\return
See Also
Author
Kurt Skauen (kurt@.nosp@m.athe.nosp@m.os.cx)

References os::Application::GetInstance().

status_t Font::GetFamilyInfo ( int  nIndex,
char *  pzFamily 
)
static
Description:
Note:
Warning:
Parameters
\return
See Also
Author
Kurt Skauen (kurt@.nosp@m.athe.nosp@m.os.cx)

References os::Application::GetInstance().

uint32 Font::GetFlags ( ) const
Description:
This method will get all the flags that have been passed to the Font
See Also
SetFlags()
Author
Kurt Skauen (kurt@.nosp@m.athe.nosp@m.os.cx) and Rick Caudill(sylla.nosp@m.ble_.nosp@m.deskt.nosp@m.op@h.nosp@m.otpop.nosp@m..com)

References os::font_properties::m_nFlags.

size_t Font::GetFlattenedSize ( void  ) const
virtual

Implements os::Flattenable.

int os::Font::GetFontID ( void  ) const
inline
Description:
Gets the Font handle ID.
See Also
Author
Kurt Skauen (kurt@.nosp@m.athe.nosp@m.os.cx)

Referenced by os::View::SetFont().

void os::Font::GetHeight ( font_height psHeight) const
inline
Description:
Gets the height of the Font.
Parameters
psHeight- a font_height pointer which will contain the height of the Font.
See Also
Author
Kurt Skauen (kurt@.nosp@m.athe.nosp@m.os.cx)

Referenced by os::View::GetFontHeight(), and os::TableView::Paint().

float Font::GetRotation ( ) const
Description:
This method returns the rotation of the Font.
See Also
SetRotation()
Author
Kurt Skauen (kurt@.nosp@m.athe.nosp@m.os.cx) and Rick Caudill(sylla.nosp@m.ble_.nosp@m.deskt.nosp@m.op@h.nosp@m.otpop.nosp@m..com)

References os::font_properties::m_vRotation.

float Font::GetShear ( ) const
Description:
This method returns the shear of the Font.
See Also
SetShear()
Author
Kurt Skauen (kurt@.nosp@m.athe.nosp@m.os.cx) and Rick Caudill(sylla.nosp@m.ble_.nosp@m.deskt.nosp@m.op@h.nosp@m.otpop.nosp@m..com)

References os::font_properties::m_vShear.

float Font::GetSize ( ) const
Description:
This method returns the size of the Font.
See Also
SetSize()
Author
Kurt Skauen (kurt@.nosp@m.athe.nosp@m.os.cx) and Rick Caudill(sylla.nosp@m.ble_.nosp@m.deskt.nosp@m.op@h.nosp@m.otpop.nosp@m..com)

References os::font_properties::m_vSize.

Referenced by SplashView::GetPreferredSize(), and SplashView::SplashView().

int Font::GetSpacing ( ) const
Description:
This method returns the spacing of the Font. This always returns 0 right now.
See Also
SetSpacing()
Author
Kurt Skauen (kurt@.nosp@m.athe.nosp@m.os.cx) and Rick Caudill(sylla.nosp@m.ble_.nosp@m.deskt.nosp@m.op@h.nosp@m.otpop.nosp@m..com)
int Font::GetStringLength ( const char *  pzString,
float  vWidth,
bool  bIncludeLast = false 
) const
Description:
Gets the length of a string.
See Also
Author
Kurt Skauen (kurt@.nosp@m.athe.nosp@m.os.cx)

Referenced by os::View::GetStringLength().

int Font::GetStringLength ( const char *  pzString,
int  nLength,
float  vWidth,
bool  bIncludeLast = false 
) const
Description:
Gets the length of a string.
See Also
Author
Kurt Skauen (kurt@.nosp@m.athe.nosp@m.os.cx)

References GetStringLengths().

int Font::GetStringLength ( const String cString,
float  vWidth,
bool  bIncludeLast = false 
) const
Description:
Gets the length of a string.
See Also
Author
Kurt Skauen (kurt@.nosp@m.athe.nosp@m.os.cx)

References os::String::c_str(), GetStringLengths(), and os::String::size().

void Font::GetStringLengths ( const char **  apzStringArray,
const int *  anLengthArray,
int  nStringCount,
float  vWidth,
int  anMaxLengthArray[],
bool  bIncludeLast = false 
) const
Description:
Gets the lengths of multiple strings.
See Also
Author
Kurt Skauen (kurt@.nosp@m.athe.nosp@m.os.cx)

References os::Application::GetInstance().

Referenced by GetStringLength(), and os::View::GetStringLengths().

float Font::GetStringWidth ( const char *  pzString,
int  nLength = -1 
) const
Description:
Gets the strings width.
See Also
Author
Kurt Skauen (kurt@.nosp@m.athe.nosp@m.os.cx)

References GetStringWidths().

Referenced by os::View::GetStringWidth(), GetStringWidth(), and os::TableView::Paint().

float Font::GetStringWidth ( const String cString) const
Description:
Gets the strings width.
See Also
Author
Kurt Skauen

References os::String::c_str(), GetStringWidth(), and os::String::size().

void Font::GetStringWidths ( const char **  apzStringArray,
const int *  anLengthArray,
int  nStringCount,
float *  avWidthArray 
) const
Description:
Gets mulitple string widths.
See Also
Author
Kurt Skauen (kurt@.nosp@m.athe.nosp@m.os.cx)

References os::Application::GetInstance().

Referenced by GetStringWidth(), and os::View::GetStringWidths().

String Font::GetStyle ( ) const
Description:
This returns the name of the style(ie: Regular, Bold,...)
See Also
SetFamilyAndStyle()
Author
Kurt Skauen (kurt@.nosp@m.athe.nosp@m.os.cx) and Rick Caudill(sylla.nosp@m.ble_.nosp@m.deskt.nosp@m.op@h.nosp@m.otpop.nosp@m..com)

References os::font_properties::m_cStyle.

int Font::GetStyleCount ( const char *  pzFamily)
static
Description:
Returns the number of styles in the family
Parameters
pzFamily- The family.
Returns
The number of styles.
Author
Kurt Skauen (kurt@.nosp@m.athe.nosp@m.os.cx)

References os::Application::GetInstance().

status_t Font::GetStyleInfo ( const char *  pzFamily,
int  nIndex,
char *  pzStyle,
uint32 *  pnFlags = NULL 
)
static
Description:
Get all the information about the Font.
Parameters
pzFamily- The family of the Font.
nIndex- The index of the family.
pzStyle- The style of the Font.
pnFlags- The flags of the Font.
Returns
See Also
Author
Kurt Skauen (kurt@.nosp@m.athe.nosp@m.os.cx)

References os::Application::GetInstance().

std::vector< uint32 > Font::GetSupportedCharacters ( ) const
Description:
Returns a vector of the supported characters that the Font can use.
See Also
Author
Henrik Isaksason

References os::Message::AddInt32(), os::Message::FindBool(), os::Message::FindInt(), os::Message::FindInt32(), os::Application::GetAppPort(), os::Application::GetInstance(), and os::Messenger::SendMessage().

Point Font::GetTextExtent ( const char *  pzString,
int  nLength = -1,
uint32  nFlags = 0,
int  nTargetWidth = -1 
) const
Description:
See Also
Author

References GetTextExtents().

Referenced by os::View::GetTextExtent(), and GetTextExtent().

Point Font::GetTextExtent ( const String cString,
uint32  nFlags = 0,
int  nTargetWidth = -1 
) const
Description:
See Also
Author

References os::String::c_str(), GetTextExtent(), and os::String::size().

void Font::GetTextExtents ( const char **  apzStringArray,
const int *  anLengthArray,
int  nStringCount,
Point acExtentArray,
uint32  nFlags,
int  nTargetWidth = -1 
) const
Description:
See Also
Author

References os::Application::GetInstance().

Referenced by GetTextExtent().

void os::Font::GetTruncatedStrings ( const char *  stringArray[],
int32  numStrings,
uint32  mode,
float  width,
char *  resultArray[] 
) const
Description:
See Also
Author
Kurt Skauen (kurt@.nosp@m.athe.nosp@m.os.cx)
virtual int os::Font::GetType ( void  ) const
inlinevirtual

Implements os::Flattenable.

References os::T_FONT.

bool Font::operator!= ( const Font cOther)
Font & Font::operator= ( const Font cOther)
bool Font::operator== ( const Font cOther)
void Font::Release ( void  )
Description:
This is the function you want to call when you want to delete a Font. Don't just delete the Font as that could cause problems, instead call this method.
See Also
AddRef()
Author

Referenced by os::View::View().

bool Font::Rescan ( )
static
Description:
This method calls the appserver to rescan for new Fonts.
See Also
Author
Rick Caudill(sylla.nosp@m.ble_.nosp@m.deskt.nosp@m.op@h.nosp@m.otpop.nosp@m..com)

References os::Message::FindBool(), and os::Application::GetInstance().

status_t Font::SetDefaultFont ( const String cName,
const font_properties sProps 
)
static
Description:
Note:
Warning:
Parameters
\return
See Also
Author
Kurt Skauen (kurt@.nosp@m.athe.nosp@m.os.cx)

References os::Application::GetInstance().

void os::Font::SetEncoding ( int  nEncoding)
Description:
Sets the encoding of the Font. This function is not implemented yet!
Author
Kurt Skauen (kurt@.nosp@m.athe.nosp@m.os.cx) and Rick Caudill(sylla.nosp@m.ble_.nosp@m.deskt.nosp@m.op@h.nosp@m.otpop.nosp@m..com)
void os::Font::SetFace ( uint16  nFace)
Description:
Sets the face of the Font. This function is not implemented yet!
Author
Kurt Skauen (kurt@.nosp@m.athe.nosp@m.os.cx) and Rick Caudill(sylla.nosp@m.ble_.nosp@m.deskt.nosp@m.op@h.nosp@m.otpop.nosp@m..com)
status_t Font::SetFamilyAndStyle ( const char *  pzFamily,
const char *  pzStyle 
)
void Font::SetFlags ( uint32  nFlags)
Description:
Sets the flags for the Font.

The flags that can be set are: FPF_MONOSPACED FPF_SMOOTHED //Antialiased FPF_BOLD FPF_ITALIC FPF_SYSTEM

See Also
GetFlags()
Author
Kurt Skauen (kurt@.nosp@m.athe.nosp@m.os.cx) and Rick Caudill(sylla.nosp@m.ble_.nosp@m.deskt.nosp@m.op@h.nosp@m.otpop.nosp@m..com)

References os::font_properties::m_nFlags.

status_t Font::SetProperties ( const font_properties sProps)
status_t Font::SetProperties ( const String cConfigName)
Description:
Sets the properties of the Font to the Font name specified.
Author
Kurt Skauen (kurt@.nosp@m.athe.nosp@m.os.cx) and Rick Caudill(sylla.nosp@m.ble_.nosp@m.deskt.nosp@m.op@h.nosp@m.otpop.nosp@m..com)

References GetDefaultFont(), and SetProperties().

status_t Font::SetProperties ( float  vSize,
float  vShear = 0.0f,
float  vRotation = 0.0f 
)
Description:
Sets the properties of the Font to the properties passed to it.
Author
Kurt Skauen (kurt@.nosp@m.athe.nosp@m.os.cx) and Rick Caudill(sylla.nosp@m.ble_.nosp@m.deskt.nosp@m.op@h.nosp@m.otpop.nosp@m..com)

References os::font_properties::m_vRotation, os::font_properties::m_vShear, and os::font_properties::m_vSize.

void Font::SetRotation ( float  vRotation)
Description:
Sets the rotation of the Font. The higher the float passed, the higher the rotation. If you pass 90.0 to this method then the font will be rotated 90 degrees and etc...
Author
Kurt Skauen (kurt@.nosp@m.athe.nosp@m.os.cx) and Rick Caudill(sylla.nosp@m.ble_.nosp@m.deskt.nosp@m.op@h.nosp@m.otpop.nosp@m..com)

References os::font_properties::m_vRotation.

void Font::SetShear ( float  vShear)
Description:
Sets the shear of the Font...
Author
Kurt Skauen (kurt@.nosp@m.athe.nosp@m.os.cx) and Rick Caudill(sylla.nosp@m.ble_.nosp@m.deskt.nosp@m.op@h.nosp@m.otpop.nosp@m..com)

References os::font_properties::m_vShear.

void Font::SetSize ( float  vSize)
Description:
Sets the size of the Font in Points... Remember that with non-TrueType Fonts, the Font will be resized to an approximation. This normally is all right, but sometimes you will have a Font that is 8.5pt instead of a Font that is 9pt.
Author
Kurt Skauen (kurt@.nosp@m.athe.nosp@m.os.cx) and Rick Caudill(sylla.nosp@m.ble_.nosp@m.deskt.nosp@m.op@h.nosp@m.otpop.nosp@m..com)

References os::font_properties::m_vSize.

Referenced by os::CalendarView::DayView::DayView(), and os::CalendarView::DOWView::DOWView().

void os::Font::SetSpacing ( int  nSpacing)
Description:
Sets the spacing of the Font. This function is not implemented yet!
Author
Kurt Skauen (kurt@.nosp@m.athe.nosp@m.os.cx) and Rick Caudill(sylla.nosp@m.ble_.nosp@m.deskt.nosp@m.op@h.nosp@m.otpop.nosp@m..com)
status_t Font::Unflatten ( const uint8 *  pBuffer)
virtual

Friends And Related Function Documentation

friend class View
friend