我有很多字体,
- OpenSans-bold.ttf
- OpenSans-boldItalic.ttf
- OpenSans-extrabold.ttf
- OpenSans-italic.ttf
- OpenSans-light.ttf
我将如何继续创建一个文件,与这许多不同的文件相反?
也许像我通常那样在CSS上使用它们,或者像在photoshop上那样使用它们?
例如
small{font-family:"OpenSans"; font-weight: normal;}
strong{font-family:"OpenSans"; font-weight: bold;}
h2 {font-family:"OpenSans"; font-weight: bolder;}
任何帮助都会得到满足。
在一个文件中组合多种字体的简单方法是在base64中对它们进行编码并将它们嵌入到CSS中。他们仍然会 不同 虽然字体和总大小会增加。有各种在线工具可以为您上传的字体文件创建css,例如 这个。
如果你想使用不同的字体(常规,斜体,粗体等),你需要不同的字体文件,因为每个字体都是作为一个单独的字体文件实现的(实际上,你甚至需要它以不同的字体格式,以涵盖不同的浏览器)。
但是你 能够 将它们用作单个字体系列,就像你使用Arial一样,并使用直接或间接使用CSS(通过HTML,例如,使用斜体和粗体)。 h2
元素默认为粗体)。为此,你需要 宣布 一个字体系列。
例如,FontSquirrel生成CSS代码,将每个字体定义为字体系列。这是可能的,但不合逻辑且不方便。例如,它生成
@font-face {
font-family: 'open_sansbold';
src: url('opensans-bold-webfont.eot');
src: url('opensans-bold-webfont.eot?#iefix') format('embedded-opentype'),
url('opensans-bold-webfont.woff') format('woff'),
url('opensans-bold-webfont.ttf') format('truetype'),
url('opensans-bold-webfont.svg#open_sansbold') format('svg');
font-weight: normal;
font-style: normal;
}
为了使事情更合理,改变 font-weight
价值,并改变 font-family
命名为您在不同中使用的名称 @font-face
规则(针对家庭的不同字体)。例如。,
@font-face {
font-family: 'Open Sans';
src: url('opensans-bold-webfont.eot');
src: url('opensans-bold-webfont.eot?#iefix') format('embedded-opentype'),
url('opensans-bold-webfont.woff') format('woff'),
url('opensans-bold-webfont.ttf') format('truetype'),
url('opensans-bold-webfont.svg#open_sansbold') format('svg');
font-weight: bold;
font-style: normal;
}