简体   繁体   English

手机浏览器不支持字体

[英]Font face not supported in mobile browser

I followed this guide to use the @font-face property for browser support, the method I used was "Slightly Deeper Browser Support".我按照指南使用@font-face属性来支持浏览器,我使用的方法是“稍微深入的浏览器支持”。 It is working on my machine (of course), I hosted the site and asked one of my friends to check the site to verify if the font is supported in his browser, and it is.它在我的机器上运行(当然),我托管了该站点并要求我的一位朋友检查该站点以验证他的浏览器是否支持该字体,并且确实如此。 However, when I checked the site from my iPhone using Safari one of the font is not supported and I wonder why that is.但是,当我使用 Safari 从我的 iPhone 检查网站时,其中一种字体不受支持,我想知道为什么会这样。 As mentioned in the guide I put the font face at the top, before any styles.如指南中所述,我将字体放在顶部,在任何 styles 之前。

Here's the link to the hosted site https://gilbert1391.github.io/new-portfolio/这是托管站点https://gilbert1391.github.io/new-portfolio/的链接

The fonts I want to support are The Bold Font (which is being used in the hero section) and Helvetica Neue, and the one that is not supported in my iphone's browser is the former one.我要支持的fonts是The Bold Font(在英雄部分使用)和Helvetica Neue,我的iphone浏览器不支持的是前者。

iPhone software version: 13.3.1 iPhone软件版本:13.3.1

I solved the issue我解决了这个问题

First, I had the font installed in my local machine and I thought the @font-face was working properly, I uninstalled the font from my computer and worked from there.首先,我在本地机器上安装了字体,我认为@font-face工作正常,我从计算机上卸载了字体并从那里开始工作。

Second, I had path wrong, fixed that by using the following path: /src/assets/fonts/TheBoldFont.ttf其次,我的路径错误,通过使用以下路径修复: /src/assets/fonts/TheBoldFont.ttf

But it still didn't work and I was getting this warning但它仍然没有工作,我收到了这个警告

Failed to decode downloaded font

What I did to fix it was to replace the previous path for this one: ./assets/fonts/TheBoldFont.ttf我修复它的方法是替换之前的路径:./assets/fonts/ ./assets/fonts/TheBoldFont.ttf

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM