const class gfx::Font

sys::Obj
  gfx::Font

@Js
@Serializable { simple=true }

Source

Font models the rendering of text.

ascent

Int ascent()

Source

Get ascent of this font which is the distance in pixels from baseline to top of chars, not including any leading area.

bold

const Bool bold

Source

Is this font bold.

descent

Int descent()

Source

Get descent of this font which is the distance in pixels from baseline to bottom of chars, not including any leading area.

dispose

Void dispose()

Source

Free any operating system resources used by this font. Dispose is required if this color has been used in an operation such as FWT onPaint which allocated a system resource to represent this instance.

equals

virtual override Bool equals(Obj? that)

Source

Equality is based on name, size, and style.

fromStr

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

Source

Parse font from string (see toStr). If invalid and checked is true then throw ParseErr otherwise return null.

Examples:

Font.fromStr("12pt Arial")
Font.fromStr("bold 10pt Courier")
Font.fromStr("bold italic 8pt Times Roman")
hash

virtual override Int hash()

Source

Return hash of name, size, and style.

height

Int height()

Source

Get height of this font which is the pixels is the sum of ascent, descent, and leading.

italic

const Bool italic

Source

Is this font in italic.

leading

Int leading()

Source

Get leading of this font which is the distance in pixels above the ascent which may include accents and other marks.

make

new make(|This| f)

Source

Construct with it-block

name

const Str name := "Serif"

Source

Name of font.

size

const Int size := 11

Source

Size of font in points.

toBold

Font toBold()

Source

Return this font, but with a bold styling. If this font is already bold then return this.

toItalic

Font toItalic()

Source

Return this font, but with a italic styling. If this font is already italic then return this.

toPlain

Font toPlain()

Source

Return this font, but with a plain styling (neither bold, nor italic). If this font is already plain then return this.

toSize

Font toSize(Int size)

Source

Return this font, but with the specified point size. If thsi font already has the given size return this.

toStr

virtual override Str toStr()

Source

Format as "[bold] [italic] <size>pt <name>"

width

Int width(Str s)

Source

Get the width of the string in pixels when painted with this font.