+
80
-

如何将font字体文件内嵌到html文档中?

请问如何将font字体文件内嵌到html文档中?

网友回复

+
0
-

第一、通过在线工具转换成base64格式,工具地址:https://tool.bfw.wiki/tool/1620804739325201.html

第二、在css中定义字体,比如如果字体是woff2格式的话

@font-face {
        font-family: 'fontname';
        src: url('data:font/woff2;charset=utf-8;base64,BASE64字符串') format('woff2'),
        url('data:font/woff;charset=utf-8;base64,BASE64字符串') format('woff');
        font-weight: normal;
        font-style: normal;
        font-display: swap;
    }

第三、直接在css中引用字体即可

h1{
 font-family:fontname;
}

我知道答案,我要回答