class

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.

constructors fromStr

Parse font from string using CSS shorthand format for supported properties

fromProps

Construct from a map of CSS props such as font-family, font-size

make

Construct with it-block

fields names

List of prioritized family names

size

Size of font in points

weight

Weight as number from 100 to 900

style

Style as normal, italic, or oblique

methods toStr

Format as "[style] [weight] <size>pt <names>"

toWeight

Return this font with different weight

toStyle

Return this font with different style

equals

Equality is based on all fields

name

First family name in names

toSize

Return this font with different point size

toProps

Get CSS style properties for this font

hash

Return hash of all fields

equals virtual Bool equals(Obj? that)

Equality is based on all fields.

fromProps static new fromProps(Str:Str props)

Construct from a map of CSS props such as font-family, font-size. Also see toProps.

fromStr static new fromStr(Str s, Bool checked)

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")

hash virtual Int hash()

Return hash of all fields

make new make(|This| f)

Construct with it-block

name Str name()

First family name in names

names const Str[] : names

List of prioritized family names

size const Float : size

Size of font in points.

style const FontStyle : style

Style as normal, italic, or oblique

toProps Str:Str toProps()

Get CSS style properties for this font. Also see fromProps

toSize Font toSize(Float size)

Return this font with different point size.

toStr virtual Str toStr()

Format as "[style] [weight] <size>pt <names>"

toStyle Font toStyle(FontStyle style)

Return this font with different style

toWeight Font toWeight(FontWeight weight)

Return this font with different weight.

weight const FontWeight : weight

Weight as number from 100 to 900

Haxall 4.0.5 ∙ 24-Feb-2026 14:33 EST