Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
DjDeveloperr committed May 11, 2021
1 parent 83a46f8 commit 583912d
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
3 changes: 3 additions & 0 deletions examples/image.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ ctx.fillRect(10, 10, 200 - 20, 200 - 20);
const img = await loadImage("https://cdn.discordapp.com/emojis/587737413330272291.gif?v=1");
ctx.drawImage(img, 100 - img.width() / 2, 100 - img.height() / 2);

ctx.font = '30px Impact'
console.log(ctx.measureText('3'), (ctx as any).gg.getGlyphBounds('3'));

const server = serve({ hostname: "0.0.0.0", port: 8080 });
console.log(`HTTP webserver running. Access it at: http://localhost:8080/`);

Expand Down
10 changes: 7 additions & 3 deletions lib.js
Original file line number Diff line number Diff line change
Expand Up @@ -2822,7 +2822,7 @@ export const CanvasKitInit = (function () {
},
[],
);
let actualBoundingBoxAscent = ((glyphBounds.map(e => e[1]).reduce((p, a) => p + a, 0)) * -1) / glyphBounds.length;
let actualBoundingBoxAscent = (Math.abs(glyphBounds.map(e => e[1]).reduce((p, a) => p + a, 0))) / glyphBounds.length;
return {
width,
actualBoundingBoxAscent,
Expand Down Expand Up @@ -6919,9 +6919,13 @@ export const CanvasKitInit = (function () {
a(h.instance);
}
function c(h) {
return Hb().then(function (m) {
return Promise.resolve().then(function (m) {
return new Promise((res) =>
res(new WebAssembly.Instance(wasmMod, d))
{
const inst = new WebAssembly.Instance(wasmMod, d);
storeWasm = inst;
return res(inst);
}
);
}).then(h, function (m) {
Ka("failed to asynchronously prepare wasm: " + m);
Expand Down

0 comments on commit 583912d

Please sign in to comment.