Follow

I accidentally a Font Degooglifier:
git.occrp.org/libre/fonts-dego

I was sick and tired of having to manually degooglify fonts, so I made this. Seems to work. Handles both local files and URLs.

Perhaps somebody finds it useful.

Humm... Currently Fonts Degooglifier works by creating a copy of the CSS file and working on that copy.

I am starting to think it should instead create a backup and work on the original.

I wanted to go slow and not break things, but it does seem more intuitive.

Phew! Fonts in 3 @OCCRP projects ungooglified! Easy, since now I have the right tool for the job. ;)

1. Sandcastle property map:
cdn.occrp.org/projects/sandcas
Related investigation:
occrp.org/en/goldensands/

2. Libre code if anyone wants to make a similar map (also ungooglified now):
git.occrp.org/libre/property-m

3. Putin's Circle:
cdn.occrp.org/projects/putinan
Related investigation:
occrp.org/en/putinandtheproxie

(this one does not have a libre code thingy... sorry)

@rysiek Yes, when I put together a privacy-friendly website recently I made sure to embed all the (very nice!) google fonts rather than expose the end-users to google directly ...

@rysiek That looks awesome! Definitely something I want to use. Thank you!

@flowfx my pleasure. :) I need to add support for other CDNs, one day.

@flowfx @rysiek Did something similiar some years ago. Just a lot less advanced. Good to see this.
github.com/Don42/fonts-offline

@rysiek Something that could be useful:

use hueristics upon the filenames to fix the @font-face rules so they declare the same font family but different font weights, styles, etc.

It always annoys me that Google fonts doesn't declare their @font-face rules properly, in the way that works best for designers and browsers. That they confuse the concepts of font files and font families.

@rysiek or you could, at the end of processing a file, do cp $f $f.orig; mv $f.new $f

@rysiek On a related topic: Does using Google Fonts break GDPR?

@jacek I would say it breaks GDPR if you don't inform your users about it.

@rysiek This also my opinion (however since informed consent should be given **before** accessing `fonts.google.com` it really means that it breaks/bends GDPR almost always).

Some lawyer I know insists that it **just** needs to be deep in privacy policy.

However I managed to get decision to remove google fonts from internal cookiecutter template citing --- well we have no privacy policy in this template either ;) (and apart of google fonts this side IMO doesn't require user consent).

@jacek there we go. Here's a toot for everyone saying " doesn't work".

You are not the first person to tell me they are removing some privacy-invading tech due to GDPR. Well done! :)

@rysiek Well first they take down google and facebook general privacy violations. Only then someone will go against random sites using google fonts . . . (unless someone actually renders "constent page" without loading them).

@jacek sure, but random sites moving away from Google Fonts are *already* a measurable improvement of users privacy.

Looks excellent and useful! It's such a pain to do this manually, so - I admit - one defaults to just leaving the calls to Google fonts there

@giocomai yeah, same here. Happy you find it useful. Suggestions and patches welcome!

Will give it a try soon and will see how it goes! thanks!

@rysiek Very nice! if I understand correctly, I could use it by only passing google's font URLs directly (e.g. If I don't have CSS files because I use some form of CSS preprocessor). Is that right?

@lastfuture well, not really. Currently it only supports CSS files. I am not sure if I get the point of providing the font URL directly -- as in, if it's a *.ttf or *.woff or whatever, then just wget/curl it?

What would be the use-case here?

@rysiek I'm sorry, I worded my question poorly. Will I be able to pass Google's CDN URLs of their CSS directly? e.g. fonts.googleapis.com/css?famil

@rysiek I would test this myself but on macOS 10.14.2 for now it aborts with

./degooglify.sh: line 258: ${SOURCE_OF_CSS,,}: bad substitution

with GNU bash, version 3.2.57(1)-release (x86_64-apple-darwin18)

@lastfuture thanks for reporting. Pushed a potential fix, can you test?

For the record, here's the issue:
git.occrp.org/libre/fonts-dego

@rysiek thank you. It passed the missing bash 4.x feature but failed at the -r option for sed:

pastebin.com/4ANttY1D

@rysiek I checked what -r would do, it seems sed that ships with macOS uses a different syntax. From the man page:

-E Interpret regular expressions as extended (modern) regular expressions rather than basic regular expressions (BRE's). The re_format(7) manual page fully describes both formats.

@rysiek after a quick test I can confirm that if I replace all occurrences of the sed parameter -r with -E in the script, it seems to complete correctly. Does this output look plausible?

pastebin.com/dzapyZd9

@rysiek it did name the CSS file `Major-Mono-Display__subset-latin-ext\n.css` for some reason but other than that the result looks good.

@lastfuture fixed I hope: git.occrp.org/libre/fonts-dego :)

Please let me know if all is well now.

And thank you so much for testing and bug reporting!

@rysiek works like a charm now. Thank you for making this helpful tool

@lastfuture yes, yes it does. sed here does support both -E and -r, changed to -E everywhere:
git.occrp.org/libre/fonts-dego

Please test. It might also fix the `\n` issue.

@rysiek beautiful. It still adds the newline to the file name but that's easy to fix by hand

@rysiek Excuse my ignorance on this but what do you mean by "degooglify fonts" and why is it a good idea to do it?

@fox

A pretty popular thing these days is to:
1. go to fonts.google.com
2. select fonts
3. include the generated CSS in a site's CSS (the fonts are then served from Google's servers)

This script makes it easy to automagically download the font files locally onto your server, and modify the CSS files to refer to them, instead of to Google's infrastructure.

@rysiek @fox Ah: That answers a question for me which was "how does this differ from Decentraleyes". Your tool is for actually modifying the server's code to remove Google (Yes x 1000!), Decentraleyes is for Clients to dynamically reroute requests away from Google's CDNs.
I'm glad to see Google's "side channel attacks" getting more attention. Next we need to kill their goddamned DNS..

@cathal @fox exactly. It's a tool for webdevelopers to *easily* move from embedding Google Fonts from Google's infrastructure to self-hosting them.

@rysiek Thanks a lot. I use another script for quite some years to make google fonts locally available.

github.com/neverpanic/google-f

Next time I'll try your script.

@juh Interesting! Mine is way, way simpler (as in, less feature-complete), I think. Thanks for the link!

@juh on the flipside mine has way fewer dependencies.

I guess I need to document that.

@rysiek Yours seems to be faster. But does your script download the latin-ext versions?

@juh you provide my script with a CSS file generated by fonts.google.com. It then downloads whatever is referenced in that file.

@rysiek I love to GitHub star, I'll have to find my selfhosted bookmark solution and use it :) thanks for sharing!

@rysiek Good to know: all fonts of Google Fonts are available on one repository on GitHub: github.com/google/fonts

@PifyZ yup. But a lot of webdevs will just grab the CSS from fonts.googleapis.com, because it's easier to see and test different scripts etc.

My script is there to simplify moving to self-hosting of fonts that are already being used.

Obviously I would recommend everyone to instead just not embed the fonts from Google Fonts in the first place. So that my script would be useless. 😏

@rysiek Your message have inspire me to make a pull request on Plume project: github.com/Plume-org/joinplu.m 😅

@PifyZ whoa cool! Happy to inspire people!

I think I need to look into supporting multiple url() stanzas.

Sign in to participate in the conversation
Mastodon

Follow friends and discover new ones. Publish anything you want: links, pictures, text, video. This server is run by the main developers of the Mastodon project. Everyone is welcome as long as you follow our code of conduct!