From 83af1453d8875c11bc1dacf7b1a7d00b88a4d5e4 Mon Sep 17 00:00:00 2001 From: Danila Poyarkov Date: Tue, 19 May 2026 13:02:15 +0300 Subject: [PATCH] fix(fonts): load Google font previews --- CHANGELOG.md | 4 ++++ src/components/FontPicker.vue | 22 ++++++++++++++++++++-- tests/e2e/fonts/picker.spec.ts | 24 ++++++++++++++++++++++-- 3 files changed, 46 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e3d0be506..db4b43eae 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,10 @@ ## Unreleased +### Fixes + +- Fix the web font picker so Google Fonts remain available in Safari, local font access is requested on first open when supported, font sources are labeled, and Google font previews load lazily for visible rows. + ## 0.12.0 — 2026-05-18 ### Added diff --git a/src/components/FontPicker.vue b/src/components/FontPicker.vue index be1bb8631..22d51b98c 100644 --- a/src/components/FontPicker.vue +++ b/src/components/FontPicker.vue @@ -4,7 +4,12 @@ import { FontPickerRoot } from '@open-pencil/vue' import { useSelectUI } from '@/components/ui/select' import { usePopoverUI } from '@/components/ui/popover' -import { listFamilies, localFontAccessState, requestLocalFontAccess } from '@/app/editor/fonts' +import { + listFamilies, + loadFont, + localFontAccessState, + requestLocalFontAccess +} from '@/app/editor/fonts' import type { FontPickerUi } from '@open-pencil/vue' @@ -29,10 +34,19 @@ const ui = computed(() => ({ emptyAction: 'mt-2 rounded bg-accent px-2 py-1 text-xs font-medium text-white disabled:opacity-50' })) +const previewFontLoads = new Set() + const localFontAccess = { state: localFontAccessState, load: requestLocalFontAccess } + +function loadPreviewFont(family: string, source: string) { + if (source !== 'google') return + if (previewFontLoads.has(family)) return + previewFontLoads.add(family) + void loadFont(family) +}