Fantom

 

const class

gfx::Font

sys::Obj
  gfx::Font

@simple
@js

Font models the rendering of text.

Slots

ascentSource

Int ascent()

Get ascent of this font on GfxEnv.cur. 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

Int descent()

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

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

Int height()

Get height of this font for GfxEnv.cur. The height is the pixels is the sum of ascent, descent, and leading.

italicSource

const Bool italic

Is this font in italic.

leadingSource

Int leading()

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

makeSource

new make(|Font| f)

Construct with it-block

nameSource

const Str name := "Serif"

Name of font.

sizeSource

const Int size := 11

Size of font in points.

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

Int width(Str s)

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