简体   繁体   中英

Storing fonts locally using localStorage

How can I use localStorage for storing .woff and .ttf files ? I don't want to use application cache. Help me. Thanks

localStorage is designed to store text key/value pairs, so if you want to save binary data you probably need to base64 encode the data. The size of the encoded binary data will be greater than the orginal size and the localStorage size is limited to a few MB (tipycally 5-10M). Probably it is not a good idea to save the font files in the localStorage.

Disk space for storage: http://dev.w3.org/html5/webstorage/#disk-space

Test localStorga limits: http://arty.name/localstorage.html

You can store fonts in base64 data .

localStorage.font1 = string(base64 data of specified font)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM