Function textMetrics

  • Returns a object that contains information about the measured text (such as its width, for example)

    Parameters

    Returns undefined | TextMetrics | TextMetrics[]

    const { textMetrics, TextLayer } = require('@hitomihiumi/lazy-canvas')
    //...
    let text = new TextLayer()
    .setText(`Hello, World!`)

    console.log(textMetrics(text))
    // returns {
    // width: 70,
    // actualBoundingBoxLeft: 0,
    // actualBoundingBoxRight: 71,
    // actualBoundingBoxAscent: 9,
    // actualBoundingBoxDescent: 2,
    // emHeightAscent: 11,
    // emHeightDescent: 3,
    // alphabeticBaseline: -1
    // }