Fix mincho font in epub iframes + eliminate emoji cover SSR flash#22
Draft
Fix mincho font in epub iframes + eliminate emoji cover SSR flash#22
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
2 Skipped Deployments
|
Co-authored-by: NarixHine <127665924+NarixHine@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Add Mincho font to English fonts in EPUB rendering
Inject mincho font into epub.js iframe for CJK fallback
Mar 1, 2026
Contributor
There was a problem hiding this comment.
Pull request overview
This PR ensures the app’s Mincho CJK font is available to epub.js-rendered content (which lives inside an iframe and cannot access the parent document’s CSS variables), restoring correct CJK fallback rendering in ebooks.
Changes:
- Adds a memoized
getMinchoFontInfo()helper that reads--font-minchofrom the parent document and extracts matching@font-facerules from accessible stylesheets. - Updates
injectThemeCSS()to prepend the extracted@font-faceCSS into the iframe<head>style injection. - Extends epub.js
rendition.themes.default()font stacks for prose/headings to include the Mincho family as a fallback.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: NarixHine <127665924+NarixHine@users.noreply.github.com>
Copilot
AI
changed the title
Inject mincho font into epub.js iframe for CJK fallback
Fix mincho font in epub.js iframe and emoji cover dark-mode on hard load
Mar 1, 2026
Co-authored-by: NarixHine <127665924+NarixHine@users.noreply.github.com>
Copilot
AI
changed the title
Fix mincho font in epub.js iframe and emoji cover dark-mode on hard load
Fix mincho font in epub iframes + eliminate emoji cover SSR flash
Mar 1, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Two bugs: CJK font never loaded inside epub.js iframes, and emoji cover backgrounds flash light→dark on hard page load in dark mode.
Font (
ebook.tsx)The stylesheet-scraping approach was fundamentally broken: Next.js hashes the font filename,
--font-minchois a comma-separated list so family-name matching failed, and even with those fixed, epub.js iframes use ablob:base URL so origin-relative paths don't resolve.Fix: copy
mincho.woff2topublic/fonts/and replace all scraping logic with two constants:injectThemeCSS()prependsMINCHO_FONT_CSS;rendition.themes.default()referencesMINCHO_EPUB_FAMILYdirectly.Emoji cover SSR flash (
emoji-cover/index.tsx+globals.css)resolvedThemeisundefineduntil after hydration, so the JS-drivenbackgroundColorinline style always renders light-first, producing a visible flash.Fix: move background color to CSS custom properties + a class selector driven by
html.dark(set synchronously by next-themes before hydration):The correct color is applied before first paint via CSS — no JS required, no flash.
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.