Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site













SourceForge.net Logo

Font

 

class Font : private AssignValueTypeNo<Font, FONT_V, Moveable<Font> >

Font is a concrete class that describes the appearance of text. It is Moveable, has cheap copy operation and is Value convertible with rich-Value abilities.

It is storing several attributes to describe the text. The corresponding system font is stored in the form of face index - each system font has specific index value. There are some predefined indexes for common fonts:

 

Font::STDFONT

Standard GUI font defined by platform. Can be altered by Draw::SetStdFont.

Font::SERIF

Standard serif font.

Font::SANSSERIF

Standard sans-serif font.

Font::MONOSPACE

Standard fixed pitch font.

 

Font also provides text metrics services.

 

 

Public Member List

 

static int GetFaceCount()

Returns the number of face-names available.

 


 

static String GetFaceName(int index)

Returns the name of face index.

 


 

static int FindFaceNameIndex(const String& name)

Finds the face index of face-name.

 


 

static dword GetFaceInfo(int index)

Returns the information about face index as combination of binary flags:

Font::FIXEDPITCH

Font-face is monospaced.

Font::SCALEABLE

Font-face is freely scalable (it is in vector format, e.g. Truetype).

Font::SPECIAL

Font does not use Unicode encoding (typical for some symbol fonts).

 


 

static void SetDefaultFont(Font font)

Sets the standard font, unless SetStdFont was used. This variant is used by Chameleon skin to set font matching platform setting, while SetStdFont can be used by client code to override this setting (and thus has higher priority).

 


 

static void SetStdFont(Font font)

Sets the standard font. U++ sets the standard font to match host platform standard. This method can be used to change this default setting.

 


 

static Font GetStdFont()

Returns the standard font.

 


 

static Size GetStdFontSize()

Returns metrics of standard font - height and average width of glyphs.

 


 

int GetFace() const

Face index of Font.

 


 

int GetHeight() const

Returns the requested height of font.

 


 

int GetWidth() const

Return the width of font or 0 for default width.

 


 

String GetFaceName() const

Returns the face-name text for current instance.

 


 

String GetFaceNameStd() const

Similar to GetFaceName, but returns generic names "serif", "sansserif", "monospace", "STDFONT" for corresponding faces, instead of real names.

 


 

dword GetFaceInfo() const

Same as GetFaceInfo(GetFace()).

 


 

int64 AsInt64() const

Returns 64-bit number representing the font. All font attributes are expressed as bitfields of this number.

 


 

void RealizeStd()

Replaces Null or STDFONT with actual standard GUI font definition. If font is Null, it is set to standard font with all attributes. If face is STDFONT, it is replaced with actual face of standard font. If font height is -32000 (which is value StdFont function normally returns), it is replaced with standard font height.

 


 

Font& Face(int n)

Sets the face index.

 


 

Font& Height(int n)

Sets the font height (in pixels/dots).

 


 

Font& Width(int n)

Sets the font width. Use 0 for default width (in pixels/dots).

 


 

Font& Bold()

Font& NoBold()

Font& Bold(bool b)

Font& Italic()

Font& NoItalic()

Font& Italic(bool b)

Font& Underline()

Font& NoUnderline()

Font& Underline(bool b)

Font& Strikeout()

Font& NoStrikeout()

Font& Strikeout(bool b)

Sets or unsets bold/italic/undeline/strikeout modes.

 


 

Font& NonAntiAliased()

Font& NoNonAntiAliased()

Font& NonAntiAliased(bool b)

Sets/unsets non-anti-aliased flag. This indicates that anti-aliasing should not be used when painting the font.

 


 

bool IsBold() const

bool IsItalic() const

bool IsUnderline() const

bool IsStrikeout() const

Tests whether bold/italic/underline/strikeout is active.

 


 

bool IsNonAntiAliased() const

True if NonAntiAliased is active.

 


 

Font& FaceName(const String& name)

Sets the face to name. If name is not valid face-name, Font is set to Null. Method is able to recognize generic names "serif", "sansserif", "monospace" and "STDFONT".

 


 

Font operator()() const

Returns a copy of Font. Useful to simplify notation when altering existing Font values.

 


 

Font operator()(int nconst

Returns a copy of Font, with height changed to n.

 


 

void Serialize(Stream& s)

Serializes the font value (face index is stored as face-name text).

 


 

void Jsonize(JsonIO& jio)

Stores/load font to/from JSON.

 


 

void Xmlize(XmlIO& xio)

Stores/load font to/from JSON..

 


 

bool operator==(Font fconst

bool operator!=(Font fconst

Compares two Font instances.

 


 

dword GetHashValue() const

Returns the font hash value.

 


 

bool IsNullInstance() const

True if Font is Null. (This method is used by default IsNull template).

 


 

void SetNull()

Sets the Font to Null.

 


 

int GetAscent() const

Returns the character cell extend above the baseline.

 


 

int GetDescent() const

Returns the character cell extend below the baseline.

 


 

int GetCy() const

Same as GetDescent() + GetAscent().

 


 

int GetExternal() const

Returns the additional space that font description recommends to insert between two lines of text. Rarely used.

 


 

int GetInternal() const

Returns the mostly free space inside GetAscent value. Rarely used.

 


 

int GetHeight() const

Returns GetAscent() + GetDescent() - the height of the line of text.

 


 

int GetLineHeight() const

Returns suggested total line height.

 


 

int GetOverhang() const

Returns overhang of font.

 


 

int GetAveWidth() const

Returns the average width of character.

 


 

int GetMaxWidth() const

Returns the maximal width of character.

 


 

bool IsNormal(int chconst

Returns true if ch exists as regular glyph in the font.

 


 

bool IsComposed(int chconst

Returns true if ch.is to be rendered as composition of 2 other glyphs (ASCII letter and diacritical mark).

 


 

bool IsReplaced(int chconst

Returns true ch is to be rendered using character from some other font.

 


 

bool IsMissing(int chconst

Returns true if ch cannot be rendered.

 


 

int HasChar(int chconst

Returns true if ch can be rendered (in any way).

 


 

int GetWidth(int cconst

Returns the total advance with of character c (encoded in unicode).

 


 

int operator[](int cconst

Same as GetWidth(c).

 


 

int GetLeftSpace(int cconst

Describes the relation of left side of character cell and leftmost area painted for character c. Negative value means that character extends character cell, positive value means that there is a space inside the cell not used for glyph.

 


 

int GetRightSpace(int cconst

Similar to GetLeftSpace for the right edge of character cell.

 


 

bool IsFixedPitch() const

True if font is mono-spaced.

 


 

bool IsScaleable() const

True if font is freely scaleable.

 


 

bool IsSpecial() const

Returns true if font does not use unicode placement of glyphs, for example some symbol fonts have this issue.

 


 

bool IsTrueType() const

Returns true if font is TrueType font. (Note that PdfDraw and Linux printing are only able to handle TrueType fonts).

 


 

String GetPath() const

POSIX specific: Returns the path of font file.

 


 

String GetTextFlags() const

Returns font flags (like Bold) in verbose string form (e.g. "bold underline").

 


 

void ParseTextFlags(const char *s)

Sets font flags based on text in format created by GetTextFlags.

 


 

String GetData() const

Returns the raw content of font file.

 


 

void Render(FontGlyphConsumer& sw, double x, double y, int chconst

For true-type fonts, renders the character glyph.

 


 

Font()

Initializes Font to STDFONT, default height, all attributes not active.

 


 

Font(int face, int height)

Initializes font to face index and height.

 


 

Font(const Nuller&)

Sets the font Null.

 


 

operator Value() const

Converts the Font to the Value (font is rich Value).

 


 

Font(const Value& q)

Converts the Value to the Font.

 

 

Last edit by cxl on 12/04/2013. Do you want to contribute?. T++