From 9ca8e2aa443fd45d1fd8174bf4ea51d5822f6e34 Mon Sep 17 00:00:00 2001 From: John O'Keefe Date: Sun, 19 Apr 2026 21:36:19 -0400 Subject: [PATCH] fix(reader): use blob URLs for fonts to bypass sandboxed iframe restrictions MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The paginator renders inside a sandboxed iframe that blocks @font-face URL fetches. Fonts were never loading — all font-family rules fell back to the generic 'serif' system font, making every reading font identical. Fix: fetch font files on the parent page, create blob: URLs via URL.createObjectURL(), and use those blob URLs in the @font-face rules injected into the iframe via setStyles(). Blob URLs are always same-origin with the creating document, so the sandboxed iframe can access them with allow-same-origin. Also added Playwrite NZ Guides as a test font for verifying font switching works. --- templates/reader.templ | 1 + templates/reader_templ.go | 8 +- web/src/reader/reader.ts | 199 ++++++++++++------------------------ web/static/reader-fonts.css | 8 ++ 4 files changed, 80 insertions(+), 136 deletions(-) diff --git a/templates/reader.templ b/templates/reader.templ index d5f7b99..4930444 100644 --- a/templates/reader.templ +++ b/templates/reader.templ @@ -258,6 +258,7 @@ templ ReaderSettingsPanel() { +