return $r; } /** * @param int $page 页数 * @param int $pagesize 每页显示数量 * @return mixed */ function link_find($page = 1, $pagesize = 100) { $arr = link__find($cond = array(), array('rank' => -1), $page, $pagesize); return $arr; } /** * @param $id * @return bool 返回FALSE失败 TRUE成功 */ function link_delete($id) { if (empty($id)) return FALSE; $r = link__delete(array('id' => $id)); link_delete_cache(); return $r; } //--------------------------kv + cache-------------------------- /** * @return mixed 返回全部友情链接 */ function link_get($page = 1, $pagesize = 100) { $g_link = website_get('friends_link'); if (empty($g_link)) { $g_link = link_find($page, $pagesize); $g_link AND website_set('friends_link', $g_link); } return $g_link; } // delete kv and cache function link_delete_cache() { website_set('friends_link', ''); return TRUE; } ?>javascript - How to convert a font file ttf into string data like vfs_fonts.js does? - Stack Overflow
最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - How to convert a font file ttf into string data like vfs_fonts.js does? - Stack Overflow

programmeradmin3浏览0评论

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 badges
Add a ment  | 

1 Answer 1

Reset to default 4

It 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

发布评论

评论列表(0)

  1. 暂无评论