As there are several issues related to fonts so it is best to convert it keep it in base 64 format. Sometimes sites like fontsquirrel.com etc. are not able to convert your fonts in base64 format showing issues like fonts are blacklisted or other issues. So how to convert fonts into base64 format in that case (in case we have no such legal issues with fonts)
-
Any websearch will give you a million links to how to base64 encode arbitrary data. Also note that the blacklisting that fontsquirrel etc. do is because you're trying to convert a well known, licensed font you *absolutely do not have the right to use*, like fonts you get "for free" with your OS or Adobe products =) – Mike 'Pomax' Kamermans Jul 26 '16 at 00:43
-
Thanks Mike. The fonts that I need to convert in base64, I already have the license to use it but as these sites don't have that right so not allowing me to convert it in base64. Other than this why to use these sites when we can do it using our own terminal/ command line. I have found out the way and have posted an answer hoping it will help others in need. – paraS elixiR Jul 28 '16 at 14:55
-
1alternatively, you can also just use the browser, which is a more universal method compared to a specific OS's terminal; All modern browsers come with FileReader for parsing data from file, and `atob()` for converting data to base64 binary for (and `btoa()` to convert back), so you never even need to leave the browser context. One note, though: as long as converter sites don't store the data, there are no rights issues. My go-to is http://www.motobit.com/util/base64-decoder-encoder.asp – Mike 'Pomax' Kamermans Jul 28 '16 at 15:11
1 Answers
I just found a solution to encode fonts in base64 format using command prompt.
- open command prompt / terminal
- go to the folder where the font files are.
- Type in following command
base64 name-of-thefont-file-name.woff
(I prefer to use .woff as it works with several advance browsers)
In case you are having difficulty in copying it from command prompt /terminal - you can redirect output to a file
base64 name-of-thefont-file-name.woff > base64encoded.txt
If one needs encoded font in just one line use following command
base64 -w 0 name-of-thefont-file-name.woff > base64encoded.txt
Now use this encoded code in css file using following code snippet -
@font-face { font-family: "Font Name"; src:url(data:font/woff;charset=utf-8;base64,font-file-in-encoded-form) format('woff'); font-weight: normal; font-style: normal; }

- 1,866
- 1
- 18
- 26