You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
matrix-spec/static/css/fonts
Andrew Morgan e77c2e3e10 Opt for serving new spec JS/CSS dependencies locally instead of downloading from CDNs (#3036)
This PR does two things:

* Updates the git submodule for the new spec hugo theme ([google/docsy](https://github.com/google/docsy)) to our fork ([matrix-org/docsy](https://github.com/matrix-org/docsy)) which has a couple changes to load JS from local sources instead of remote, as well as allowing sites to override the URL that font CSS files are loaded from. Note that my definition of "font CSS" files here as CSS files that contain settings and point to locations of where font files (`.woff2`) are located.
* Adds a script (and the files generated as a result of running that script) that can take a google fonts URL, download the fonts it points to and spit out those fonts as well as a font CSS file pointing to them for local distribution. We then use the resulting font CSS file in our project variables.

This brings the benefit of not serving files from a CDN which can track users across the web, as well as inadvertently pinning docsy to a specific commit. The downside is that we need to remember to update [matrix-org/docsy](https://github.com/matrix-org/docsy) when needed (and apply the patches on top, though they're quite small).
3 years ago
..
Inter.css Opt for serving new spec JS/CSS dependencies locally instead of downloading from CDNs (#3036) 3 years ago
README.md Opt for serving new spec JS/CSS dependencies locally instead of downloading from CDNs (#3036) 3 years ago
download_google_fonts_css.py Opt for serving new spec JS/CSS dependencies locally instead of downloading from CDNs (#3036) 3 years ago
requirements.txt Opt for serving new spec JS/CSS dependencies locally instead of downloading from CDNs (#3036) 3 years ago

README.md

Fonts

Inter.css

Inter.css is a local copy of https://fonts.googleapis.com/css?family=Inter:300,300i,400,400i,700,700i, modified to pull font files (.woff2) from local sources. It was created using download_google_fonts_css.py.

download_google_fonts_css.py

download_google_fonts_css.py is a script that takes a google fonts CSS URL, downloads the file and linked fonts, then saves the fonts locally along with a modified CSS file to load them. Example call:

python3 download_google_fonts_css.py \
  "https://fonts.googleapis.com/css?family=Inter:300,300i,400,400i,700,700i" \
  ../../fonts \
  ../../fonts 

Which would pop out a Inter.css file that should be @import url("Inter.css")d somewhere in the site's SCSS (currently in /assets-hugo/scss/_variables_project.scss).

Re-running the script and committing any new files is only necessary when a desired font updates (not very often), or we want to change the font we're using. In that case, remove the existing font files at /static/fonts/*.woff2 and re-run the script with a different URL.