admin管理员组文章数量:1406924
I am planning to embed custom font ttf into pdfmake plugin. The documentation remends to add the custom fonts to the vfs_fonts.js file.
window.pdfMake = window.pdfMake || {}; window.pdfMake.vfs = {
"Roboto-Italic.ttf": "AAEAAAASAQAABA",
"Roboto-Medium.ttf": "AAEAAA",
"MyFont.ttf":"???????????????????"
}
I have MyFont.ttf file but I don't know how to convert that into string/encoded format. Is there anyway to do it programatically through javascript?
I am planning to embed custom font ttf into pdfmake plugin. The documentation remends to add the custom fonts to the vfs_fonts.js file.
window.pdfMake = window.pdfMake || {}; window.pdfMake.vfs = {
"Roboto-Italic.ttf": "AAEAAAASAQAABA",
"Roboto-Medium.ttf": "AAEAAA",
"MyFont.ttf":"???????????????????"
}
I have MyFont.ttf file but I don't know how to convert that into string/encoded format. Is there anyway to do it programatically through javascript?
Share Improve this question asked Jan 16, 2017 at 23:57 user3501278user3501278 2671 gold badge8 silver badges21 bronze badges1 Answer
Reset to default 4It is a base64
format.
There are many tools available online.
Here is one
Programatically :
In JavaScript there are two functions respectively for decoding and encoding base64 strings:
atob()
btoa()
The atob() function decodes a string of data which has been encoded using base-64 encoding.
Conversely, the btoa() function creates a base-64 encoded ASCII string from a "string" of binary data.
source
本文标签: javascriptHow to convert a font file ttf into string data like vfsfontsjs doesStack Overflow
版权声明:本文标题:javascript - How to convert a font file ttf into string data like vfs_fonts.js does? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744979139a2635706.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论