mirror of
https://github.com/storytold/harfbuzz.git
synced 2026-11-22 23:41:03 +01:00
Add web_set_variations(const char *) to both the WebGL and WebGPU hb-gpu-web wasm modules. Parses a comma-separated "wght=400,wdth=100" string via hb_variation_from_string, applies via hb_font_set_variations on the current font, and rebuilds the shaping buffer. Cheap to call repeatedly -- suitable for live slider pushes once a slider UI lands. Shell.html grows a matching applyVariations() helper and a 'variations' postMessage case. config-override.h undefs HB_NO_VAR so the new function actually links. EXPORTED _FUNCTIONS on both build scripts list _web_set_variations. Also plumbed in a small cap (32 axes) on the stack so the parser doesn't need hb's internal containers -- no font has anywhere near that many. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
36 lines
1.0 KiB
Bash
Executable File
36 lines
1.0 KiB
Bash
Executable File
#!/bin/sh
|
|
|
|
# Build the hb-gpu web demo with Emscripten + WebGPU.
|
|
# Prerequisites: source emsdk/emsdk_env.sh
|
|
|
|
set -e
|
|
|
|
SRCDIR="$(cd "$(dirname "$0")/../../.." && pwd)"
|
|
OUTDIR="$(dirname "$0")/out"
|
|
|
|
mkdir -p "$OUTDIR"
|
|
|
|
em++ \
|
|
-std=c++17 \
|
|
-Oz -flto \
|
|
-I"$SRCDIR/src" \
|
|
-I"$SRCDIR/util/gpu/web" \
|
|
-DHAVE_CONFIG_H \
|
|
-DHB_GPU_NO_GLFW \
|
|
-include gl-stub.h \
|
|
"$SRCDIR/src/harfbuzz-world.cc" \
|
|
"$SRCDIR/util/gpu/demo-atlas.cc" \
|
|
"$SRCDIR/util/gpu/demo-buffer.cc" \
|
|
"$SRCDIR/util/gpu/demo-font.cc" \
|
|
"$SRCDIR/util/gpu/demo-view.cc" \
|
|
"$SRCDIR/util/gpu/web/hb-gpu-web-webgpu.cc" \
|
|
--use-port=emdawnwebgpu \
|
|
-sALLOW_MEMORY_GROWTH=1 \
|
|
-sEXPORTED_FUNCTIONS='["_main","_web_load_font","_web_set_text","_web_get_text","_web_set_variations","_web_request_redraw","_web_cancel_gesture","_malloc","_free"]' \
|
|
-sEXPORTED_RUNTIME_METHODS='["UTF8ToString","lengthBytesUTF8","stringToUTF8"]' \
|
|
--shell-file "$SRCDIR/util/gpu/web/shell.html" \
|
|
-o "$OUTDIR/webgpu.html"
|
|
|
|
echo "Built: $OUTDIR/webgpu.html"
|
|
echo "Serve: python3 -m http.server -d $OUTDIR"
|