I have a very strange problem and I'm not even sure if its the right angle but here comes the setup:
link to a google font in the head;
onload: function x()
to render the font in a canvas;
onclick: x();
since the onload
renders the text in a standard font and the onclick
execution of the same function work perfectly, I'm thinking the font is not fully loaded on the first execution. so i was wondering if there was a way to check the loading progress of an external font.
Have you looked at the Google Fonts API, particularly the section 'Acting on events' ?
WebFontConfig = {
google: {
families: [ 'Tangerine', 'Cantarell' ]
},
typekit: {
id: 'myKitId'
},
loading: function() {
// do something
},
fontloading: function(fontFamily, fontDescription) {
// do something
},
fontactive: function(fontFamily, fontDescription) {
// do something
},
fontinactive: function(fontFamily, fontDescription) {
// do something
},
active: function() {
// do something
},
inactive: function() {
// do something
}
};
(function() {
var wf = document.createElement('script');
wf.src = ('https:' == document.location.protocol ? 'https' : 'http') +
'://ajax.googleapis.com/ajax/libs/webfont/1/webfont.js';
wf.type = 'text/javascript';
wf.async = 'true';
var s = document.getElementsByTagName('script')[0];
s.parentNode.insertBefore(wf, s);
})();
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.