在 Mac 电脑上使用谷歌网页字体 [英] using google web fonts on mac computer

查看:35
本文介绍了在 Mac 电脑上使用谷歌网页字体的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在构建一个在 PC 上使用 Google WebFonts (open sans) 的网页,它运行良好,但是当我在 Mac 计算机上尝试时,它在文本中显示一个问号.这是为什么?

I'm building a web page that uses Google WebFonts (open sans) on a PC and it works perfectly, but when I try it on a mac computer it shows a question mark within the text. Why is this?

推荐答案

您看到的字符是 替换字符,当字体不包含特定的 Unicode 字符时使用,在这种情况下,ñ"又名 U+00F1 又名带波浪号的拉丁小写字母 n".

The character you are seeing is the replacement character, which is used when a font does not contain a particular Unicode character, in this case, "ñ" AKA U+00F1 AKA "Latin small letter n with tilde".

Google Open Sans 确实包含此字符,因此 Safari 似乎没有正确地从网络获取字体.渲染引擎然后恢复到另一种字体,而那个字体缺少有问题的字符.您将能够在您的 mac 上检查开发工具,您的脚本正在抓取哪种字体.

Google Open Sans does contain this character, so it seems that Safari is not correctly getting the font from the web. The rendering engine is then reverting to another font, and that one is missing the offending character. You will be able to check in dev tools on your mac which font is being grabbed by your script.

我检查了您在问题评论中发布的脚本注释.您正在返回 woff2 格式的字体.事实证明,从版本 9 开始,woff2 在 Safari 中不受支持,但 woff 是.因此,我建议将格式更改为 woff 并在本地将其提供给您的页面:

I checked the script annotation you posted in the comment to your question. You are returning the fonts in the woff2 format. It turns out that woff2 is not supported in Safari as of version 9, but woff is. I therefore recommend changing the format to woff and serving it to your page locally:

将其另存为 css 文件(例如 fonts.css)

Save it as a css file (e.g. fonts.css)

查找并替换 woff2 到 woff

Find-and-replace woff2 to woff

保存文件

将其添加到您的网络项目中(但您添加了其他文件)

Add it to your web project (however you add your other files)

@StyleSheet({"fonts.googleapis.com/css?family=Open+Sans:300,400,500,700";}‌ ) 替换为对这个新上传的文件的引用.

Replace @StyleSheet({"fonts.googleapis.com/css?family=Open+Sans:300,400,500,700";}‌​) with a reference to this newly uploaded file.

这篇关于在 Mac 电脑上使用谷歌网页字体的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆