harfbuzzjs
Advanced tools
Comparing version 0.1.5 to 0.2.0
17
hbjs.js
@@ -65,4 +65,6 @@ function hbjs(instance) { | ||
var ptr = exports.hb_face_create(blob.ptr, index); | ||
const upem = exports.hb_face_get_upem(ptr); | ||
return { | ||
ptr: ptr, | ||
upem, | ||
/** | ||
@@ -185,2 +187,13 @@ * Return the binary contents of an OpenType table. | ||
function createJsString(text) { | ||
const ptr = exports.malloc(text.length * 2); | ||
const words = new Uint16Array(exports.memory.buffer, ptr, text.length); | ||
for (let i = 0; i < words.length; ++i) words[i] = text.charCodeAt(i); | ||
return { | ||
ptr: ptr, | ||
length: words.length, | ||
free: function () { exports.free(ptr); } | ||
}; | ||
} | ||
/** | ||
@@ -198,4 +211,4 @@ * Create an object representing a Harfbuzz buffer. | ||
addText: function (text) { | ||
var str = createCString(text); | ||
exports.hb_buffer_add_utf8(ptr, str.ptr, str.length, 0, str.length); | ||
const str = createJsString(text); | ||
exports.hb_buffer_add_utf16(ptr, str.ptr, str.length, 0, str.length); | ||
str.free(); | ||
@@ -202,0 +215,0 @@ }, |
{ | ||
"name": "harfbuzzjs", | ||
"version": "0.1.5", | ||
"version": "0.2.0", | ||
"description": "Minimal version of HarfBuzz for JavaScript use", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -45,3 +45,4 @@ // Based on https://github.com/harfbuzz/harfbuzzjs/issues/9#issuecomment-507874962 | ||
exports.hb_face_destroy(subset); | ||
exports.hb_face_destroy(face); | ||
exports.free(fontBuffer); | ||
})(); |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
1245546
658