1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
|
# Readme for save-webfonts
This `save-webfonts` script and accompanying library are designed to facilitate caching webfonts manually for approved sites. Many sites out there use fonts for interesting glyphs, so disabling webfonts is not a choice made for convenience but security.
But for the sites you trust (or are willing to compromise for), you can run save-webfonts with those URLs, and save down the webfonts to your local user font cache.
## Upstream
[This repo](https://gitlab.com/bgstack15/save-webfonts) is the original source.
## Alternatives
Enable webfonts in your browser. Check setting `gfx.downloadable_fonts.enabled`. The author is not aware of any other scripts, processes, or extensions that "allow" web fonts for arbitrary sites.
This is original research.
## How to use
Read the output of `./save-webfonts --help`, which is also provided here.
usage: save-webfonts [-h] [-d [{0,1,2,3,4,5,6,7,8,9,10}]] [-v] [-n | -a] [-o OUTDIR] [-w | -N] url [url ...]
Download webfonts for a URL so browsers do not need to fetch them
positional arguments:
url URLs whose webfonts should be downloaded
optional arguments:
-h, --help show this help message and exit
-d [{0,1,2,3,4,5,6,7,8,9,10}], --debug [{0,1,2,3,4,5,6,7,8,9,10}]
Set debug level
-v, --version show program's version number and exit
-n, --dryrun Make no changes (default)
-a, --apply Actually make changes
-o OUTDIR, --outdir OUTDIR
Location of font directory. Default is ~/.local/share/fonts
-w, --wait Wait at end for Return key
-N, --no-wait, --nowait
Do not wait. Default.
## Dependencies
These are available as system packages in Fedora and Devuan.
* python3-beautifulsoup4 (aka python3-bs4)
* python3-tinycss2
## Bugs
* Wordpress's weirdness
Wordpress's css lets me manually inspect it but not use the whole script to indicate a single URL, and then list all CSS possible.
Visited in browser, logged in. Used developer tools, tab "Network", enabled CSS and Fonts. Found in the list, dashicons.min.css.
On python prompt:
>>> savewebfonts_lib.get_webfonts_for_one_css("https://s2.wp.com/wp-includes/css/dashicons.min.css?m=1617198107h&ver=5.7.1-alpha-50603&wp-mce-49110-20201110")
Found that a .ttf is listed. So manually wgeted that file, and saved it to ~/.local/share/fonts.
wget --output=~/.local/share/fonts/dashicons.ttf 'https://s2.wp.com/wp-includes/fonts/dashicons.ttf?99ac726223c749443b642ce33df8b800'
* Some webfonts are only as data stored inline in the css directly, or svg only.
## Improve
Write a function that parses a HAR file!
## References
None
## Differences from upstream
None
|