@font-face not working on Wordpress site

后端 未结 2 1970
爱一瞬间的悲伤
爱一瞬间的悲伤 2021-01-26 05:19

I\'m using the @font-face function to use a custom font (Geosanslight) on my Wordpress site.

I have downloaded the webkit using http://www.fontsquirrel.com and uploaded

相关标签:
2条回答
  • 2021-01-26 06:04

    Check on your browser console :

    Font from origin 'http://www.lynnepassmore.com' has been blocked from loading by Cross-Origin Resource Sharing policy: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://lynnepassmore.com' is therefore not allowed access.

    You're trying to load a font from a different domain (www vs without www) - it is considered as a distant resource, and blocked by the headers policy.

    You can use relative path for your font if you include it from your css file, then it'll be relative to your css file location.

    0 讨论(0)
  • 2021-01-26 06:08

    Your custom css is actually in the source code index, hence the relative path wont work. Change your font paths as follow.

    @font-face {
    font-family: 'geosanslight';
    src: url('/wp-content/themes/esteem/fonts/geosanslight-webfont.ttf') format('truetype');
    }
    

    and

    body, h1, h2, h3, h4, h5, h6, p, li, a {
    font-family: "geosanslight",sans-serif;
    }
    

    please make sure your final css is like this

    @font-face {
    font-family: 'geosanslight';
    src: url('/wp-content/themes/esteem/fonts/geosanslight-webfont.ttf') format('truetype');
    }
    
    body, h1, h2, h3, h4, h5, h6, p, li, a {
    font-family: 'geosanslight', sans-serif !important;
    }
    
    0 讨论(0)
提交回复
热议问题