【问题标题】:I downloaded a webfont but it only works in brackets我下载了一个网络字体,但它只能在括号中使用
【发布时间】:2020-12-21 19:26:49
【问题描述】:

所以我下载了一个字体(合法地我买了它) 而且字体看起来非常好。但它只显示在括号中的实时预览中。 当我在 chrome 中打开它时,它只是拒绝工作。我购买时遵循了字体上的所有说明。谁能帮帮我?

这是我想要的括号字体显示的图像:

当我在谷歌浏览器中打开index.html 文件时,这是完全相同的代码。

这是我用来在 CSS 中获取字体的代码

@font-face{
   font-family:"Ethnocentric W05 Italic";
   src:url("/fonts/MTI-WebFonts-367222846/Fonts/5118942/e91f32ff-44ec-47c0-afd3-5cdeeb6c73c8.woff2") 
   format("woff2");
}

这是我以前放在标题中的内容

font-family: "Ethnocentric W05 Italic";

【问题讨论】:

  • 您是否查看了浏览器开发工具上的控制台以确保字体加载正常?
  • 是的,我有,一切看起来都很好,应该可以工作。

标签: css fonts adobe-brackets


【解决方案1】:

如果您使用@font-face 声明自定义字体,浏览器将在找不到粗体和斜体样式时尝试伪造它们。

您可以为每种字体使用相同的字体系列名称,并定义匹配的样式,而不是为每种字体定义单独的字体系列值,如下所示:

[css]@font-face {
font-family: 'Ubuntu';
src: url('Ubuntu-R-webfont.eot');
font-weight: normal;
font-style: normal;
}

@font-face {
font-family: 'Ubuntu';
src: url('Ubuntu-I-webfont.eot');
font-weight: normal;
font-style: italic;
}

@font-face {
font-family: 'Ubuntu';
src: url('Ubuntu-B-webfont.eot');
font-weight: bold;
font-style: normal;
}

@font-face {
font-family: 'Ubuntu';
src: url('Ubuntu-BI-webfont.eot');
font-weight: bold;
font-style: italic;
}

.test {
font-family: Ubuntu, arial, sans-serif;
}[/css]

然后您需要做的就是将单个字体系列应用于您的目标,任何嵌套的粗体或斜体样式都会自动使用正确的字体,并且如果您的自定义字体无法加载,仍然会应用粗体和斜体样式。

【讨论】:

    猜你喜欢
    • 2010-12-20
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-07-31
    • 1970-01-01
    • 2017-07-25
    • 1970-01-01
    • 2022-10-14
    相关资源
    最近更新 更多