为什么即使我删除了 @font-face 代码并从我的计算机中卸载了该字体,我的 @font-face 字体仍然可以工作?
我在搞乱 @font-face
并得到了一些奇怪的结果。我下载并安装了该字体,它被安装在 /Users/myuser/Library/Fonts 中,就像它应该的那样(我想!?)。奇怪的是,无论我在 CSS 中给出什么 URL,它都可以工作。
现在我已经从 CSS 中完全删除了 @font-face
类,清空了所有可能的缓存,甚至禁用了 & 。从字体簿(Mac thingie)中删除了“Garton”字体,但它仍然有效! (我正在 Eclipse 中开发和查看该页面。)
那么...
1:它如何工作?使它失败的唯一方法是当我在 CSS 中编辑字体系列“Garton”时。无论我在 @font-face
中写什么,它都会起作用,并且我在 CSS 中没有重复!我重新启动了计算机,将其放在发生故障的电脑上。我查看了 /Library/Fonts ,我想那里安装了默认字体,那里没有“Garton”。
Works even without @font-face in css
#header{
font-family: 'Garton',Georgia, serif;
}
Only way to make it fail on mac
#header{
font-family: 'GartonXXX',Georgia, serif;
}
2:如果弄清楚这一点,我想我必须在托管该页面的网络服务器上安装字体?或者还有别的办法吗?
3:为什么我下载的字体安装在与默认字体不同的文件夹中? (不是那么重要,但我很困惑。)
I was messing around with @font-face
and I had some weird results. I downloaded and installed the font and it got installed in /Users/myuser/Library/Fonts like it should (I suppose!?). The weird thing is that it was working whatever URL I gave it in CSS.
Now I have removed the @font-face
class from the CSS altogether, emptied all possible caches, even disabled & removed the 'Garton' font from Font Book (Mac thingie), but it’s still working! (I’m developing and viewing the page in Eclipse.)
So...
1: how can it work? The only way to make it fail is when I edit the font-family 'Garton' in CSS. Whatever I write in @font-face
it works and I have no duplicates in CSS! I restarted the computer, put it up in my PC where it fails. I looked in /Library/Fonts where default fonts are installed I suppose, and there is no 'Garton' there.
Works even without @font-face in css
#header{
font-family: 'Garton',Georgia, serif;
}
Only way to make it fail on mac
#header{
font-family: 'GartonXXX',Georgia, serif;
}
2: If ever get clarity in this, I guess I must install the font it on the webserver that’s hosting the page? Or is there another way?
3: Why do my downloaded fonts get installed in different folder than the default fonts? (Not so important, but I’m very confused.)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果您已从 Mac 中删除了 Garton,那么即使没有
@font-face
代码,您的网页仍然会在 Garton 中呈现,这很奇怪。我只能想象 Garton 仍然安装在您的 Mac 上。有关此问题的问题最好在 apple.stackexchange.com 或 superuser.com。
如果您使用
@font-face
,最好不要在开发计算机上安装该字体,这样您看到的就是普通用户看到的内容。是的 - 要在公共网站上使用 Garton(计算机上未安装 Garton 的人将查看该网站),您需要在网站服务器上提供可用的字体文件,或者通过诸如 Typekit 或 FontSpring。
您不需要在网络服务器上实际“安装”字体,您只需从那里提供字体文件,就像您提供图像文件或样式表一样,以便浏览器可以获取它并在您的网页上使用它。
为了使其能够跨浏览器工作,您需要拥有几种不同格式的字体文件,并小心使用
@font-face
CSS 以避免妨碍 Internet Explorer。最简单的方法是使用 Font Squirrel 的@font-face
生成器.这又是一个针对 apple.stackexchange.com 或 superuser.com。
If you’ve removed Garton from your Mac, it is odd that your web page still renders in Garton even without
@font-face
code. I can only imagine that Garton is still installed on your Mac.Questions regarding that are better asked at apple.stackexchange.com or superuser.com.
If you’re working with
@font-face
, it’s better not to install the font on your development machine, so that you see what normal users see.Yes — to use Garton on a public web site (where people without Garton installed on their machines will view the site), you need to have the font file available on the site’s server, or via a font service like Typekit or FontSpring.
You don’t need to actually “install” the font on the web server, you just need to serve the font file from there, just like you were serving an image file or a stylesheet, so that the browser can get it and use it on your web page.
In order to get it to work across browsers, you need to have the font file in a few different formats, and be careful with your
@font-face
CSS to avoid tripping up Internet Explorer. The easiest way to get this right is to use Font Squirrel’s@font-face
generator.Again, this is a question for apple.stackexchange.com or superuser.com.