是否可以为Google字体指定自定义名称? [英] Is it possible to specify custom name for a Google Font?

查看:129
本文介绍了是否可以为Google字体指定自定义名称?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是一个示例CSS

h1 {
   font-family: 'header-font', arial, sans-serif;
}

p {
   font-family: 'paragraph-font', arial, serif;
}

可以加载任何远程Google字体所以它在CSS中的家庭名称将是'header-font'?

Is it possible to load any remote Google Font (let say 'Lato') so that it's family name in CSS would be 'header-font'?

编辑:这个想法是能够容易地交换WP主题中的字体。不幸的是,在我的情况下,使用CSS预处理器中的变量不是一个选项。

The idea behind this is to be able to easily swap fonts in a WP theme. Unfortunately using variables in CSS preprocessors is not an option in my case.

推荐答案

是的,你可以给任何你想要的名字,当你在@ font-face样式声明中定义字体系列,并使用该名称稍后在样式表中引用它。

Yes, you can give any name you want when you define the font family in the @font-face style declaration and use that name to reference it later in the stylesheet.

@font-face
{
  font-family: whateverYouWant;
  src: url('example.ttf'),
       url('example.eot');
       ... /* and so on */
}

在style-family属性中的样式名称是如何从文档的其余部分引用的。但是我不知道它如何与本地字体文件(所以如果你试图命名一个自定义字体Arial我不知道你会得到什么 - 自定义字体或真正的Arial)。我不知道为什么你会这样做反正虽然。

Whatever you name the style as in the font-family property is how it will be referred to from the rest of the document. However I don't know how it competes with local font files (so if you tried to name a custom font Arial I'm not sure what you would get - the custom font or the real Arial). I don't know why you would do that anyway though.

这篇关于是否可以为Google字体指定自定义名称?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆