- Index
- »
- fan.graphics
- »
- Font
Font
@Js
@Serializable { simple=true }
const class Font : Obj
Font models font-family, font-size, and font-style, and font-weight. Metrics are available for a predefined set of fonts.
Construct from a map of CSS props such as font-family, font-size
Parse font from string using CSS shorthand format for supported properties
Construct with it-block
List of prioritized family names
Size of font in points
Style as normal, italic, or oblique
Weight as number from 100 to 900
Equality is based on all fields
Return hash of all fields
First family name in names
Get CSS style properties for this font
Return this font with different point size
Format as "[style] [weight] <size>pt <names>"
Return this font with different style
Return this font with different weight
virtual Bool equals(Obj? that)
Equality is based on all fields.
static new fromProps(Str:Str props)
Construct from a map of CSS props such as font-family, font-size. Also see toProps.
static new fromStr(Str s, Bool checked := true)
Parse font from string using CSS shorthand format for supported properties:
[<style>] [<weight>] <size> <names>
Examples:
Font.fromStr("12pt Arial")
Font.fromStr("bold 10pt Courier")
Font.fromStr("italic bold 8pt Times")
Font.fromStr("italic 300 10pt sans-serif")
virtual Int hash()
Return hash of all fields
new make(|This| f)
Construct with it-block
Str name()
First family name in names
const Str[] : names
List of prioritized family names
const Float : size
Size of font in points.
const FontStyle : style
Style as normal, italic, or oblique
Str:Str toProps()
Get CSS style properties for this font. Also see fromProps
Font toSize(Float size)
Return this font with different point size.
virtual Str toStr()
Format as "[style] [weight] <size>pt <names>"
Font toStyle(FontStyle style)
Return this font with different style
Font toWeight(FontWeight weight)
Return this font with different weight.
const FontWeight : weight
Weight as number from 100 to 900