Describes a font using with size, family, style, weight, and line spacing.
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'
Type Details
- yFiles module
- view
Constructors
Font
(fontFamily?: string, fontSize?: number, fontStyle?: FontStyle, fontWeight?: 'normal' | 'bold' | 'light' | 'bolder' | 'lighter' | 'inherit' | string, lineSpacing?: number, textDecoration?: TextDecorations)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
A map of options to pass to the method.
- fontFamily - string
- A comma separated list of font-family names.
- fontSize - number
- The font size in px.
- fontStyle - FontStyle
- The font style.
- fontWeight - 'normal' | 'bold' | 'light' | 'bolder' | 'lighter' | 'inherit' | string
- 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
Properties
Gets the font family.
Remarks
Property Value
Gets the font style.
Property Value
Gets the text decoration.
Property Value
Methods
Assigns the text properties of this instance to the given text element.
Parameters
A map of options to pass to the method.
- textElement - SVGTextElement
- The text element to assign set the Font on.
createCopy
(fontFamily?: string, fontSize?: number, fontStyle?: FontStyle, fontWeight?: 'normal' | 'bold' | 'light' | 'bolder' | 'lighter' | 'inherit' | string, lineSpacing?: number, textDecoration?: TextDecorations) : FontCreates a copy with the values of this instance or optionally the explicitly specified values.
Parameters
A map of options to pass to the method.
- 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 - 'normal' | 'bold' | 'light' | 'bolder' | 'lighter' | 'inherit' | string
- 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.
Returns
Indicates whether this instance and a specified object are equal.
Parameters
A map of options to pass to the method.
- other - any
- Another object to compare to.
Returns
- ↪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.
Remarks
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.
Returns
- ↪number
- the hash code for this object
Static Methods
Creates a Font instance from the given font-like object by performing automatic type conversion.