在CSS中显示@font-face的替代字体

发布于 2025-01-01 04:19:23 字数 486 浏览 4 评论 0原文

在 CSS 中使用 @font-face as 引入新字体

@font-face{
font-family:'myCustom';
font-style:normal;
font-weight:400;
src:local('myCustom'),
local('myCustom-Regular'),
url('myCustom.woff') format('woff')
}

并将字体定义为

font-family: myCustom, Tahoma, Verdana, cursive;

但是,我有两个问题:

  1. 在下载我的自定义字体之前,它不会显示第二个(替代字体),并且文本将为空白。

  2. 如果出于任何原因访问者浏览器没有下载我的自定义字体,它将不会显示任何文本。

在我的自定义字体可用之前,如何显示替代字体?

Introducing new font in CSS with @font-face as

@font-face{
font-family:'myCustom';
font-style:normal;
font-weight:400;
src:local('myCustom'),
local('myCustom-Regular'),
url('myCustom.woff') format('woff')
}

and defining the font as

font-family: myCustom, Tahoma, Verdana, cursive;

However, I have two problems:

  1. Until download my custom font, it will not show the second (alternative font), and the text will be blank.

  2. If for any reason the visitor browser does not download my custom font, it will not display any text.

How can I display the alternative font until availability of my custom font?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(1

小女人ら 2025-01-08 04:19:23

我期望发生的是,将使用 font-family 列表中列出的第一个可用的已安装字体。如果没有出现这种情况,请发布 URL 进行检查。

但您可能希望考虑您使用的字体系列列表。如果 TahomaVerdana 可以接受,那么 cursive 就不会;在这种情况下,正常的通用后备字体将是 sans-serif

What I expect to happen is that the first available installed font, among those listed in the font-family list, will be used. If this does not happen, please post a URL for inspection.

But you may wish to consider the list of font families you use. The odds are that if Tahoma and Verdana would be acceptable, cursive would not be; a normal generic fallback font in this case would be sans-serif.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文