gs.Font Class
A class to describe fonts. Fonts can be loaded from installed fonts or from imported fonts. (Graphics/Fonts)
Constructor
gs.Font
-
name
-
size
Parameters:
-
name
String- The font name.
-
size
String- The font size in pixels.
Item Index
Methods
Methods
compare
-
font
Compares the font to the specified font. Only name and size are compared.
Parameters:
-
font
gs.Font- The font to compare to.
Returns:
If true both fonts are equal. Otherwise false
createDefault
()
gs.Font
static
Creates a new default font.
Returns:
A new created default font.
loadCustomFonts
-
A
Loads custom fonts and makes them ready to use.
Parameters:
-
A
Functioncallback called if the loading-process has been done. It has the following signature:
// error - Indicates if an error occurred during the loading-process function(error) {}
measureChar
-
c
Measures the size of a single character. The result isn't pixel-perfect.
Parameters:
-
c
String- A single character.
Returns:
The size of the character.
measureText
-
text
Measures a specified text. The result isn't pixel-perfect.
Parameters:
-
text
String- The text to measure.
Returns:
The size of the text.
measureTextPlain
-
text
Measures a specified text as plain text. Formatting like outlines, style, etc. is ignored. The result isn't pixel-perfect.
Parameters:
-
text
String- The text to measure.
Returns:
The size of the text.
set
-
font
Assigns all properties from the specified font.
Parameters:
-
font
gs.Font- The font to get all properties from.
toDataBundle
()
Object
Converts the font into a data bundle.
Returns:
The data bundle.
toDataBundle
-
data
Restores the font from a data bundle.
Parameters:
-
data
Object- The data bundle.
toString
()
String
Returns a CSS string representation of the font like "italic bold 12px Arial".
Returns:
A CSS representation of the font.
Properties
@shadowOffsetX
Number
The vertical shadow offset.
@shadowOffsetX
Number
The horizontal shadow offset.
bold
Boolean
Indicates if the font-style is bold.
border
Boolean
Indicates if the font has an outline/border.
borderSize
Number
The outline size.
italic
Boolean
Indicates if the font-style is italic.
loaded
Boolean
Indicates if the font is loaded.
metrics
gs.FontMetrics
Font metrics contains additional info about the font.
name
String
The font name.
shadow
Boolean
Indicates if the font has a shadow.
size
Number
The font size in pixels.
smallCaps
Boolean
Indicates if the font-style is small-caps.
strikeThrough
Boolean
Indicates if the font-style is strike-through.
underline
Boolean
Indicates if the font-style is underline.