Pomax / lib-font

This library adds a new Font() object to the JavaScript toolbox, similar to new Image() for images
MIT License
734 stars 72 forks source link

onload fired before canvas is ready to draw font #27

Closed actionnick closed 10 years ago

actionnick commented 10 years ago

Steps To Repro:

  1. Load a remote (uncached) font.
  2. In the onload callback try to draw text to canvas using this font.
  3. Often times it does not appear as the correct font.
actionnick commented 10 years ago

You can see in this screenshot the text renders initially in a default sans serif font. paperless_post

On a redraw though it renders with the correct font. paperless_post

Pomax commented 10 years ago

loading for use on a canvas is not the same as loading for use on a webpage. When the font reports ready, it's ready for styling text on the page only: using it on the canvas actual leads to a new load operation into the canvas 2d/3d context, which can take a few frames.