Skip to content

Commit 5f8ae5f

Browse files
committed
Self-host all fonts
Using the Google Fonts CDN without user consent has been found to violate the GDPR (https://rewis.io/urteile/urteil/lhm-20-01-2022-3-o-1749320/), making it either legally risky or unnecessarily difficult to use. To resolve this issue, bundle the fonts we use into our application using Fontsource instead of using the Google Fonts CDN. This change has multiple other benefits as well, such as: - Font versioning, meaning our fonts aren't automatically upgraded without notice, our visuals are deterministic, etc. - The console now has no third-party service dependencies, making it theoretically usable in an isolated environment without internet access. - Particularly privacy-conscious users feel their privacy is better respected. Since Fontsource distributes fonts as npm packages, we can more or less automatically get font updates using our regular package update systems without checking binary font files into version control. Closes #58
1 parent f4b0882 commit 5f8ae5f

File tree

5 files changed

+54
-5
lines changed

5 files changed

+54
-5
lines changed

angular.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@
3131
"src/assets"
3232
],
3333
"styles": [
34+
"node_modules/@fontsource-variable/roboto/index.css",
35+
"node_modules/@fontsource/material-icons/index.css",
3436
"src/styles.scss"
3537
],
3638
"scripts": [],

package-lock.json

Lines changed: 20 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@
2121
"@angular/platform-browser": "^20.0.6",
2222
"@angular/platform-browser-dynamic": "^20.0.6",
2323
"@angular/router": "^20.0.6",
24+
"@fontsource-variable/roboto": "^5.2.10",
25+
"@fontsource/material-icons": "^5.2.7",
2426
"rxjs": "~7.8.0",
2527
"tslib": "^2.3.0",
2628
"zone.js": "~0.15.1"

src/index.html

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,6 @@
1212
<base href="/">
1313
<meta name="viewport" content="width=device-width, initial-scale=1">
1414
<link rel="icon" type="image/x-icon" href="favicon.ico">
15-
<link rel="preconnect" href="https://fonts.gstatic.com">
16-
<link href="https://fonts.googleapis.com/css2?family=Roboto:wght@300;400;500&display=swap" rel="stylesheet">
17-
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
1815
</head>
1916
<body class="mat-typography">
2017
<acc-root></acc-root>

src/styles.scss

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ html {
1717
primary: theme.$primary-palette,
1818
tertiary: theme.$tertiary-palette,
1919
),
20-
typography: Roboto,
20+
typography: "Roboto Variable",
2121
density: 0,
2222
));
2323
}
@@ -37,4 +37,32 @@ body {
3737
}
3838

3939
html, body { height: 100%; }
40-
body { margin: 0; font-family: Roboto, "Helvetica Neue", sans-serif; }
40+
body { margin: 0; font-family: "Roboto Variable", "Helvetica Neue", sans-serif; }
41+
42+
// Sourced verbatim from
43+
// https://developers.google.com/fonts/docs/material_icons#setup_method_2_self_hosting (which is
44+
// repeated at https://fontsource.org/docs/getting-started/material-icons)
45+
.material-icons {
46+
font-family: 'Material Icons';
47+
font-weight: normal;
48+
font-style: normal;
49+
font-size: 24px; /* Preferred icon size */
50+
display: inline-block;
51+
line-height: 1;
52+
text-transform: none;
53+
letter-spacing: normal;
54+
word-wrap: normal;
55+
white-space: nowrap;
56+
direction: ltr;
57+
58+
/* Support for all WebKit browsers. */
59+
-webkit-font-smoothing: antialiased;
60+
/* Support for Safari and Chrome. */
61+
text-rendering: optimizeLegibility;
62+
63+
/* Support for Firefox. */
64+
-moz-osx-font-smoothing: grayscale;
65+
66+
/* Support for IE. */
67+
font-feature-settings: 'liga';
68+
}

0 commit comments

Comments
 (0)