Cufon 控制台错误,未替换字体.(引用错误:找不到变量:Cufon)

Cufon console error, not replacing font. (ReferenceError: Can't find variable: Cufon)

本文关键字:错误 Cufon 找不到 变量 引用 字体 控制台 替换      更新时间:2023-09-26

我第一次尝试使用 Cufon 给我带来了一些问题,因为我似乎无法让它工作。 Coda的Javascript日志给了我这个错误(参考错误:找不到变量:Cufon)从几个教程中,我准确地遵循了它们,一遍又一遍地来回下载库,没有任何效果。 如果你们能看看并帮助我,将不胜感激。

这是我的代码;

    <!DOCTYPE html>
    <html lang="en">
    <head>
    <title>Test</title>
    <!-- Styles go here -->
    <link rel="stylesheet" type="text/css" href="css/reset.css" />
    <link rel="stylesheet" href="css/style.css" />
    <!-- End styles here -->
    <!-- Scripts go here -->
    <!--[if lt IE 9]>
    <script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
    <![endif]-->
    <script type="text/javascript" src="scripts/A.font.js"></script>
    <script type="text/javascript" src="scripts/cufon.js"></script>
    <script type="text/javascript">
        Cufon.replace("p");
    </script>
    <!-- Scripts end here -->
</head>
<body>
<p>Test</p>
Test
</body>
</html>

谢谢。

发生

此错误是因为您在加载需要它的字体后加载了Cufon,因此请尝试更改顺序,首先加载cufon.js

<script type="text/javascript" src="scripts/cufon.js"></script>

然后加载A.font.js

<script type="text/javascript" src="scripts/A.font.js"></script>
我知道

这不能直接回答你的问题,但请不要使用 Cufon。改用 CSS 2.1 的@font面。它非常简单且 100% 可访问,而 Cufon 则不是。

以下是您需要在 CSS 中使用@font脸的仅有的 2 个链接:

http://www.fontspring.com/blog/further-hardening-of-the-bulletproof-syntaxhttp://www.fontsquirrel.com/fontface/generator