mirror of
https://github.com/storytold/harfbuzz.git
synced 2026-11-19 22:11:04 +01:00
Web build using Emscripten + WebGL2 with HB_GPU_ATLAS_2D mode. Touch support: drag to pan, tap to toggle animation. FPS counter overlay. Viewport meta for mobile. Fix cursor position on first touch by querying glfwGetCursorPos in mouse_func. Left click/tap also toggles animation. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
50 lines
1.4 KiB
HTML
50 lines
1.4 KiB
HTML
<!DOCTYPE html>
|
|
<html>
|
|
<head>
|
|
<meta charset="utf-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no">
|
|
<title>HarfBuzz GPU Demo</title>
|
|
<style>
|
|
body { margin: 0; background: #222; overflow: hidden; touch-action: none; }
|
|
canvas { display: block; width: 100vw; height: 100vh; }
|
|
#fps { position: fixed; top: 8px; right: 12px; color: #999;
|
|
font: 14px monospace; pointer-events: none; z-index: 1; }
|
|
</style>
|
|
</head>
|
|
<body>
|
|
<div id="fps"></div>
|
|
<canvas id="canvas" oncontextmenu="event.preventDefault()" tabindex="-1"></canvas>
|
|
<script>
|
|
var canvas = document.getElementById('canvas');
|
|
function resizeCanvas () {
|
|
var dpr = window.devicePixelRatio || 1;
|
|
canvas.width = Math.round(canvas.clientWidth * dpr);
|
|
canvas.height = Math.round(canvas.clientHeight * dpr);
|
|
}
|
|
resizeCanvas();
|
|
window.addEventListener('resize', resizeCanvas);
|
|
|
|
var fpsEl = document.getElementById('fps');
|
|
var frames = 0, lastTime = performance.now();
|
|
(function fpsLoop () {
|
|
requestAnimationFrame(fpsLoop);
|
|
frames++;
|
|
var now = performance.now();
|
|
if (now - lastTime >= 1000) {
|
|
fpsEl.textContent = Math.round(frames * 1000 / (now - lastTime)) + ' fps';
|
|
frames = 0;
|
|
lastTime = now;
|
|
}
|
|
})();
|
|
|
|
var Module = {
|
|
canvas: canvas,
|
|
onRuntimeInitialized: function () {
|
|
console.log('HarfBuzz GPU Demo loaded');
|
|
}
|
|
};
|
|
</script>
|
|
{{{ SCRIPT }}}
|
|
</body>
|
|
</html>
|