git.lucas.co / cce-ui
GPU-accelerated UI toolkit (Vulkan)
git clone https://git.lucas.co/cce-ui.git

scripts/web-probe/demo (1.8K)

 1 #!/usr/bin/env bash
 2 # web-probe/demo <out-dir> — run the reference app (src/main.rs) on the
 3 # browser shell, in headless Chromium, through the native harness's input
 4 # script (drive.mjs), one screenshot per step into <out-dir>.
 5 #
 6 # Fonts: the native demo, run with CCE_LOAD_SYSTEM_FONTS=1, sees every system
 7 # font, and the generic families fontdb reads from fontconfig; the page is
 8 # handed the same files in the order fontdb's directory scan finds them
 9 # ($DEMO_FONTS_DIR, default /usr/share/fonts) and the same generic families
10 # ($DEMO_FAMILIES, "serif,sans,mono" — what fontdb's fontconfig reading made
11 # of this machine's config, which is not always what `fc-match` says; empty
12 # for the shell's defaults). A family the app names and the set lacks falls
13 # back through them — the text measurement to the serif family — so with
14 # either different, text is the difference you measure. Needs what `run`
15 # needs.
16 set -euo pipefail
17 here=$(cd "$(dirname "$0")" && pwd)
18 out=$(realpath -m "${1:?usage: web-probe/demo <out-dir>}")
19 fonts=${DEMO_FONTS_DIR:-/usr/share/fonts}
20 cd "$here/../.."
21 
22 cargo build --release --target wasm32-unknown-unknown --example demo_web
23 site=$(mktemp -d)
24 trap 'rm -rf "$site"' EXIT
25 wasm-bindgen --target web --no-typescript --out-dir "$site" \
26     target/wasm32-unknown-unknown/release/examples/demo_web.wasm
27 cp "$here/demo.html" "$site/demo.html"
28 ln -s "$fonts" "$site/fonts"
29 (cd "$fonts" && find . \( -type f -o -type l \) \( -iname '*.ttf' -o -iname '*.otf' -o -iname '*.ttc' -o -iname '*.otc' \) \
30     | sed 's|^\./||' | DEMO_FAMILIES="${DEMO_FAMILIES:-}" python3 -c 'import json,os,sys; print(json.dumps({"files": sys.stdin.read().split(), "families": os.environ["DEMO_FAMILIES"]}))') > "$site/fonts.json"
31 node "$here/drive.mjs" "$site" "$out"
32 echo "web-probe: screenshots in $out"