Skip to content

Commit

Permalink
Fix type errors from updating mem module
Browse files Browse the repository at this point in the history
  • Loading branch information
thetarnav committed Jan 11, 2025
1 parent efeac69 commit cf2073a
Showing 1 changed file with 17 additions and 17 deletions.
34 changes: 17 additions & 17 deletions wasm/ctx2d/ctx2d.js
Original file line number Diff line number Diff line change
Expand Up @@ -513,23 +513,23 @@ export function make_odin_ctx2d(wasm, s) {
/** @type {number} */ text_len,
/** @type {number} */ ptr,
) {
const text = mem.load_string_raw(wasm.memory.buffer, text_ptr, text_len)
const metrics = s.ctx.measureText(text)
const offset = new mem.ByteOffset(ptr)
const data = new DataView(wasm.memory.buffer)

mem.store_offset_f32(data, offset, metrics.actualBoundingBoxAscent)
mem.store_offset_f32(data, offset, metrics.actualBoundingBoxDescent)
mem.store_offset_f32(data, offset, metrics.actualBoundingBoxLeft)
mem.store_offset_f32(data, offset, metrics.actualBoundingBoxRight)
mem.store_offset_f32(data, offset, metrics.alphabeticBaseline)
mem.store_offset_f32(data, offset, metrics.emHeightAscent)
mem.store_offset_f32(data, offset, metrics.emHeightDescent)
mem.store_offset_f32(data, offset, metrics.fontBoundingBoxAscent)
mem.store_offset_f32(data, offset, metrics.fontBoundingBoxDescent)
mem.store_offset_f32(data, offset, metrics.hangingBaseline)
mem.store_offset_f32(data, offset, metrics.ideographicBaseline)
mem.store_offset_f32(data, offset, metrics.width)
let text = mem.load_string_raw(wasm.memory.buffer, text_ptr, text_len)
let metrics = s.ctx.measureText(text)
let data = new DataView(wasm.memory.buffer)
let cursor = mem.make_cursor(data, ptr)

mem.cursor_store_f32(data, cursor, metrics.actualBoundingBoxAscent)
mem.cursor_store_f32(data, cursor, metrics.actualBoundingBoxDescent)
mem.cursor_store_f32(data, cursor, metrics.actualBoundingBoxLeft)
mem.cursor_store_f32(data, cursor, metrics.actualBoundingBoxRight)
mem.cursor_store_f32(data, cursor, metrics.alphabeticBaseline)
mem.cursor_store_f32(data, cursor, metrics.emHeightAscent)
mem.cursor_store_f32(data, cursor, metrics.emHeightDescent)
mem.cursor_store_f32(data, cursor, metrics.fontBoundingBoxAscent)
mem.cursor_store_f32(data, cursor, metrics.fontBoundingBoxDescent)
mem.cursor_store_f32(data, cursor, metrics.hangingBaseline)
mem.cursor_store_f32(data, cursor, metrics.ideographicBaseline)
mem.cursor_store_f32(data, cursor, metrics.width)
},

// ------------------------------ /
Expand Down

0 comments on commit cf2073a

Please sign in to comment.