Cufon 多种字体 - 如何?

发布于 2024-08-31 07:28:12 字数 608 浏览 3 评论 0原文

我第一次尝试在同一页面上实现 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

陪我终i 2024-09-07 07:28:12

它非常简单,假设您使用 2 个字体系列“Segoe UI”和“Bauhaus 93”,然后放置脚本,如下所示:

<script src="js/cufon-yui.js" type="text/javascript"></script>
<script src="js/Segoe_UI_400.font.js" type="text/javascript"></script>
<script src="js/Bauhaus_93_400.font.js" type="text/javascript"></script>
<script type="text/javascript">
Cufon.replace('h1', { fontFamily: 'Segoe UI' });
Cufon.replace('h2', { fontFamily: 'Bauhaus 93' });     
</script>

Its very simple, lets suppose you are using 2 font families "Segoe UI" and "Bauhaus 93" then place the scripts as shown below:

<script src="js/cufon-yui.js" type="text/javascript"></script>
<script src="js/Segoe_UI_400.font.js" type="text/javascript"></script>
<script src="js/Bauhaus_93_400.font.js" type="text/javascript"></script>
<script type="text/javascript">
Cufon.replace('h1', { fontFamily: 'Segoe UI' });
Cufon.replace('h2', { fontFamily: 'Bauhaus 93' });     
</script>
寻找我们的幸福 2024-09-07 07:28:12

它知道是因为您的 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 the font-family object parameter (in face).

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?

北城半夏 2024-09-07 07:28:12
<script src="Vegur_300.font.js" type="text/javascript"></script>
<script type="text/javascript">
  Cufon.replace('h1');
</script>

<script src="Myriad_Pro_400.font.js" type="text/javascript"></script>
<script type="text/javascript">
  Cufon.replace('h2');
</script>

这对我有用。

<script src="Vegur_300.font.js" type="text/javascript"></script>
<script type="text/javascript">
  Cufon.replace('h1');
</script>

<script src="Myriad_Pro_400.font.js" type="text/javascript"></script>
<script type="text/javascript">
  Cufon.replace('h2');
</script>

This worked for me.

迷乱花海 2024-09-07 07:28:12

当您在其网站上生成 Cufon 字体时,您可以指定用于字体的名称。

使用以下值作为生成字体的字体系列(可选)

调用 Cufon 时必须使用相同的名称,否则它将无法正常工作。我认为这可能是您的字体替换不起作用的原因。这就是当您调用 fontFamily 时 Cufon 知道您所指的字体的方式。

When you generate your Cufon font on their website, you specify a name to be used for your font.

Use the following value as the font-family of the generated font (optional)

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.

生活了然无味 2024-09-07 07:28:12

看:
https://github.com/sorccu/cufon/wiki/usage

使用多种

字体使用多种字体,您只需要指定要使用的字体即可:

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<script src="cufon-yui.js" type="text/javascript"></script>
<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>
</head>
<body>
<h1>This text will be shown in Vegur.</h1>
<h2>This text will be shown in Myriad Pro.</h2>
</body>
</html>

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:

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<script src="cufon-yui.js" type="text/javascript"></script>
<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>
</head>
<body>
<h1>This text will be shown in Vegur.</h1>
<h2>This text will be shown in Myriad Pro.</h2>
</body>
</html>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文