Compressing fonts for using in web - css

Can fonts be compressed someway before using as webfonts? I have a font file which is 150kB. Is it possible to compress it down.
And also if i call for both font .eot and .ttf will both be downloaded by browsers?

If you use the FontSquirrel #font-face kit generator - http://www.fontsquirrel.com/fontface/generator - and choose the expert setting, you can manipulate the settings to achieve a little better compression.

You can compress .woff font files with https://github.com/hn/woff-compress. It uses zlib's Z_BEST_COMPRESSION flag or Zopfli to losslessly shrink files down to a minimum.
If you want to lossy reduce files even more, you can remove unneeded glyphs from the font as discussed in Way to reduce size of .ttf fonts?.

Related

How to compress .ttf font file size

I'm using noori nastaleeq font in my website but the .ttf file is around a 7mb file which is taking too much time to load the webpage, is there any way to compress the filesize? this font is not available on google fonts too.
P.S: The actual .ttf was around 12mb i'm using w3 super cache plugin so it compress the current file to 7mb and i wanted to compress more
Thanks
Try using font-squirrel to convert your font. They have perfect instructions on their website. After you convert your font, it also comes with a css file that includes your font already added to a font-family. Easy to just plug into your html.
https://www.fontsquirrel.com/tools/webfont-generator
Converting your font file (.ttf extension) to .woff or .woff2
the woff extension is more compacted in comparison of .ttf
Note: consider that IE11 didn't accept woff2 so use woff as it fallback.

Bootstrap - about fonts files (.eot .svg .ttf .woff and .woff2) roles and usages

In the fonts folder of Bootstrap 3, we can see those files:
glyphicons-halflings-regular.eot
glyphicons-halflings-regular.svg
glyphicons-halflings-regular.ttf
glyphicons-halflings-regular.woff
glyphicons-halflings-regular.woff2
Are they all the same files converted in different formats? Are they all necessary? What is the role/usage of each file?
They are included because each font was created to solve different problems. Woff and woff2 are the newest formats which were designed to stop font piracy. Svg is also a newer format which is a vector file and used on iOS mobile devices. Tff and eot are old school formats used by old browsers, but they allow anyone to download and use the font for free.
Short answer: They are all included for multi-version cross-browser compatibility.
See: Why should we include ttf, eot, woff, svg,... in a font-face

How can I Use a Font Suitcase with the #font-face CSS statement?

I would like to use the Eurostyle font in my Rails application. We got it a while ago and installed in on our Mac computers. The font shows up in all our applications.
This will be my first time using the #font-face CSS statement in my stylesheet. I could not find any examples using a font suitcase. I have found a few solutions on how to split the font. So far the one I found has not worked. The link below suggested using DFontSplitter but when I did I got an error which is listed below. I have no idea what this is.
Want to embed a font but cannot convert from Font Suitcase or PostScript Type 1 files
The error message is: ‘Can't find an appropriate resource fork in /Users/xxxxxxx/Desktop/Exported Fonts/Eurostile/Eurostile
The only other solution I saw was very complicated and was for Mac OS 9.
Has anyone successfully used a font suitcase with the #font-face statement? If not how do I convert this to ttf or some other font format that works on popular browsers?
Short answer: you can't. #font-face is for loading individual font files, not suitcases/fontbooks/opentype collections/etc.
Long answer: there is no long answer, the short answer is all there is to it.
Convert the individual fonts you need to an opentype format, or ideally an opentype format that's been wrapped by a WOFF (WOFF v1 has massive support, WOFF v2 not yet, it's too new), and point to those with your (possibly multiple due to multiple font styles and weights) #font-face rules.
I was able to find a solution to convert my font suitcase to TTF using the solution from this link below.
http://macthoughts.net/20131112-373
After converting my suitcase file I copied the TTF files into my Rails application. I changed the src value in my stylesheet to point to the font files in my application. Now people who do not have the font installed will see the font I want in my Rails application.
I was able to get ttf files from font suitcase files this way:
I opened the Font Book app on my mac (osx 10.13.2), and located the font (make sure it's installed). Select the font and click file - export fonts and select a location.
The result in my case was a ttc file. I could convert this file easily with an online converter like this one.

Can I just use FA's CSS and SVG file or do I need .EOT, .TTF, and .OFF?

due to security reasons, I can't use the Font Awesome CDN nor can I transfer over any files other than the Font Awesome's .css and the .svg files. The other .eot, .ttf, and .off files included in the download get stripped out when I try to transfer between secure networks.
So, does anyone know if I can just use the .css and .svg file or do I need all the others?
Thanks,
The differing font files are included for browser compatibility. As to whether or not you can use just SVG, that depends on which browsers you want to support.
Take a look at this related question for a detailed explanation Why should we include ttf, eot, woff, svg,... in a font-face

How can I reduce the size of TTF file?

Am using font face method for my website.For that am using TTF file.The problem am facing is due to the size of TTF file the site loading slowly.So suggest me how to reduce the size of TTF file.Thanks.
You could look into the amount of glyphs you are using in the font and try to reduce it to the absolute necessary ones, the Font Squirrel kit generator, when in Expert Mode, lets you select the symbols you want to use.
Read more at Limit characterset of a Webfont?

Resources