Skip to content

fix(reader): select imported custom fonts#441

Open
codedogQBY wants to merge 1 commit into
mainfrom
codex/fix-local-font-import
Open

fix(reader): select imported custom fonts#441
codedogQBY wants to merge 1 commit into
mainfrom
codex/fix-local-font-import

Conversation

@codedogQBY

Copy link
Copy Markdown
Owner

Analysis

  • 导入本地字体文件不成功 #107 reports that importing a local font does not visibly add/apply the font.
  • The import flows saved the font but left the reader on the previous selected font, so users had to manually find and select the new font after import.
  • Newly imported local/direct-url fonts also derived CSS font-family names from the display name, which can include CJK characters, spaces, or punctuation. That makes the generated @font-face and iframe CSS less robust.
  • On mobile, Android document pickers can return content:// URIs; the Expo platform file read path only handled the new File API path directly.

Changes

  • Add a stable ReadAnyCustomFont-... family helper and use it for newly imported local/direct-url fonts.
  • Let addFont(font, { select: true }) add and select a font in one store update, avoiding async index write races.
  • Auto-select fonts after desktop/mobile local import, direct URL import, and preset add.
  • Preserve the original picked filename when saving font files so the extension stays correct.
  • Quote custom font-family values consistently in app and reader @font-face CSS.
  • Add an Android content:// fallback for Expo readFile.
  • Load local mobile fonts into Expo Font for the settings-list preview when possible.
  • Explicitly clear mobile reader custom font settings when the user switches back to system default.

Verification

  • pnpm --filter app exec tsc --noEmit
  • pnpm --filter @readany/app-expo exec tsc --noEmit
  • git diff --check
  • pnpm exec biome check --write ... applied safe formatting/import fixes; full targeted check still exits non-zero on existing lint in touched files, including pre-existing label/htmlFor, noForEach/non-null assertion, and no-explicit-any diagnostics.

Fixes #107

@codedogQBY codedogQBY added bug Something isn't working priority:p1 High: important feature broken or major platform/workflow regression area:reader Reader, pagination, scrolling, layout, TOC area:import Import, download, file handling, format support labels Jun 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:import Import, download, file handling, format support area:reader Reader, pagination, scrolling, layout, TOC bug Something isn't working priority:p1 High: important feature broken or major platform/workflow regression

Projects

None yet

Development

Successfully merging this pull request may close these issues.

导入本地字体文件不成功

1 participant