PDG engine v0.9.5
 All Classes Namespaces Functions Variables Groups Pages
Public Member Functions | List of all members
Font Class Reference

font for text drawing and measuring (GUI Only) More...

Public Member Functions

number getFontAscent (number size, int style=textStyle_Plain)
 get the distance from the top of the font to the baseline
 
number getFontDescent (number size, int style=textStyle_Plain)
 get the distance from the baseline to the bottom of the font
 
number getFontHeight (number size, int style=textStyle_Plain)
 get the total height of a line of text in this font, including spacing
 
number getFontLeading (number size, int style=textStyle_Plain)
 get the distance between lines of the font
 
string getFontName ()
 get the name of this font
 

Detailed Description

font for text drawing and measuring (GUI Only)

Precondition
API Stability: 3 - Stable. The API has proven satisfactory, but cleanup in the underlying code may cause minor changes. Backwards-compatibility is guaranteed.

You cannot create fonts directly, they must be loaded by the Graphics Manager. Drawing text is done through the Port class after assigning a font. The Font object is read only, and has methods for getting measurement info (Font Metrics) for the font.

Font Metrics:

Font Metrics Illustration
See Also
GraphicsManager.createFont
Port.getCurrentFont
Port.setFont
Port.setFontForStyle
Port.setFontScalingFactor

Member Function Documentation

getFontAscent ( number  size,
int  style = textStyle_Plain 
)

get the distance from the top of the font to the baseline

Parameters
sizethe font size you are getting the ascent for
style(optional) the Font Style, defaults to textStyle_Plain if not passed
Returns
the distance in pixels
getFontDescent ( number  size,
int  style = textStyle_Plain 
)

get the distance from the baseline to the bottom of the font

Parameters
sizethe font size you are getting the descent for
style(optional) the Font Style, defaults to textStyle_Plain if not passed
Returns
the distance in pixels
getFontHeight ( number  size,
int  style = textStyle_Plain 
)

get the total height of a line of text in this font, including spacing

Parameters
sizethe font size you are getting the height for
style(optional) the Font Style, defaults to textStyle_Plain if not passed
Returns
the distance in pixels
getFontLeading ( number  size,
int  style = textStyle_Plain 
)

get the distance between lines of the font

Parameters
sizethe font size you are getting the leading for
style(optional) the Font Style, defaults to textStyle_Plain if not passed
Returns
the distance in pixels
getFontName ( )

get the name of this font

Returns
a string with the font name

User Comments