Describes a font using with size, family, style, weight, and line spacing.
Inheritance Hierarchy

Remarks

This is a convertible type that can be used with the following notation(s) in parameter lists, parameter objects or setters.

CSS font shorthand strings are converted to Fonts. For example:

'bold 16px sans-serif'
'italic Tahoma'
'normal xx-large Arial'

See Also

Developer's Guide

Members

No filters for this type

Constructors

Initializes a new instance of the Font class with size 10, "Arial" family, normal weight and style and line spacing 0.5, or the given values.

Parameters

fontFamily?: string
A comma separated list of font-family names.
fontSize?: number
The font size in px.
fontStyle?: FontStyle
The font style.
fontWeight?: any
The font weight.
lineSpacing?: number
The line spacing which is interpreted as additional spacing of the line height.
textDecoration?: TextDecorations
The text decoration.

See Also

API
createCopy

Properties

Gets the font family.
If the given font family string contains quotation marks, it is assumed to follow the W3C fontFamily value specification regarding additional quotes, listing multiple font family names or using generic family names. Otherwise, non-generic font family names will be automatically quoted in order to avoid invalid font family name tokens.
readonlyfinal

Property Value

The font family.
Gets the size of the font.
The font size is interpreted as px.
readonlyfinal

Property Value

The size of the font.
Gets the font style.
readonlyfinal

Property Value

The font style.
Gets the font weight.
readonlyfinal

Property Value

The font weight.
Gets the line spacing.
The value is interpreted as a fraction of the line height in EM values.
readonlyfinal

Property Value

The line spacing in EM.
Gets the text decoration.
readonlyfinal

Property Value

The text decoration.

Methods

Assigns the text properties of this instance to the given text element.
final

Parameters

textElement: SVGTextElement
The text element to assign set the Font on.
Creates a copy with the values of this instance or optionally the explicitly specified values.
final

Parameters

fontFamily?: string
The font family to use for the copy.
fontSize?: number
The font size to use for the copy.
fontStyle?: FontStyle
The font style to use for the copy.
fontWeight?: any
The font weight to use for the copy.
lineSpacing?: number
The line spacing to use for the copy.
textDecoration?: TextDecorations
The text decoration to use for the copy.

Return Value

Font
A new Font instance.
Indicates whether this instance and a specified object are equal.
final

Parameters

other: any
Another object to compare to.

Return Value

boolean
true if other and this instance are the same type and represent the same values; otherwise, false.
Returns a hash code for this object.

The hash code is a numeric value that can be used to treat this object as a key in a hash table or similar data structure.

Two objects that are considered equal must have the same hash code. However, the reverse does not hold and two objects having the same hash code don't have to be equal. Ideally, the hash code should be roughly uniformly-distributed to prevent hash tables from performing poorly. Calculating the hash code is also a potentially frequent operation and should therefore be fast.

final

Return Value

number
the hash code for this object

Static Methods

Creates a Font instance from the given font-like object by performing automatic type conversion.
static

Parameters

typefaceLike: Font
The object to convert to a Font.

Return Value

Font
The given typefaceLike if it is already a Font, or a new instance initialized to the values found in typefaceLike.