How to work with TextBounds in instance mode


I have the following problem, when I try to use textBounds on instance mode im not sure how to do it, is reporting me this error -> Unable to get property ‘unitsPerEm’ of undefined or null reference.

let name = "test";
let font = this.loadFont('assets/AvantBold.otf');
let bounds = font.textBounds(name, 0, 0, 32);

Im just trying to do this example in instance mode:

1 Like

Hello @murillazo,

What the error message is telling you, in a somewhat cryptic fashion, is that variable font is null or undefined. Maybe there’s not a font present at assets/AvantBold.otf?

1 Like

@Sven Problem solved, the problem was the use of the preload function, I wasn’t using it.

1 Like