[英]Options for embedding fonts in a React app?
Is there a way that I can convert a font file to a buffer or svgs or something and embed it within a js bundle? 有没有一种方法可以将字体文件转换为缓冲区或svgs或其他内容并将其嵌入js包中?
The way the app will be used means I can't link to a hosted font file and I won't have access to the local file system. 应用程序的使用方式意味着我无法链接到托管字体文件,也无法访问本地文件系统。
Thanks for any info. 感谢您提供任何信息。
You can include ttf (font files) into your project and then modify your config.js to bundle it together: 您可以在项目中包含ttf(字体文件),然后修改config.js以将其捆绑在一起:
let rules = []
rules.push({
test: /\.ttf$/,
loader: 'file-loader',
options: {name: 'fonts/[name].[ext]'}
})
module.exports = () => {
module: { rules },
...
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.