abstract const class vaseGraphics::Font

sys::Obj
  vaseGraphics::Font

@Js
@Serializable { simple=true }

Font models the rendering of text.

ascent

abstract Int ascent()

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

Is this font bold.

descent

abstract Int descent()

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

dispose

abstract Void dispose()

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)

Equality is based on name, size, and style.

fromStr

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

virtual override Int hash()

Return hash of name, size, and style.

height

abstract Int height()

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

italic

const Bool italic

Is this font in italic.

leading

abstract Int leading()

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

make

static new make(Int size := 12, Str name := "Serif", Bool bold := false, Bool italic := false)

Construct a Font with family name, size in points, and optional bold/italic style. This is internal for now, because eventually we should be able to collapse this and it-block into single ctor.

name

const Str name := "Serif"

Name of font.

privateMake

new privateMake(Func<Void,This> f)

size

const Int size := 11

Size of font in points.

toBold

Font toBold()

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

toItalic

Font toItalic()

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

toPlain

Font toPlain()

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)

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

toStr

virtual override Str toStr()

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

width

abstract Int width(Str s)

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