enricosapicco

Font is not Rendered on Safari

Recommended Posts

I use a variation of Open Sans in the game. It works perfectly OK on Firefox and Chrome but Safari uses some default font instead of the font I use. Does anyone have any idea or had similar experience?

Edited by enricosapicco
Tags

Share this post


Link to post
Share on other sites
18 hours ago, enricosapicco said:

I use a variation of Open Sans in the game. It works perfectly OK on Firefox and Chrome but Safari uses some default font instead of the font I use. Does anyone have any idea or had similar experience?

Did you checked the network ? Maybe font just doesn't downloading properly for some reason 

Share this post


Link to post
Share on other sites

how did you load your fonts ?
are you able to share your code ?
 

    load_fonts(){
        const fonts = [
            {name:"ArchitectsDaughter", url:"fonts/ArchitectsDaughter.ttf"},
            {name:"zBirdyGame", url:"fonts/zBirdyGame.ttf"},
        ];
        fonts.forEach(font => {
            const style = document.createElement('style');
            style.appendChild(document.createTextNode(`
                @font-face {
                    font-family: '${font.name}';
                    font-style: normal;
                    font-weight: 700;
                    src: url("${font.url}");
                }
            `));
            document.getElementsByTagName('head').item(0).appendChild(style);
            const div = document.createElement('div');
            div.style.fontFamily = font.name;
            document.body.appendChild(div);/* Initiates download in Firefox, IE 9+ */
            div.innerHTML = 'Content.';/* Initiates download in WebKit/Blink */
        });
        let checkFonts =  setInterval(()=>{
            if( fonts.every(e => document.fonts.check(`12px ${e.name}`) )){
                this.fonts = fonts;
                clearInterval(checkFonts);
                this.load();
            }
        },60);
    };



 

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.