Skip to content

Commit ebb06e0

Browse files
authored
Merge pull request #112 from MattMatic/Fix-JavaScript-browser-issues
Fix browser issues with 0.4.x
2 parents eee3c3e + 70969a5 commit ebb06e0

File tree

3 files changed

+12
-11
lines changed

3 files changed

+12
-11
lines changed

build.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ em++ \
1616
-DHB_EXPERIMENTAL_API \
1717
--no-entry \
1818
-s MODULARIZE \
19+
-s EXPORT_NAME=createHarfBuzz \
1920
-s EXPORTED_FUNCTIONS=@hb.symbols \
2021
-s EXPORTED_RUNTIME_METHODS='["addFunction", "wasmMemory", "wasmExports"]' \
2122
-s INITIAL_MEMORY=65MB \

examples/hbjs.example.html

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
1+
<script src="../hb.js"></script>
12
<script src="../hbjs.js"></script>
23
<script src="hbjs.example.js"></script>
34
<script>
4-
// instantiateStreaming isn't supported in Safari yet, see nohbjs.html
5-
WebAssembly.instantiateStreaming(fetch("../hb.wasm")).then(function (result) {
5+
6+
let harfBuzzModule; // not really needed with the hbjs wrapper
7+
createHarfBuzz().then(hbmodule=>{
8+
harfBuzzModule = hbmodule;
69
fetch('../test/fonts/noto/NotoSans-Regular.ttf').then(function (x) {
710
return x.arrayBuffer();
811
}).then(function (blob) {
9-
document.body.innerText = JSON.stringify(example(hbjs(result.instance), new Uint8Array(blob)), undefined, 2);
12+
document.body.innerText = JSON.stringify(example(hbjs(hbmodule), new Uint8Array(blob)), undefined, 2);
1013
document.body.style.whiteSpace = 'pre';
1114
});
1215
});

examples/nohbjs.html

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,12 @@
11
<!DOCTYPE html>
2+
<script src="../hb.js"></script>
23
<script>
34
var utf8Encoder = new TextEncoder("utf8");
45

5-
// We could use instantiateStreaming but it's not supported in Safari yet
6-
// https://bugs.webkit.org/show_bug.cgi?id=173105
7-
fetch("../hb.wasm").then(function (x) {
8-
return x.arrayBuffer();
9-
}).then(function (wasm) {
10-
return WebAssembly.instantiate(wasm);
11-
}).then(function (result) {
12-
var exports = result.instance.exports;
6+
let harfBuzzModule;
7+
createHarfBuzz().then(hbmodule=>{
8+
harfBuzzModule = hbmodule;
9+
var exports = hbmodule.wasmExports;
1310

1411
fetch('../test/fonts/noto/NotoSans-Regular.ttf').then(function (x) {
1512
return x.arrayBuffer();

0 commit comments

Comments
 (0)