Add font: own web file chooser, so a picked font is never dropped silently

file_picker's web picker treated the window regaining focus as a cancel when
the files arrived more than 500 ms later, so a real dialog could return an
empty pick and Add font did nothing. The web now uses its own file input that
completes only on change or cancel; mobile browsers get no accept filter.
Picker, check and save failures are shown in a dialog, and the row is busy
only after files were chosen.
This commit is contained in:
2026-11-04 20:47:43 +00:00
parent 1d025bebf3
commit 081ae0957d
8 changed files with 361 additions and 32 deletions
+24 -3
View File
@@ -45,9 +45,14 @@ same compressed amount (not measured).
## Fonts the user adds
Settings > Font ends with **Add font…**. It opens the host picker
(`file_picker`; .ttf/.otf filter on the web and Apple hosts, every file on
Android, whose document picker filters by MIME type), then:
Settings > Font ends with **Add font…**. It opens the host picker, then:
natively `file_picker` (.ttf/.otf filter on Apple and desktop hosts, every
file on Android, whose document picker filters by MIME type); on the web
its own `<input type=file>` (`custom_fonts/font_file_picker_web.dart`),
filtered to .ttf/.otf in desktop browsers and unfiltered in Android/iOS
browsers, where font MIME mapping is inconsistent. Every failure after the
pick (unreadable file, wrong type, picker, load or storage error) is said in
a dialog; the row is busy only once files were chosen.
1. `CustomFontDraft.inspect` refuses other extensions, files over 10 MB,
more than 16 files at once, two files of the same weight and style, and a
@@ -118,3 +123,19 @@ face; the options menu and action sheet; rename to "Body face"; the remove
confirmation; the fallback to System default; and a fake `.ttf` refused
with "“fake.ttf” cannot be used: The file is too short." Android and iOS
were not run on a device.
### Fix: “Add font… does nothing” in the browser
`file_picker`'s web picker (`cancelUploadOnWindowBlur`, on by default)
treats the window regaining focus as a cancel unless the chosen files arrive
within 500 ms. A real dialog returns focus before the browser delivers the
files, so a slow delivery became an empty pick and the action returned
silently. The capture kit's `files=` step answers the chooser without any
focus change, which hid it. Reproduced on the release build (the installed
web app and the fixture) in Chrome with a canvas mouse click (semantics off),
`Page.setInterceptFileChooserDialog` + `DOM.setFileInputFiles`, and a window
`focus` 700 ms before the files: the old build dropped the font; the new one
shows the name dialog and adds it. Also checked: two files added and chosen,
OFL.txt refused with a message, and a 560x1600 Android-UA touch run (no
`accept` filter, name dialog shown). Safari/iOS and the Android app were not
run on a device.