mirror of
https://github.com/nicbarker/clay.git
synced 2026-02-06 12:48:49 +00:00
Add font preload to web renderers and update README
This commit is contained in:
parent
a4f90a217d
commit
c6ab57c638
4 changed files with 24 additions and 32 deletions
|
|
@ -4,6 +4,8 @@
|
|||
<meta charset="utf-8">
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||
<link rel="preload" href="/clay/fonts/Calistoga-Regular.ttf" as="font" type="font/ttf" crossorigin>
|
||||
<link rel="preload" href="/clay/fonts/Quicksand-Semibold.ttf" as="font" type="font/ttf" crossorigin>
|
||||
<title>Clay - UI Layout Library</title>
|
||||
<style>
|
||||
html, body {
|
||||
|
|
@ -214,18 +216,7 @@
|
|||
instance.exports.Clay_CreateArenaWithCapacityAndMemory(arenaStructAddress, memorySize, arenaMemoryAddress);
|
||||
}
|
||||
async function init() {
|
||||
await new Promise((resolve, reject) => {
|
||||
// repeatedly poll check
|
||||
const poller = setInterval(async () => {
|
||||
await Promise.all(fontsById.map(f => document.fonts.load(`12px "${f}"`)));
|
||||
console.log(`12px "${fontsById[0]}"`);
|
||||
if (document.fonts.check(`12px "${fontsById[0]}"`)) {
|
||||
clearInterval(poller);
|
||||
resolve(true);
|
||||
}
|
||||
}, 10);
|
||||
setTimeout(() => {clearInterval(poller); resolve()}, 1000);
|
||||
});
|
||||
await Promise.all(fontsById.map(f => document.fonts.load(`12px "${f}"`)));
|
||||
window.htmlRoot = document.body.appendChild(document.createElement('div'));
|
||||
window.canvasRoot = document.body.appendChild(document.createElement('canvas'));
|
||||
window.canvasContext = window.canvasRoot.getContext("2d");
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue