How do I convert my font to data
qassimhaider
Posts: 4
Comments
-
I'm not sure I understand your question. If you mean, 'How do I convert to WOFF format', a good answer is the program sfnt2woff available on GitHub. If you mean, how do I hide the fact that it's a font, you might be able to do something with the HTTP headers sent from the web server, but that makes no sense in the context of CSS.2
-
terminal:base64 font.ttf > fontbase64.txtthen embed it into your css with:
font-family: "Font";
src: url("data:font/<FONT FORMAT>;base64,<ENCODED TEXT FROM FILE>") format("<FONT FORMAT>");
}
3 -
Thanks for your help, yes perfectly it's through the terminal,base64 font.ttf > fontbase64.txt0
-
There really is no good reason to do this...$ base64 YourFont.ttf > Notsecure.txt
$ base64 -d Notsecure.txt > YourFontAgain.ttfWhat it does do is prevent the user's browser from caching that file (bad) and use ~25-50% more space more (also bad) and it forces the server to transmit that data, instead of more efficiently serving a file (also bad). Anybody who know how to grab a woff file from their browser console also knows how to save a base64 blob to a file.base64 is like zip, it does _nothing_ to protect your file. Unlike zip, it only makes your font larger in size.
5 -
That's not always an issue, nor is it necessarily the case. If the CSS file you are embedding the font into is itself cached, which it usually will be, then the font data are cached with it. This is only really an additional issue if the CSS is inline in the page, and the font is used on several pages.What it does do is prevent the user's browser from caching that file (bad)use ~25-50% more space more (also bad)
It's 33%, or 36% if you have line breaks; and once the CSS file is gzipped the difference ends up being more like 1-2%.
There are good reasons to inline a font: when it is subsetted, and/or you are only using it one one page, and/or you are only using it in one shared stylesheet. I agree that it's not "protecting" the font in any way, not sure why you would want to try to do that anyway, it is a fool's errand.
A particularly good case for embedding fonts in data URIs is for icon fonts, if you wrote custom hinting code for your icons (making SVG not an option).2
Categories
- All Categories
- 46 Introductions
- 3.9K Typeface Design
- 485 Type Design Critiques
- 560 Type Design Software
- 1.1K Type Design Technique & Theory
- 654 Type Business
- 852 Font Technology
- 29 Punchcutting
- 519 Typography
- 119 Type Education
- 323 Type History
- 77 Type Resources
- 112 Lettering and Calligraphy
- 33 Lettering Critiques
- 79 Lettering Technique & Theory
- 549 Announcements
- 91 Events
- 114 Job Postings
- 170 Type Releases
- 173 Miscellaneous News
- 276 About TypeDrawers
- 54 TypeDrawers Announcements
- 120 Suggestions and Bug Reports

