clove/pkviewer
web/src/lib/components/ThemeFonts.svelte
back to web/src/lib/components
<!-- web/src/lib/components/ThemeFonts.svelte -->
<script lang="ts">
import type { FontEntry } from "@pkviewer/shared";
// Families come from the fixed allow-list, so this only ever requests a font we chose
let { fonts }: { fonts: FontEntry[] } = $props();
const families = $derived(
fonts
.filter((font) => font.family !== null)
.map((font) => `family=${encodeURIComponent(font.family!).replace(/%20/g, "+")}:wght@${font.weights.join(";")}`),
);
</script>
<svelte:head>
{#if families.length > 0}
<link
rel="stylesheet"
href="https://fonts.googleapis.com/css2?{families.join('&')}&display=swap"
/>
{/if}
</svelte:head>