Wait for font loaded in canvas

I’m using a custom font defined by @font-face to draw text on a canvas:
context.font = “12px MyFont”;
context.fillText(text, 20, 20);

Apparently the call to fillText is executed before the font is loaded, so it falls back to some standard font instead.

Some remedies are suggested in
http://stackoverflow.com/questions/2756575/drawing-text-to-canvas-with-font-face-does-not-work-at-the-first-time

  1. adding an extra element before the canvas doesn’t work for me
  2. using a timer solves the problem, but that seems a ugly (and how long should one wait?)

Any suggestions on how to cope with this in Ionic (2)?

could you wrap it in platform.ready()?

platform.ready().then(() => {
… font handling here…
})

or create a promise to check that the font has been loaded.

EDIT: sorry just noticed this is ionic1.

syntax can be found here
http://ionicframework.com/docs/api/utility/ionic.Platform/