Fan

 

const class

fwt::Font

sys::Obj
  fwt::Font

Font models the rendering of text.

Slots

ascentSource

native Int ascent()

Get ascent of this font on default display device. The ascent is the distance in pixels from baseline to top of chars, not including any leading area.

boldSource

const Bool bold

Is this font bold.

descentSource

native Int descent()

Get descent of this font on default display device. The descent is the distance in pixels from baseline to bottom of chars, not including any leading area.

disposeSource

native Void dispose()

Free any operating system resources used by this instance.

equalsSource

override Bool equals(Obj? that)

Overrides sys::Obj.equals

Equality is based on name, size, and style.

fromStrSource

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

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

override Int hash()

Overrides sys::Obj.hash

Return hash of name, size, and style.

heightSource

native Int height()

Get height of this font on default display device. The height is the pixels is the sum of ascent, descent, and leading.

italicSource

const Bool italic

Is this font in italic.

leadingSource

native Int leading()

Get leading of this font on default display device. The leading area is the distance in pixels above the ascent which may include accents and other marks.

makeSource

new make(Str? name := null, Int size := 12, Bool bold := false, Bool italic := false)

Construct a Font with family name, size in points, and optional bold/italic style.

nameSource

const Str name

Name of font.

sizeSource

const Int size

Size of font in points.

sysSource

static native Font sys()

Get the default system font.

sysMonospaceSource

static native Font sysMonospace()

Get the default system mono-spaced font.

toBoldSource

Font toBold()

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

toItalicSource

Font toItalic()

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

toPlainSource

Font toPlain()

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

toSizeSource

Font toSize(Int size)

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

toStrSource

override Str toStr()

Overrides sys::Obj.toStr

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

widthSource

native Int width(Str s)

Get the width of the string in pixels when painted with this font on the default display device.