Fix #443: installed fonts outside the font folders and fonts installed while the app runs reach the font menus

The scan read only the platform's font folders, once per session (or on
Character panel menu > Refresh Font List). Fonts Windows registers outside
its font folders (installed as shortcuts, or by programs into their own
folders) never listed, nor did fonts installed while the app was open.

- Windows: the font files registered under the local machine's and the
  user's Fonts registry keys outside the scanned folders are scanned too
  (windows-registry, the windows-rs project's safe registry API).
- Linux/BSD: the XDG data folders' fonts (XDG_DATA_HOME, XDG_DATA_DIRS:
  Flatpak, Snap, NixOS, Guix) and a Flatpak sandbox's host fonts
  (/run/host/fonts, local-fonts, user-fonts); macOS: /Network/Library/Fonts.
- The global database looks the platform's paths up again at each scan,
  and a scan's roots may be font files as well as folders.
- FontDb::installed_fonts_changed compares the folders the last scan read
  (their modification times, and the paths it started from); the app
  checks it when its window comes back to the front and rescans
  (text.rescanFonts) only when fonts were installed or removed meanwhile.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
bflatasticandClaude Opus 5.5 committed 2026-10-08 14:03:53 +07:00
1 parent e2a4173337
commit 64cbee2a96
7 files changed
+239 -37

No files matched your search

+8 -3
View File
@@ -2096,15 +2096,20 @@ tone (mono, or CMYK screens multiplied over each other), clipped to the art's ou
## Fonts
Type can use the bundled fonts, fonts added to the session and the fonts installed on the system (none on the web).
The installed fonts are cataloged once per session (in the background when the app starts, else on the first lookup
Type can use the bundled fonts, fonts added to the session and the fonts installed on the system (none on the web):
the system's and the user's font folders (Windows: `Fonts` and `%LOCALAPPDATA%\Microsoft\Windows\Fonts`, plus fonts
registered outside them, such as fonts installed as shortcuts; macOS: `/System/Library/Fonts`, `/Library/Fonts`,
`/Network/Library/Fonts`, `~/Library/Fonts` and downloaded system fonts; Linux and BSD: `/usr/share/fonts`,
`/usr/local/share/fonts`, `~/.fonts` and the XDG data folders' `fonts`, `~/.local/share/fonts` among them, and in a
Flatpak sandbox the host's fonts). The installed fonts are cataloged once per session (in the background when the app starts, else on the first lookup
by family name), so opening, placing, pasting and importing files find them whatever ran before. `text.fontList`
lists every family available, the installed ones included, as the font menus do: without the system's hidden
families, whose names start with "." (macOS's ".SF NS", ".LastResort"), which still resolve when a document names
them. With `family` it gives that family's styles (upright by weight, then italics) and fails when the family isn't
available. `text.rescanFonts` (Character panel menu ›
Refresh Font List) scans the font folders again, for fonts installed or removed since the app started: type set in a
font that became available redraws in it, without editing the document.
font that became available redraws in it, without editing the document. The app does so by itself when its window
comes to the front and a font folder changed meanwhile.
```json
{"name":"run_command","arguments":{"command":"text.fontList","params":{}}}