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 all commits
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
2 changes: 2 additions & 0 deletions hb.symbols
Original file line number Diff line number Diff line change
Expand Up @@ -45,5 +45,7 @@ _hb_set_destroy
_hb_set_get_population
_hb_set_next_many
_hb_shape
_hb_version
_hb_version_string
_malloc
_free
15 changes: 12 additions & 3 deletions hbjs.js
Original file line number Diff line number Diff line change
Expand Up @@ -533,15 +533,24 @@ function hbjs(Module) {
return trace;
}

function get_version() {
var versionPtr = exports.hb_version_string();
var version = utf8Decoder.decode(heapu8.subarray(versionPtr, heapu8.indexOf(0, versionPtr)));
return version;
}

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) {}
7 changes: 7 additions & 0 deletions test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -247,3 +247,10 @@ describe('shape', function () {
});
});
});

describe('misc', function () {
it('get version string', function () {
const version = hb.version
expect(version).to.match(/^\d+\.\d+\.\d+$/);
});
});
Loading