majodev / google-webfonts-helper

A Hassle-Free Way to Self-Host Google Fonts. Get eot, ttf, svg, woff and woff2 files + CSS snippets
https://gwfh.mranftl.com
MIT License
12.03k stars 421 forks source link

unicode-range support #25

Open nazar-pc opened 8 years ago

nazar-pc commented 8 years ago

Looks like all fonts are downloaded as single file with selected characters supported, while I'd like to have versions with unicode-range, which now works in all modern browsers to download fewer bytes. Will it be supported at some point or how it works currently is intentional?

majodev commented 8 years ago

Yep that's intentional, unicode-range was a thing of the future when this project was initially released (the user-agent to grab the woff2 files is quite old).

Will mark this as an enhancement. I'm not sure if this format should be really the new default CSS generation output for all modern browsers or hidden behind fine-grained configuration options.

superpoincare commented 8 years ago

Unicode range creates complications and I think (not sure, although) that the bullet proof font-face syntax will not work for all browsers with unicode range.

Here's the complication:

https://jakearchibald.com/2014/minimising-font-downloads/

I think this is the reason Google itself doesn't use it. If bullet proof font-face syntax would have worked, Google wouldn't send a different css file based on user agent.

nazar-pc commented 8 years ago

Article is almost 2 years old, this is HUGE for modern web. Google Fonts DOES use unicode-range for majority of browsers by default (except, probably, some ancient browsers you should not care about anyway). Where did you saw Google doesn't use it?

There are some browsers, that are not smart enough to download only necessary unicode ranges, but anyway page will still work, and with HTTP/2 will work even faster than downloading single big font file.

superpoincare commented 8 years ago

Yes I know Google Fonts uses unicode-range. What I meant was that it doesn't use it always. So for Firefox < 44, it doesn't.

HTTP2 is slightly irrelevant here. The question is just about syntax.

Assume you have a code similar to "bullet-proof" syntax with unicode-range added. It won't work in Firefox < 44. Firefox 43 will just download the latin variant.

What google fonts does for Firefox < 44 is that it combines all subsets and doesn't use unicode range in the css.

You can't create a "bullet-proof" syntax with unicode range.

nazar-pc commented 8 years ago

Firefox 44 was released almost 5 months ago. There was 45, 46, 47 stable releases since then. I believe it is a sane choice to drop support for Firefox 43- since this is an evergreen browser. Supported ESR version is based on 45, so this i is clearly not a problem here anyway.

szepeviktor commented 7 years ago

I think the problem is that Google does user-agent sniffing while this project produces a static output. http://fonts.googleapis.com/css?family=Open+Sans:400&subset=latin,latin-ext

Buzut commented 7 years ago

@szepeviktor There's nothing preventing you from giving your users the old method if a lot of them have legacy browsers.

Plus, I don't know what's the default behaviour in browsers that don't support it, but if they don't take it into account and download everything, they'll have all the fonts. The only difference will be a couple more http requests when all the ranges are not needed.

If performance AND compatibility are REALLY an issue, there's nothing preventing your from doing user agent sniffing either.