From 53b85469830148ebaa16b3d82e24c616fbe3d156 Mon Sep 17 00:00:00 2001 From: Jakob Scheid Date: Tue, 4 Aug 2026 14:27:30 +0200 Subject: [PATCH] feat(fonts): load all fonts specified in font configuration --- src/main.js | 20 ++++++++++++++++++++ src/styles/fonts.json | 1 + 2 files changed, 21 insertions(+) create mode 100644 src/styles/fonts.json diff --git a/src/main.js b/src/main.js index 5274388..90efd54 100644 --- a/src/main.js +++ b/src/main.js @@ -14,6 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ +import { getAssetsUrl } from './config/env'; import { createApp } from 'vue' import { createPinia } from 'pinia'; import piniaPluginPersistedstate from 'pinia-plugin-persistedstate'; @@ -25,10 +26,29 @@ import './styles/common.css' import './styles/variables/colors.css' import './styles/variables/dimensions.css'; +import rawFonts from './styles/fonts.json'; import './styles/common.css'; import './styles/variables/colors.css'; (async () => { + const fonts = rawFonts.map((font) => new FontFace( + font.family ?? '', + Array.isArray(font.source) + ? font.source.map( + (source) => `url('${source.url + ? new URL(source.url, getAssetsUrl()).href + : '' + }') format('${source.format ?? ''}')` + ).join(',') + : '', + { + weight: font.weight ?? undefined, + style: font.style ?? undefined + } + )); + await Promise.all(fonts.map((font) => font.load())); + fonts.forEach((font) => document.fonts.add(font)); + await loadLanguage(fallbackLocale); await loadLanguage(getCurrentLanguage()); diff --git a/src/styles/fonts.json b/src/styles/fonts.json new file mode 100644 index 0000000..fe51488 --- /dev/null +++ b/src/styles/fonts.json @@ -0,0 +1 @@ +[]