It usually works in all browsers, you just have to use font-face correctly. Just use a generator like this one: http://www.fontsquirrel.com/tools/webfont-generator
It creates a zip files with 4 font files (eot, svg, ttf, woff), and there is a css file with the necessary code:
@font-face {
font-family: 'myfont';
src: url('myfont.eot');
src: url('myfont.eot?#iefix') format('embedded-opentype'),
url('myfont.woff') format('woff'),
url('myfont.ttf') format('truetype'),
url('myfont.svg#myfont') format('svg');
font-weight: normal;
font-style: normal;
}
I am using KineticJS, when i create the stage after page load it works with the correct font:
window.onload = function () {
var stage = new Kinetic.Stage({
container: 'container',
width: 800,
height: 600
});
//code for creating a layer, text and whatnot with kinetic
}
Should also be no problem if you don´t use Kinetic, of course.
If it does not work in some browsers, the font may not be loaded correctly. Using a timeout would be a bad workaround imho, you can try adding a hidden div right after the opening body tag:
<div class="font-hack" style="font-family:'your-font';">nothing to see here, move along</div>
It does not matter what you write there (it must not be empty though).
I am not working with Kinetic anymore, but this works great with the Phaser Engine.
head
tag of thehtml
? – Utile<div style="font-family: myFont"></div>
– Templin