使用CSS中的@font-face功能导入字体,但没有像创建者宣传的那样显示

问题描述 投票:0回答:1

How my font should appear as per the creator

上图是导入的字体应如何显示(编辑:第一种字体样式),正如创建者所说的那样。

How my font actuall appears

然而,上图就是我看到的样子。

下面是我的CSS。我只添加了文本阴影作为测试。当我删除文本阴影时,它仍然无法正常工作。有人知道我做错了什么吗?

#hero {
    display: flex;
    flex-direction: column;
    border: 3px solid black;
    border-radius: 10px;
    width: 500px;
    margin: auto;
    text-align: center;
    font-size: 50px;
    font-family: reglisse;
    text-shadow: 1px 1px 1px black;
}
@font-face {
    src: url("Reglisse-0WOD9.otf");
    font-family: reglisse;
}
#jdogs{
    color: #ff0054;
    margin: 5px;
}
#corn {
    color: #ffbd00;
    margin: 5px;
}
#dogs {
    color: #ff0054;
    margin: 5px;
}

我尝试使用@font-face 功能,就像我对导入文本所做的那样。上面的图片展示了我的预期和实际结果。我没有通过谷歌找到答案。以下是创建者页面的链接:https://www.fontspace.com/reglisse-font-f43313

另外,我意识到它在创建者页面上是黑白的,但我需要使用我的代码中的颜色。

css import fonts font-face
1个回答
1
投票

您需要在

@font-face
规则和样式规则中指定字体粗细。
否则,您的文本会被人为加粗。 这种 “仿粗体” 样式的工作方式与笔划非常相似 - 字形的透明区域将由该笔划填充。

@font-face {
    font-family: 'Reglisse';
    src: url('data:font/woff2;charset=utf-8;base64,d09GMgABAAAAAAukAA4AAAAAEuAAAAtPAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAGhYbgRwcKgZgAFwRCAqWaJQ0CxoAATYCJAMwBCAFh2QHOhubEBGVq2Mn++KAJ0PNGYYDARLitcQa4cRWYxcnUkWqCHxcDp6v/V7P3d0HGGByyBZJAo//KipCRSUlEq62qiwUCkWyswN0s6u5Bjbh380IY1vLFzEFDqxH29f29PaA91Z4Afk/LhEAf7+unWsMTe8EZCh+rfF/a63uYLrXINogjZJphEwpN3M77/bf3xNDVJrZINrEE1QSVZJaSFbJNEIkxMQjkggxMwzP8nwyXUI6BIg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yVaQio5p+uZKNmjpUyxvZFVGPRblEfTqjinIcyYlm0tRQbXekp8r8duMC0oC3HD3nb3iOw3i4I0xE6aeAMAOH88+nEh5MUCVxh1qhr5GcJShwWT+xp1rv51zdftiKZfiC4QEX+y8LBt/YIfLF/j4jKhPZEflmMz8aXcIb9mEB3ZPyn1P1JtzJMCNbEkQXqEMaAEP6DFgA4Aj4G54TyWe8k39HQiBV5EtdlH9QIzLUB50CYCnCwGdAjeCBQICGVB9RCB5fBtlNGMzIcsjq5GU74gfnOxIEXRTYx25qqn51CL4JQPmujYAKUGsDULw1GXwXj1jBu57xenNJLzIxMlraQawHIQna1SYM+EKwU3azezhD1GcNr715CWMQVeeNhbO1+BGOePfjiVVqNOkwYMiEKQAAAA==') format('woff2');
    font-weight: normal;
    font-style: normal;
    font-display: swap;
}


body{
  font-family:Reglisse;
  font-size:5em;
  font-synthesis: none;
}


.jdogs{
    color: #ff0054;
    margin: 5px;
}
<h1>DOGS</h1>
<p class="jdogs">JDOGS</p>
<p class="jdogs"><strong>JDOGS</strong></p>
<p class="jdogs"><em><strong>JDOGS</strong></em></p>

将“Reglisse”定义为 font-weight:bold/700 可能更容易,以防止这种假粗体渲染。

您还可以通过以下方式防止这种人造样式

font-synthesis
像这样的属性

body{
  font-family:Reglisse;
  font-size:5em;
  font-synthesis: none;
}

这也可以防止假雅体字 - 倾斜字形

@font-face {
    font-family: 'Reglisse';
    src: url('data:font/woff2;charset=utf-8;base64,d09GMgABAAAAAAukAA4AAAAAEuAAAAtPAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAGhYbgRwcKgZgAFwRCAqWaJQ0CxoAATYCJAMwBCAFh2QHOhubEBGVq2Mn++KAJ0PNGYYDARLitcQa4cRWYxcnUkWqCHxcDp6v/V7P3d0HGGByyBZJAo//KipCRSUlEq62qiwUCkWyswN0s6u5Bjbh380IY1vLFzEFDqxH29f29PaA91Z4Afk/LhEAf7+unWsMTe8EZCh+rfF/a63uYLrXINogjZJphEwpN3M77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ko2aOmQjk10R9Wilmfqk3MkBksNm0pgSNp+fUMZpQCPGC4ArHkEqZMsyVaQio5p+uZKNmjpUyxvZFVGPRblEfTqjinIcyYlm0tRQbXekp8r8duMC0oC3HD3nb3iOw3i4I0xE6aeAMAOH88+nEh5MUCVxh1qhr5GcJShwWT+xp1rv51zdftiKZfiC4QEX+y8LBt/YIfLF/j4jKhPZEflmMz8aXcIb9mEB3ZPyn1P1JtzJMCNbEkQXqEMaAEP6DFgA4Aj4G54TyWe8k39HQiBV5EtdlH9QIzLUB50CYCnCwGdAjeCBQICGVB9RCB5fBtlNGMzIcsjq5GU74gfnOxIEXRTYx25qqn51CL4JQPmujYAKUGsDULw1GXwXj1jBu57xenNJLzIxMlraQawHIQna1SYM+EKwU3azezhD1GcNr715CWMQVeeNhbO1+BGOePfjiVVqNOkwYMiEKQAAAA==') format('woff2');
    font-weight: 700;
    font-style: normal;
    font-display: swap;
}


body{
  font-family:Reglisse;
  font-size:5em;
}


.jdogs{
    color: #ff0054;
    margin: 5px;
}
<h1>DOGS</h1>
<p class="jdogs">JDOGS</p>
<p class="jdogs"><strong>JDOGS</strong></p>

© www.soinside.com 2019 - 2024. All rights reserved.