5 ms·
I tried to do something similar myself once but quickly gave up. I decided to just slap that line Google gave me in the web page. I get why it is "better" -- C
by rs186 1y ago
I tried to do something similar myself once but quickly gave up. I decided to just slap that line Google gave me in the web page.
I get why it is "better" -- CDN, optimized for browser blah blah. But I really wanted to host it myself, because 1) it's my website 2) I don't want every visitor to send a piece of information about themselves to Google just to get some fonts.
But apparently Google is not motivated to offer such a solution, at all.
- trnglina 1y agoWhat made you give up? As the article describes, self hosting fonts is as easy as making the static font files available and then adding a few lines of CSS. What solution would you want Google to offer?
- rs186 1y agoI needed to figure out exactly which files need to be there, and I needed to understand what's happening in that CSS file. I vaguely remember seeing different content for the CSS file in different browsers. At that time it would take me more than a few minutes (which was what I had), and seemed a rabbit hole. I decided not to pursue that.
- rs186 1y agoLOL downvoted. The sentence "self hosting fonts is as easy as making the static font files available and then adding a few lines of CSS" is a complete lie and you could tell they have never gone through the process themselves and were just making things up. If you don't believe me, you are welcome to try it out yourself FROM SCRATCH without any references whatsoever, and see how long it takes you to come up a solution that works on all 5 or 6 platforms, desktop or mobile.
- trnglina 1y agoPlease educate me if I'm missing something! From memory, what I would do is simply download the original ttfs or otfs, run them through woff2 (https://github.com/google/woff2 https://github.com/google/woff2), and then write the @font-face declarations for each weight/style variation. Variable fonts make this even easier, since you can get by with just the one declaration. One could further optimise them for size with fonttools, to do stuff like subsetting by unicode ranges (https://github.com/fonttools/fonttools https://github.com/fonttools/fonttools), but that's quite optional. Unless your font includes CJK, it's probably not that big to begin with.
- alwillis 1y ago> The sentence "self hosting fonts is as easy as making the static font files available and then adding a few lines of CSS" is a complete lie and you could tell they have never gone through the process themselves and were just making things up. It's not a lie—I've been doing exactly that as long as Google fonts has been a thing. I think people are confusing what was required in the back in the day when browsers were buggy and supported different font formats--15+ years ago. The technique was called the "bullet proof" @font-face syntax because it "solved" getting web fonts to work across operating systems and devices in the 2010's [1]: @font-face { font-family: 'Graublau Web'; src: url('GraublauWeb.eot'); src: local(''), url("GraublauWeb.woff") format("woff"), url("GraublauWeb.otf") format("opentype"), url("GraublauWeb.svg#grablau") format("svg"); } If you weren't doing web development back then, you don't understand what a revelation this syntax was for supporting cross-browser web fonts. There were even websites that would generate the syntax for you. BTW, woff2 didn't exist then. It seems that some developers, like the Japanese soldiers who didn't stop fighting WWII until the 1970's because they didn't know the war ended in 1945 [2], still believe dealing with fonts in 2025 is like it was 15 years ago. It's never been easier to self-host fonts… why make an additional HTTPS request if you don't have to? There are plenty of utilities to compress TrueType or OpenType fonts to WOFF2. [1]: https://www.paulirish.com/2009/bulletproof-font-face-implementation-syntax/ https://www.paulirish.com/2009/bulletproof-font-face-impleme... [2]: https://en.wikipedia.org/wiki/Hiroo_Onoda https://en.wikipedia.org/wiki/Hiroo_Onoda
- cornedor 1y agoSince caches are no longer shared between pages, it actually is often better to self host your fonts than rely on public CDN’s. Makes it even weirder that Google does not offer a simple solution to self host fonts. https://dev.to/rstacruz/public-cdns-arent-useful-anymore-2b66 https://dev.to/rstacruz/public-cdns-arent-useful-anymore-2b6...
- deleted 1y ago[deleted]
- Velocifyer 1y agoGoogle likes collecting referers and IP adresses
- xp84 1y agoSee my top-level comment pointing to where Google is specifically refuting that. So you're welcome to believe they do, but it'd have to be a conspiracy that nobody at GOOG has ever whistleblown.
- saghm 1y agoYour top-level comment does not refute that. As one of the replies to it already states, saying that aren't going to use to info to "create" a targeted profile doesn't really mean a whole lot when they already have so much data on most people already. Even for people that they don't already have a profile on, it's not obvious that they couldn't just add it in to an existing profile in the future if the person made a Google account or something. It's also not nearly as unbelievable as you seem to think it sounds that it could be happening without anyone blowing the whistle. What would you expect to happen if they did? Does "Google tracks lied about tracking users through front downloads" sound like front page news, or something that would stay on people's radar for more than a day or two even if it was? It's hard to imagine that there would be any sort of fine that would reach a level that mattered to Google, or that the recent antitrust case would have had a different outcome if only the font conspiracy had been discovered. Trying to blow the whistle on it just wouldn't be worth it.
- OskarS 1y agoGoogle Fonts lets you just download the font, right? So what's the problem with self-hosting them? They're not encrypted or anything. Like, I'm not sure what else you would want Google to do.
- dawnerd 1y agoIt’s like we’ve taken a step back and people forgot how the web used to be built. I’ve also seen someone ask how you use JavaScript if you don’t have a preprocessor like webpack.
- Velocifyer 1y agoGoogle fonts download button gives you a TTF file and not a WOFF2 file so you have to read the CSS to get the WOFF2 file.
- darrenf 1y agoOr you use Google's own TTF <-> WOFF2 converter tools: https://github.com/google/woff2 https://github.com/google/woff2 [0] I have very recent -- like, 2 weeks ago -- successful experience of using these, since I wanted to distribute a WOFF2 as part of a browser extension. [0] edited to add - you don't have to build it, you can get it from homebrew https://formulae.brew.sh/formula/woff2 https://formulae.brew.sh/formula/woff2 or an Arch package https://archlinux.org/packages/extra/x86_64/woff2/ https://archlinux.org/packages/extra/x86_64/woff2/ and presumably other distros
- cornedor 1y agoAny idea if the woff2 files served by Google are the same? Or that they maybe are more optimized for web?
- darrenf 1y agoI’m afraid I don’t know for sure, I only know that the woff2 file I generated with the CLI worked fine in all the browsers I needed it to. Other posters have said that Google may do some user-agent sniffing or other fingerprinting to maybe serve an even more reliable version, but I can’t comment on that.
- Velocifyer 1y agoThen this guide will be very usefull for you
- carlosjobim 1y ago> But apparently Google is not motivated to offer such a solution, at all. Wait a moment, why should this be Google's job? They're not the lords of your HTML and CSS. In fact, they have no duty to help you with anything at all, and neither does anybody else except your mother.
- saghm 1y agoIt's not as much that they should do it that it's weird that they don't do it. They're already doing a ton of work to try to get people to download fonts from them, supposedly without an ulterior motive other than being helpful, and yet for some reason they seem kinda hesitant to let people actually, you know, actually download them. It's like if Netflix didn't make anyone sign in or charge any money, and went out of their way to get to get people to link to them, but then got shy when someone wanted to download a video to host on their site directly. Being surpsingly unmotivated to do something that ostensibly should be less effort in the long run kind of makes it seem like maybe there's something else going on here.