Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add hb_version symbol and .version member #102

Merged
merged 2 commits into from
Aug 29, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions hb.symbols
Original file line number Diff line number Diff line change
Expand Up @@ -45,5 +45,6 @@ _hb_set_destroy
_hb_set_get_population
_hb_set_next_many
_hb_shape
_hb_version
_malloc
_free
25 changes: 22 additions & 3 deletions hbjs.js
Original file line number Diff line number Diff line change
Expand Up @@ -533,15 +533,34 @@ function hbjs(Module) {
return trace;
}

function get_version() {
var major = exports.malloc(4);
var minor = exports.malloc(4);
var patch = exports.malloc(4);
heapu32[major / 4] = 0;
heapu32[minor / 4] = 0;
heapu32[patch / 4] = 0;
exports.hb_version(major, minor, patch);
let hbversion =
heapu32[major / 4] + "." + heapu32[minor / 4] + "." + heapu32[patch / 4];
exports.free(major);
exports.free(minor);
exports.free(patch);
khaledhosny marked this conversation as resolved.
Show resolved Hide resolved
return hbversion;
}

return {
createBlob: createBlob,
createFace: createFace,
createFont: createFont,
createBuffer: createBuffer,
shape: shape,
shapeWithTrace: shapeWithTrace
shapeWithTrace: shapeWithTrace,
version: get_version(),
};
};
}

// Should be replaced with something more reliable
try { module.exports = hbjs; } catch(e) {}
try {
module.exports = hbjs;
} catch (e) {}
Loading