[英]Base64 encoded OpenType font-face using data URI
I want to add a base64 encoded
OpenType font as a data URI in font-face. 我想添加
base64 encoded
OpenType字体作为font-face中的数据URI。
I have this so far: 到目前为止,我有:
@font-face {
font-family: 'test';
src: url(data:font/otf;base64,
// Base64 string here ...
) format('opentype');
}
But I believe it does not include the font correctly to my style. 但是我认为它没有正确包含我的字体。
Any help with this would be really appreciated. 任何帮助,将不胜感激。
Data URIs are always of this format: 数据URI始终采用以下格式:
data:[<mediatype>][;base64],<data>
The very first part of every data URI is the media-type
, which in the case of an Open Type
font is: 每个数据URI的第一部分是
media-type
,对于Open Type
字体,它是:
font/opentype
So, you may use it like this: 因此,您可以这样使用它:
@font-face{
font-family: test;
src: url(data:font/opentype; base64, [base64 string here]);
}
Replacing 更换
[base64 string here]
with the exact copy-pasted version of your base-64 encoded string. 与您的base-64编码字符串的复制粘贴版本完全相同。
Notes 笔记
Please note that: 请注意:
font/opentype
for the data
, not otf
. data
使用font/opentype
otf
,而不是otf
。 Online Encoding Tool 在线编码工具
You may use this tool, to convert your font file to the encoded string. 您可以使用此工具将字体文件转换为编码的字符串。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.