[PR #729] [MERGED] Fix CJK Google font shard loading #4750

Closed
opened 2026-10-22 04:10:20 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Pasta-Devs/Marinara-Engine/pull/729
Author: @Xelvanis
Created: 5/12/2026
Status: ✅ Merged
Merged: 5/12/2026
Merged by: @Xelvanis

Base: main ← Head: fix/cjk-font-prompt-encoding


📝 Commits (2)

  • 7447536 fix: preserve CJK Google font shards
  • b5d56a9 fix: allow legacy Google font reinstalls

📊 Changes

4 files changed (+418 additions, -81 deletions)

View changed files

📝 packages/client/src/App.tsx (+27 -11)
📝 packages/client/src/components/panels/SettingsPanel.tsx (+23 -3)
📝 packages/server/src/routes/fonts.routes.ts (+318 -67)
➕ packages/server/test/fonts-routes.test.ts (+50 -0)

📄 Description

Linked issue

No linked issue yet. This came from a user report that Chinese text did not receive the selected Google font even though the font family supports CJK glyphs.

Why this change

Users installing CJK Google fonts such as Noto Sans SC could see the font apply to Latin characters while Chinese characters fell back to another font. Google Fonts serves these families as unicode-range shards, but Marinara only kept a single downloaded file, so the CJK shards were missing.

What changed

  • Parse every Google Fonts @font-face block and preserve each shard's weight, style, and unicode range.
  • Register custom font faces on the client with unicode ranges so browsers can lazily fetch the shard needed for the rendered text.
  • Keep the settings dropdown grouped by family instead of showing every shard as a separate option.
  • Replace managed Google font files with a temp/backup flow so failed reinstalls can roll back instead of deleting a working font first.
  • Add focused server coverage for CJK shard parsing and display-name collapsing.

Validation

  • pnpm check passes locally
  • Container (Docker / Podman) built and ran without issue
  • Ran the app, clicked through the changes manually
  • Checked edge cases (light + dark mode, mobile viewport, empty states, error paths)
  • Above manual verification completed (describe below)
  • Read and followed CONTRIBUTING.md

Manual verification notes

Automated/local commands run by Codex:

  • pnpm --filter @marinara-engine/server exec tsx --import ./test/setup-env.ts --test test/fonts-routes.test.ts
  • pnpm --filter @marinara-engine/server lint
  • pnpm --filter @marinara-engine/client lint
  • pnpm check
  • Post-rebase pnpm check

Xel verified manual browser font install flow works as intended.

Docs and release impact

  • No docs changes needed
  • Updated docs (README / CONTRIBUTING / android/README / CHANGELOG) as needed
  • Version/release files updated (only if this PR includes a version bump)

No docs or release files were changed.

Summary by CodeRabbit

  • New Features

    • Added support for installing Google Fonts directly in the application
    • Implemented persistent font metadata storage for improved font management
    • Enhanced font information display with additional details like weight and style variants
  • Bug Fixes

    • Improved custom font deduplication to prevent duplicate entries in the font list
  • Tests

    • Added comprehensive test coverage for font management functionality

Review Change Stack


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/Pasta-Devs/Marinara-Engine/pull/729 **Author:** [@Xelvanis](https://github.com/Xelvanis) **Created:** 5/12/2026 **Status:** ✅ Merged **Merged:** 5/12/2026 **Merged by:** [@Xelvanis](https://github.com/Xelvanis) **Base:** `main` ← **Head:** `fix/cjk-font-prompt-encoding` --- ### 📝 Commits (2) - [`7447536`](https://github.com/Pasta-Devs/Marinara-Engine/commit/7447536ffdee897ba3b6f63abe3cbcd3bc4c84bb) fix: preserve CJK Google font shards - [`b5d56a9`](https://github.com/Pasta-Devs/Marinara-Engine/commit/b5d56a9f00b7970f1e3dff4250eb93aaecf8e410) fix: allow legacy Google font reinstalls ### 📊 Changes **4 files changed** (+418 additions, -81 deletions) <details> <summary>View changed files</summary> 📝 `packages/client/src/App.tsx` (+27 -11) 📝 `packages/client/src/components/panels/SettingsPanel.tsx` (+23 -3) 📝 `packages/server/src/routes/fonts.routes.ts` (+318 -67) ➕ `packages/server/test/fonts-routes.test.ts` (+50 -0) </details> ### 📄 Description ## Linked issue No linked issue yet. This came from a user report that Chinese text did not receive the selected Google font even though the font family supports CJK glyphs. ## Why this change Users installing CJK Google fonts such as Noto Sans SC could see the font apply to Latin characters while Chinese characters fell back to another font. Google Fonts serves these families as unicode-range shards, but Marinara only kept a single downloaded file, so the CJK shards were missing. ## What changed - Parse every Google Fonts `@font-face` block and preserve each shard's weight, style, and unicode range. - Register custom font faces on the client with unicode ranges so browsers can lazily fetch the shard needed for the rendered text. - Keep the settings dropdown grouped by family instead of showing every shard as a separate option. - Replace managed Google font files with a temp/backup flow so failed reinstalls can roll back instead of deleting a working font first. - Add focused server coverage for CJK shard parsing and display-name collapsing. ## Validation - [x] `pnpm check` passes locally - [ ] Container (Docker / Podman) built and ran without issue - [x] Ran the app, clicked through the changes manually - [ ] Checked edge cases (light + dark mode, mobile viewport, empty states, error paths) - [x] Above manual verification completed (describe below) - [x] Read and followed `CONTRIBUTING.md` ### Manual verification notes Automated/local commands run by Codex: - `pnpm --filter @marinara-engine/server exec tsx --import ./test/setup-env.ts --test test/fonts-routes.test.ts` - `pnpm --filter @marinara-engine/server lint` - `pnpm --filter @marinara-engine/client lint` - `pnpm check` - Post-rebase `pnpm check` Xel verified manual browser font install flow works as intended. ## Docs and release impact - [x] No docs changes needed - [ ] Updated docs (README / CONTRIBUTING / android/README / CHANGELOG) as needed - [ ] Version/release files updated (only if this PR includes a version bump) No docs or release files were changed. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **New Features** * Added support for installing Google Fonts directly in the application * Implemented persistent font metadata storage for improved font management * Enhanced font information display with additional details like weight and style variants * **Bug Fixes** * Improved custom font deduplication to prevent duplicate entries in the font list * **Tests** * Added comprehensive test coverage for font management functionality [![Review Change Stack](https://storage.googleapis.com/coderabbit_public_assets/review-stack-in-coderabbit-ui.svg)](https://app.coderabbit.ai/change-stack/Pasta-Devs/Marinara-Engine/pull/729) <!-- end of auto-generated comment: release notes by coderabbit.ai --> --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-22 04:10:20 +07:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Pasta-Devs/Marinara-Engine#4750
No description provided.