Jump to content

Font is not Rendered on Safari


enricosapicco
 Share

Recommended Posts

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 

Link to comment
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);
    };



 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...