hyperandroid / CAAT

Canvas Advanced Animation Toolkit
hyperandroid.github.com/CAAT
MIT License
727 stars 117 forks source link

Preload external fonts in CAAT #140

Closed mohankumarA closed 11 years ago

mohankumarA commented 11 years ago

Hi,

Is there any way to preload font and show the home page, as we load images using (CAAT.Module.Initialization.Template.init()).

My problem is images are loading on first load itself, but the font is shown only when I press refreshing button once again.

Any help is appreciated greatly.

Thanks, Mohan Kumar. A

mohankumarA commented 11 years ago

Hi,

I found the solution in below web link:

http://labs.hyperandroid.com/animation

If you mean whether you could use embedded fonts like google fonts, the answer is yes. The only drawback is that by the time the canvas element accessed in example a CAAT.TextActor which uses the font embedded, it may happen the font is not still loaded. To prevent this, you should create a div in your markup which references the embedded font, something like:

.

which will make your embedded font to be preloaded.

CAAT supports sprited fonts with the object CAAT.Font object. You could also draw text with an atlas texture with the CAAt.SpriteImage object as well. Hope this helps.

that solved my problem.