Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/css/38.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Html 如何在一个字体文件中包含不同的字体权重?_Html_Css_Wordpress_Fonts_Font Face - Fatal编程技术网

Html 如何在一个字体文件中包含不同的字体权重?

Html 如何在一个字体文件中包含不同的字体权重?,html,css,wordpress,fonts,font-face,Html,Css,Wordpress,Fonts,Font Face,我目前正在用Wordpress制作一个网站。我的问题是使用字体。我在这里找不到问题的答案,所以我决定问自己。有人发送字体给我使用,但问题是当我打开文件时,有不同样式的字体。更清楚的是:字体是Avenir Next,不同的样式是Avenir Next Bold、Avenir Next Middle、Avenir Next Ultra Light 它不是谷歌字体。我已尝试将其包含在@font-face中: @font-face { font-family: Avenir Next;

我目前正在用Wordpress制作一个网站。我的问题是使用字体。我在这里找不到问题的答案,所以我决定问自己。有人发送字体给我使用,但问题是当我打开文件时,有不同样式的字体。更清楚的是:字体是Avenir Next,不同的样式是Avenir Next Bold、Avenir Next Middle、Avenir Next Ultra Light

它不是谷歌字体。我已尝试将其包含在@font-face中:

@font-face {
    font-family: Avenir Next;  
    src: url('http://localhost/cultuurfonds/wp-
         content/themes/monstroid/fonts/Avenir-Next.ttf');
    font-weight: bold;
    font-weight: 700;
}

@font-face {
    font-family: Avenir Next Medium;  
    src: url('http://localhost/cultuurfonds/wp-
         content/themes/monstroid/fonts/Avenir-Next.ttf');
    font-weight: normal;
    font-weight: 400;
}
有了这个,我可以使用Avenir Next(非常大胆,所以我不想使用它),但是Avenir Next媒介不起作用

这是一种付费字体,但不是我买的。那个人将字体文件(Avenir Next.ttf)发送给我,所以这就是我必须处理的

我宁愿不使用插件来包含它。无论如何,我找不到一个好的插件。但是如果除了使用插件没有其他方法,我愿意使用它


我希望我的问题很清楚(这里的第一个问题)。

如果你想从本地文件加载字体,首先你必须使用一些工具,比如生成不同格式的字体

然后你必须像这样加载字体的所有格式

@font-face {
    font-family: 'AvenirNextLTPro';
    src: url('fonts/AvenirNextLTPro-Regular.eot?#iefix') format('embedded-opentype'),  
        url('fonts/AvenirNextLTPro-Regular.otf')  format('opentype'),
        url('fonts/AvenirNextLTPro-Regular.woff') format('woff'), 
        url('fonts/AvenirNextLTPro-Regular.ttf')  format('truetype'), 
        url('fonts/AvenirNextLTPro-Regular.svg#AvenirNextLTPro-Regular') format('svg');
    font-weight: 400;
    font-style: normal;
}

@font-face {
    font-family: 'AvenirNextLTPro';
    src: url('fonts/AvenirNextLTPro-Demi.eot?#iefix') format('embedded-opentype'),  
        url('fonts/AvenirNextLTPro-Demi.woff') format('woff'), 
        url('fonts/AvenirNextLTPro-Demi.ttf')  format('truetype'),
        url('fonts/AvenirNextLTPro-Demi.svg#AvenirNextLTPro-Demi') format('svg');
    font-weight: 500;
    font-style: normal;
}

正如您所看到的,字体系列名称是相同的,但字体的大小是不同的(常规-400和Demi-500)

然后,当您想在不同的元素中使用不同的字体权重时,您必须这样声明:

p {
  font-family: 'AvenirNextLTPro';
  font-weight: 400;
}

h1 {
  font-family: 'AvenirNextLTPro';
  font-weight: 500;
}

我知道这样进口的方法。但是当我生成不同格式的字体时,我只得到Avenir Next Bold而不是其他格式。你说的其他格式是什么意思?格式有woff、eot、ttf等。如果您正在生成Avenir Next Bold,您将无法获得Avenir Next Light。是的,格式不是合适的词。我认为款式或重量更好。文件名为“Avenir Next.tff”。当我打开“ttf”文件时,会有不同名称的不同权重,如“Avenir Next Medium”和“Avenir Next Bold”等。然后我生成了“Avenir Next.tff”文件,只得到了“Avenir Next Bold”。而“ttf”文件中的其他样式不会生成