ac4af582301a4e8a29245dbba767eba31334ddf9
2
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
3f53fa1f31 |
gui: a browser tab's font probe yields, and measures the generics once
Opening Settings in a browser tab (magpie web) held the page for 2.5 to
2.9 s on a cold start with the CPU slowed 4x (unscientific9: "冷启动进入设置"
is slow). The profile put the whole long task in webfonts.js drawn() ->
measureText: list() probed every installed family in one task, and each
probe measured monospace and serif again, so a Mac's few hundred families
cost up to four measures each, and a measure of a family not drawn yet
loads it.
Now the two generics' widths are measured once, so each family costs one
or two measures, and list() gives the page back every 8 ms.
Measured on mote (headless Chromium, 1280x820, CPU 4x, sandbox HOME with a
300k-row ledger, magpie web, Settings opened from Usage), two runs each:
- before (a build of
|
||
|
|
a1f06bd780 |
gui: a browser tab offers the fonts of the computer it runs on (Norcleeh)
Norcleeh (Discord #general): magpie in Docker, used through the web GUI,
Settings' font menu doesn't list the fonts he installed on his own
computer; the app does. Cause, confirmed in the code: a tab's list is
/api/fonts, the server's families (none in a nogui build such as Docker)
plus commonFamilies, filtered by what the browser draws. A family that
is only on the browser's computer was never offered, and a choice the
server doesn't list was dropped by desktopFonts.available.
Now (webfonts.js, which only a browser tab loads; the app's windows are
unchanged):
- Where the Local Font Access API is (Chromium on https or localhost),
the press that opens a family menu calls queryLocalFonts() once a
page, and at load when the local-fonts permission is already given.
The families join the list with their real styles ("SemiBold
Condensed Italic" -> weight 600, 75%, italic).
- Elsewhere (Safari, Firefox, a plain-http LAN address, a refused
permission) the menu's search says "Search or type a font name…" and
offers Use "name" for a family the list lacks, enabled when the canvas
probe says this browser draws it, greyed with "This browser can't find
this font" when not; Enter takes it.
- A chosen family the server doesn't list stays in the tab's list on
later loads while the browser draws it, so it keeps being applied.
- The app's menu (openProtoMenu), never a <select>. Strings in zh,
zh-TW, ja and de. docs/subsystems/gui-shell.md says so.
Budget: no raise. here() moved out of fonts.js into webfonts.js, which
isn't a core script: loadFonts import()s it in a tab only (the page has
no CSP). The core is 106 bytes smaller than origin/main's.
Run (mote-run). At this head on
|