Travis Kirton

Font Properties

There are a number of properties that you can access on a Font object. Typically, you will use these to do some custom layout. Here is the list:


You can access them like this:

let f = Font()

Resizing a Font

If you want a font with a smaller point size, you can use the font(size:) method, like this:

let f = Font("AvenirNext-DemiBold", size: 80)
let smallFont = f.font(30)


override func setup() {
    //create an initial font
    var f = Font(name:"BodoniSvtyTwoITCTT-Book", size:45.0)!

    //create an initial label, position it, add it to the canvas
    var p = Point(, f.lineHeight)

    createTextShape("Font Properties", font: f, center: &p)

    //change the font size
    f = f.font(30.0)

    createTextShape("Family name: \(f.familyName)", font: f, center: &p)
    createTextShape("Font name: \(f.fontName)", font: f, center: &p)
    createTextShape(String(format:"Point size: %.2f", f.pointSize), font: f, center: &p)
    createTextShape(String(format:"Ascender: %.2f", f.ascender), font: f, center: &p)
    createTextShape(String(format:"Descender: %.2f", f.descender), font: f, center: &p)
    createTextShape(String(format:"Cap Height: %.2f", f.capHeight), font: f, center: &p)
    createTextShape(String(format:"X-Height: %.2f", f.xHeight), font: f, center: &p)
    createTextShape(String(format:"Line Height: %.2f", f.lineHeight), font: f, center: &p)

func createTextShape(text: String, font: Font, inout center: Point) {
    let ts = TextShape(text: text, font: font)! = center
    center += Vector(x: 0, y: ts.height + 10)