const class graphics::Font

sys::Obj
  graphics::Font

@Js
@Serializable { simple=true }

Source

Font models font-family, font-size, and font-style, and font-weight. Metrics are available for a predefined set of fonts.

equals

virtual override Bool equals(Obj? that)

Source

Equality is based on all fields.

fromProps

static new fromProps(Str:Str props)

Source

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

fromStr

static new fromStr(Str s, Bool checked := true)

Source

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 override Int hash()

Source

Return hash of all fields

make

new make(|This| f)

Source

Construct with it-block

name

Str name()

Source

First family name in names

names

const Str[] names := Str["sans-serif"]

Source

List of prioritized family names

size

const Float size := 11.0f

Source

Size of font in points.

style

const FontStyle style := FontStyle.normal

Source

Style as normal, italic, or oblique

toProps

Str:Str toProps()

Source

Get CSS style properties for this font. Also see fromProps

toSize

Font toSize(Float size)

Source

Return this font with different point size.

toStr

virtual override Str toStr()

Source

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

toStyle

Font toStyle(FontStyle style)

Source

Return this font with different style

toWeight

Font toWeight(FontWeight weight)

Source

Return this font with different weight.

weight

const FontWeight weight := FontWeight.normal

Source

Weight as number from 100 to 900