Settings: add your own fonts (.ttf/.otf) per device
Add font… picks one or more files, checks them with a bounded sfnt reader (name table family, OS/2 weight), registers them with FontLoader before storing, and chooses the new family. Added fonts list below the bundled ones with Rename and Remove; removing the chosen one falls back to System default. Bytes live in the app support directory natively and in IndexedDB on the web (localStorage is too small); a shared_preferences index names them. Limits: 10 MB per file, 40 MB total. The capture kit gains a files= step.
This commit is contained in:
@@ -53,6 +53,7 @@ In JSON, a step can also set `wait` (ms), `timeout`, `name`, `ms` and `frames`.
|
||||
| `labels=name` | write the visible semantics labels, keys and rects to JSON |
|
||||
| `film=<target>` | screencast a click for `--film-ms` (900) and write the frames plus a contact sheet |
|
||||
| `wait=ms` | sleep |
|
||||
| `files=a.ttf[,b.ttf]` | answer the next file chooser the page opens with these files (paths relative to the working directory); put it before the click that opens the picker |
|
||||
| `swipe=<target>>dx,dy` | one-finger touch swipe (needs `--touch true`, which emulates a touch screen once semantics is on) |
|
||||
| `pinch=<target>>scale` | two-finger touch pinch, spreading (>1) or closing (<1) (needs `--touch true`) |
|
||||
| `tabs=name` | write the open tabs (`{url, type}`) to JSON, e.g. to see a link open a new tab |
|
||||
|
||||
@@ -23,6 +23,7 @@ options: --script <steps.json> --size WxH (880x1000) --platform material|cuperti
|
||||
--touch true (emulate a touch screen: mobile metrics, touch input)
|
||||
steps: open=<route>[@WxH] wait=<ms> shot=<name> click=<target> waitfor=<target>
|
||||
type=<text> press=<Enter|Escape|Tab|...> scroll=<dy> size=WxH
|
||||
files=<path>[,<path>] (answers the next file chooser)
|
||||
film=<target> labels=<name> tabs=<name> eval=<js> expect=<js> hover=<target>
|
||||
drag=<target>><dx>,<dy> (JSON: drag, dx, dy, steps, gap, hold)
|
||||
swipe=<target>><dx>,<dy> pinch=<target>><scale> (with --touch true)
|
||||
@@ -113,6 +114,7 @@ try {
|
||||
break;
|
||||
}
|
||||
case 'waitfor': await page.waitFor(value, step.timeout ?? 10000); break;
|
||||
case 'files': await page.armFiles(String(value).split(',').map((p) => resolve(p))); break;
|
||||
case 'type': await page.type(String(value)); await delay(step.wait ?? settle); break;
|
||||
case 'press': await page.press(String(value)); await delay(step.wait ?? settle); break;
|
||||
case 'scroll': {
|
||||
|
||||
@@ -122,6 +122,17 @@ export function flutterPage(browser, log, { touch = false } = {}) {
|
||||
return point;
|
||||
},
|
||||
waitFor: (target, timeout) => locate(target, timeout),
|
||||
/** Answers the next file chooser the page opens with [paths] (absolute). */
|
||||
async armFiles(paths) {
|
||||
await send('Page.setInterceptFileChooserDialog', { enabled: true });
|
||||
const off = browser.on('Page.fileChooserOpened', (p) => {
|
||||
off();
|
||||
send('DOM.setFileInputFiles', { files: paths, backendNodeId: p.backendNodeId })
|
||||
.then(() => log(` chose ${paths.join(', ')}`))
|
||||
.catch((e) => errors.push(`files: ${e.message}`))
|
||||
.finally(() => send('Page.setInterceptFileChooserDialog', { enabled: false }).catch(() => {}));
|
||||
});
|
||||
},
|
||||
async type(text) {
|
||||
const focused = await evaluate(`(() => {
|
||||
const a = document.activeElement;
|
||||
|
||||
Reference in New Issue
Block a user