Skip to content

Commit

Permalink
feat: Self-host Roboto and Material Icons font
Browse files Browse the repository at this point in the history
Before, fonts were loaded via Google Fonts. This is an external dependency
and not compliant with GDPR. Therefore, self-host required fonts.
  • Loading branch information
MoritzWeber0 committed May 10, 2024
1 parent 928385c commit d2052a5
Show file tree
Hide file tree
Showing 18 changed files with 90 additions and 24 deletions.
13 changes: 0 additions & 13 deletions frontend/.storybook/preview-head.html

This file was deleted.

3 changes: 1 addition & 2 deletions frontend/angular.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
"browser": "src/main.ts",
"polyfills": ["src/polyfills.ts"],
"tsConfig": "tsconfig.app.json",
"assets": ["src/favicon.ico", "src/assets"],
"assets": ["src/favicon.ico", "src/assets", "src/fonts"],
"styles": [
"@angular/material/prebuilt-themes/indigo-pink.css",
"monaco-editor/min/vs/editor/editor.main.css",
Expand Down Expand Up @@ -91,7 +91,6 @@
"with": "src/environments/environment.storybook.ts"
}
]

}
},
"defaultConfiguration": "production"
Expand Down
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
SPDX-FileCopyrightText: Copyright Material Icons Authors
SPDX-License-Identifier: Apache-2.0
Binary file added frontend/src/fonts/roboto-v30-latin-300.woff2
Binary file not shown.
2 changes: 2 additions & 0 deletions frontend/src/fonts/roboto-v30-latin-300.woff2.license
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
SPDX-FileCopyrightText: Copyright Christian Robertson
SPDX-License-Identifier: Apache-2.0
Binary file not shown.
2 changes: 2 additions & 0 deletions frontend/src/fonts/roboto-v30-latin-300italic.woff2.license
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
SPDX-FileCopyrightText: Copyright Christian Robertson
SPDX-License-Identifier: Apache-2.0
Binary file added frontend/src/fonts/roboto-v30-latin-500.woff2
Binary file not shown.
2 changes: 2 additions & 0 deletions frontend/src/fonts/roboto-v30-latin-500.woff2.license
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
SPDX-FileCopyrightText: Copyright Christian Robertson
SPDX-License-Identifier: Apache-2.0
Binary file not shown.
2 changes: 2 additions & 0 deletions frontend/src/fonts/roboto-v30-latin-500italic.woff2.license
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
SPDX-FileCopyrightText: Copyright Christian Robertson
SPDX-License-Identifier: Apache-2.0
Binary file not shown.
2 changes: 2 additions & 0 deletions frontend/src/fonts/roboto-v30-latin-italic.woff2.license
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
SPDX-FileCopyrightText: Copyright Christian Robertson
SPDX-License-Identifier: Apache-2.0
Binary file added frontend/src/fonts/roboto-v30-latin-regular.woff2
Binary file not shown.
2 changes: 2 additions & 0 deletions frontend/src/fonts/roboto-v30-latin-regular.woff2.license
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
SPDX-FileCopyrightText: Copyright Christian Robertson
SPDX-License-Identifier: Apache-2.0
9 changes: 0 additions & 9 deletions frontend/src/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,6 @@
<base href="/" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<link rel="icon" type="image/x-icon" href="favicon.ico" />
<link rel="preconnect" href="https://fonts.gstatic.com" />
<link
href="https://fonts.googleapis.com/css2?family=Roboto:wght@300;400;500&display=swap"
rel="stylesheet"
/>
<link
href="https://fonts.googleapis.com/icon?family=Material+Icons"
rel="stylesheet"
/>
</head>
<body>
<app-root></app-root>
Expand Down
75 changes: 75 additions & 0 deletions frontend/src/styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,87 @@
@tailwind components;
@tailwind utilities;

@layer base {
@font-face {
font-display: swap;
font-family: "Roboto";
font-style: normal;
font-weight: 300;
src: url("fonts/roboto-v30-latin-300.woff2") format("woff2");
}
@font-face {
font-display: swap;
font-family: "Roboto";
font-style: italic;
font-weight: 300;
src: url("fonts/roboto-v30-latin-300italic.woff2") format("woff2");
}
@font-face {
font-display: swap;
font-family: "Roboto";
font-style: normal;
font-weight: 400;
src: url("fonts/roboto-v30-latin-regular.woff2") format("woff2");
}
@font-face {
font-display: swap;
font-family: "Roboto";
font-style: italic;
font-weight: 400;
src: url("fonts/roboto-v30-latin-italic.woff2") format("woff2");
}
@font-face {
font-display: swap;
font-family: "Roboto";
font-style: normal;
font-weight: 500;
src: url("fonts/roboto-v30-latin-500.woff2") format("woff2");
}
@font-face {
font-display: swap;
font-family: "Roboto";
font-style: italic;
font-weight: 500;
src: url("fonts/roboto-v30-latin-500italic.woff2") format("woff2");
}
@font-face {
font-display: swap;
font-family: "Material Icons";
font-style: normal;
font-weight: 400;
src: url("fonts/material-icons-v142-latin-regular.woff2") format("woff2");
}
}

html,
body {
height: 100%;
font-size: 100%;
}

/* Copied from https://developers.google.com/fonts/docs/material_icons#setup_method_2_self_hosting */
.material-icons {
font-family: "Material Icons";
font-weight: normal;
font-style: normal;
font-size: 24px; /* Preferred icon size */
display: inline-block;
line-height: 1;
text-transform: none;
letter-spacing: normal;
word-wrap: normal;
white-space: nowrap;
direction: ltr;

/* Support for all WebKit browsers. */
-webkit-font-smoothing: antialiased;
/* Support for Safari and Chrome. */
text-rendering: optimizeLegibility;

/* Support for Firefox. */
-moz-osx-font-smoothing: grayscale;
}

html {
overflow-y: scroll;
}
Expand Down

0 comments on commit d2052a5

Please sign in to comment.