문제

To load a font with WebFont, I do as they suggest here: https://developers.google.com/fonts/docs/webfont_loader

WebFontConfig = {
    custom: { families: ['font1', 'font2', 'font3'],
    urls: [ 'stylesheets/fonts.css' ] },
    loading: function(){
        console.log('loaded');
    },
    inactive: function(){
        console.log('not loaded');
    }
};
WebFont.load(WebFontConfig);

But this mean that the broswer wait the download of the css file before it starts loading the fonts.The css is just a few lines of code and i don't see why I could not paste it directly in the js.

Anyone knowes how to achieve that ?

도움이 되었습니까?

해결책

This is simply not possible ; the detection starts when the download of the css is done.

다른 팁

How about download the font and use @font-face in your CSS, like this

@font-face {
  font-family: "Gang-of-Three";
  src: url("fonts/gangofthree.ttf")
  }
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top