Cufon 多种字体 - 如何?
我第一次尝试在同一页面上实现 2 个 cufon 字体。它不起作用。
在文档中,这是作为示例提供的:
<script src="Vegur_300.font.js" type="text/javascript"></script>
<script src="Myriad_Pro_400.font.js" type="text/javascript"></script>
<script type="text/javascript">
Cufon.replace('h1', { fontFamily: 'Vegur' });
Cufon.replace('h2', { fontFamily: 'Myriad Pro' });
</script>
我不明白的是 - fontFamily: 'Vegur' 和实际的 Vegur_300.font.js 文件之间的链接是什么?
换句话说,浏览器如何知道“Vegur”是那个特定文件?
提前致谢
I am trying to implement 2 cufon fonts on the same page for the first time. Its not working.
In the documentation this is provided as an example:
<script src="Vegur_300.font.js" type="text/javascript"></script>
<script src="Myriad_Pro_400.font.js" type="text/javascript"></script>
<script type="text/javascript">
Cufon.replace('h1', { fontFamily: 'Vegur' });
Cufon.replace('h2', { fontFamily: 'Myriad Pro' });
</script>
The thing I dont understand is - what is the link between fontFamily: 'Vegur' and the actual Vegur_300.font.js file?
In other words, how does the browser know that 'Vegur' is that particular file?
thanks in advance
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
它非常简单,假设您使用 2 个字体系列“Segoe UI”和“Bauhaus 93”,然后放置脚本,如下所示:
Its very simple, lets suppose you are using 2 font families "Segoe UI" and "Bauhaus 93" then place the scripts as shown below:
它知道是因为您的 Vegur_300.font.js 文件包含一个
Cufon.registerFont
命令,该命令包含font-family
对象参数(在脸
)。只要所有字体 .js 文件都在执行,Cufon 就会获取每种字体的注册信息和曲线数据。至于为什么它对你不起作用,在没有更多信息的情况下我无法推测。您有示例网站吗?
It knows because your Vegur_300.font.js file contains a
Cufon.registerFont
command that contains thefont-family
object parameter (inface
).As long as all your font .js files are executing, Cufon is getting the registration information with the curve data for each font. As to why it's not working for you, I can't speculate without more information. Do you have a sample site up?
这对我有用。
This worked for me.
当您在其网站上生成 Cufon 字体时,您可以指定用于字体的名称。
调用 Cufon 时必须使用相同的名称,否则它将无法正常工作。我认为这可能是您的字体替换不起作用的原因。这就是当您调用 fontFamily 时 Cufon 知道您所指的字体的方式。
When you generate your Cufon font on their website, you specify a name to be used for your font.
You have to use that same name when calling Cufon, or it won't work properly. I think that might be the reason why your font replacement isn't working. That's the way Cufon knows what font you're referring to when you make the fontFamily call.
看:
https://github.com/sorccu/cufon/wiki/usage
使用多种
字体使用多种字体,您只需要指定要使用的字体即可:
See:
https://github.com/sorccu/cufon/wiki/usage
Using multiple fonts
To use multiple fonts you only need to specify which font you want to use and you’re set: