harfbuzzjs 0.8.0 → 0.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -3
- package/em.runtime +0 -1
- package/hb-subset.wasm +0 -0
- package/hb.js +1 -1
- package/hb.symbols +1 -0
- package/hb.wasm +0 -0
- package/hbjs.js +38 -5
- package/package.json +1 -1
- package/test/index.js +32 -0
- package/harfbuzz.ts +0 -289
- package/tsconfig.json +0 -18
package/README.md
CHANGED
|
@@ -28,8 +28,7 @@ Download from the [releases tab](https://github.com/harfbuzz/harfbuzzjs/releases
|
|
|
28
28
|
### TL;DR
|
|
29
29
|
|
|
30
30
|
```javascript
|
|
31
|
-
|
|
32
|
-
WebAssembly.instantiateStreaming(fetch("hb.wasm")).then(function (result) {
|
|
31
|
+
require("harfbuzzjs").then(function (hb) {
|
|
33
32
|
fetch('myfont.ttf').then(function (data) {
|
|
34
33
|
return data.arrayBuffer();
|
|
35
34
|
}).then(function (fontdata) {
|
|
@@ -45,7 +44,7 @@ WebAssembly.instantiateStreaming(fetch("hb.wasm")).then(function (result) {
|
|
|
45
44
|
// Enumerate the glyphs
|
|
46
45
|
var xCursor = 0;
|
|
47
46
|
var yCursor = 0;
|
|
48
|
-
for (glyph of output) {
|
|
47
|
+
for (var glyph of output) {
|
|
49
48
|
var glyphId = glyph.g;
|
|
50
49
|
var xAdvance = glyph.ax;
|
|
51
50
|
var xDisplacement = glyph.dx;
|
|
@@ -56,6 +55,7 @@ WebAssembly.instantiateStreaming(fetch("hb.wasm")).then(function (result) {
|
|
|
56
55
|
drawAGlyph(svgPath, xCursor + xDisplacement, yDisplacement);
|
|
57
56
|
|
|
58
57
|
xCursor += xAdvance;
|
|
58
|
+
yCursor += yAdvance;
|
|
59
59
|
}
|
|
60
60
|
|
|
61
61
|
// Release memory
|
package/em.runtime
CHANGED
package/hb-subset.wasm
CHANGED
|
File without changes
|
package/hb.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var createHarfBuzz=(()=>{var _scriptName=typeof document!="undefined"?document.currentScript?.src:undefined;return async function(moduleArg={}){var moduleRtn;var Module=moduleArg;var ENVIRONMENT_IS_WEB=typeof window=="object";var ENVIRONMENT_IS_WORKER=typeof WorkerGlobalScope!="undefined";var ENVIRONMENT_IS_NODE=typeof process=="object"&&process.versions?.node&&process.type!="renderer";var arguments_=[];var thisProgram="./this.program";var quit_=(status,toThrow)=>{throw toThrow};if(typeof __filename!="undefined"){_scriptName=__filename}else if(ENVIRONMENT_IS_WORKER){_scriptName=self.location.href}var scriptDirectory="";function locateFile(path){if(Module["locateFile"]){return Module["locateFile"](path,scriptDirectory)}return scriptDirectory+path}var readAsync,readBinary;if(ENVIRONMENT_IS_NODE){var fs=require("fs");scriptDirectory=__dirname+"/";readBinary=filename=>{filename=isFileURI(filename)?new URL(filename):filename;var ret=fs.readFileSync(filename);return ret};readAsync=async(filename,binary=true)=>{filename=isFileURI(filename)?new URL(filename):filename;var ret=fs.readFileSync(filename,binary?undefined:"utf8");return ret};if(process.argv.length>1){thisProgram=process.argv[1].replace(/\\/g,"/")}arguments_=process.argv.slice(2);quit_=(status,toThrow)=>{process.exitCode=status;throw toThrow}}else if(ENVIRONMENT_IS_WEB||ENVIRONMENT_IS_WORKER){try{scriptDirectory=new URL(".",_scriptName).href}catch{}{if(ENVIRONMENT_IS_WORKER){readBinary=url=>{var xhr=new XMLHttpRequest;xhr.open("GET",url,false);xhr.responseType="arraybuffer";xhr.send(null);return new Uint8Array(xhr.response)}}readAsync=async url=>{if(isFileURI(url)){return new Promise((resolve,reject)=>{var xhr=new XMLHttpRequest;xhr.open("GET",url,true);xhr.responseType="arraybuffer";xhr.onload=()=>{if(xhr.status==200||xhr.status==0&&xhr.response){resolve(xhr.response);return}reject(xhr.status)};xhr.onerror=reject;xhr.send(null)})}var response=await fetch(url,{credentials:"same-origin"});if(response.ok){return response.arrayBuffer()}throw new Error(response.status+" : "+response.url)}}}else{}var out=console.log.bind(console);var err=console.error.bind(console);var wasmBinary;var ABORT=false;var EXITSTATUS;var isFileURI=filename=>filename.startsWith("file://");var readyPromiseResolve,readyPromiseReject;var wasmMemory;var HEAP8,HEAPU8,HEAP16,HEAPU16,HEAP32,HEAPU32,HEAPF32,HEAPF64;var HEAP64,HEAPU64;var runtimeInitialized=false;function updateMemoryViews(){var b=wasmMemory.buffer;Module["HEAP8"]=HEAP8=new Int8Array(b);HEAP16=new Int16Array(b);Module["HEAPU8"]=HEAPU8=new Uint8Array(b);Module["HEAPU16"]=HEAPU16=new Uint16Array(b);Module["HEAP32"]=HEAP32=new Int32Array(b);Module["HEAPU32"]=HEAPU32=new Uint32Array(b);Module["HEAPF32"]=HEAPF32=new Float32Array(b);HEAPF64=new Float64Array(b);HEAP64=new BigInt64Array(b);HEAPU64=new BigUint64Array(b)}function preRun(){if(Module["preRun"]){if(typeof Module["preRun"]=="function")Module["preRun"]=[Module["preRun"]];while(Module["preRun"].length){addOnPreRun(Module["preRun"].shift())}}callRuntimeCallbacks(onPreRuns)}function initRuntime(){runtimeInitialized=true;wasmExports["__wasm_call_ctors"]()}function postRun(){if(Module["postRun"]){if(typeof Module["postRun"]=="function")Module["postRun"]=[Module["postRun"]];while(Module["postRun"].length){addOnPostRun(Module["postRun"].shift())}}callRuntimeCallbacks(onPostRuns)}var runDependencies=0;var dependenciesFulfilled=null;function addRunDependency(id){runDependencies++;Module["monitorRunDependencies"]?.(runDependencies)}function removeRunDependency(id){runDependencies--;Module["monitorRunDependencies"]?.(runDependencies);if(runDependencies==0){if(dependenciesFulfilled){var callback=dependenciesFulfilled;dependenciesFulfilled=null;callback()}}}function abort(what){Module["onAbort"]?.(what);what="Aborted("+what+")";err(what);ABORT=true;what+=". Build with -sASSERTIONS for more info.";var e=new WebAssembly.RuntimeError(what);readyPromiseReject?.(e);throw e}var wasmBinaryFile;function findWasmBinary(){return locateFile("hb.wasm")}function getBinarySync(file){if(file==wasmBinaryFile&&wasmBinary){return new Uint8Array(wasmBinary)}if(readBinary){return readBinary(file)}throw"both async and sync fetching of the wasm failed"}async function getWasmBinary(binaryFile){if(!wasmBinary){try{var response=await readAsync(binaryFile);return new Uint8Array(response)}catch{}}return getBinarySync(binaryFile)}async function instantiateArrayBuffer(binaryFile,imports){try{var binary=await getWasmBinary(binaryFile);var instance=await WebAssembly.instantiate(binary,imports);return instance}catch(reason){err(`failed to asynchronously prepare wasm: ${reason}`);abort(reason)}}async function instantiateAsync(binary,binaryFile,imports){if(!binary&&!isFileURI(binaryFile)&&!ENVIRONMENT_IS_NODE){try{var response=fetch(binaryFile,{credentials:"same-origin"});var instantiationResult=await WebAssembly.instantiateStreaming(response,imports);return instantiationResult}catch(reason){err(`wasm streaming compile failed: ${reason}`);err("falling back to ArrayBuffer instantiation")}}return instantiateArrayBuffer(binaryFile,imports)}function getWasmImports(){return{env:wasmImports,wasi_snapshot_preview1:wasmImports}}async function createWasm(){function receiveInstance(instance,module){wasmExports=instance.exports;Module["wasmExports"]=wasmExports;wasmMemory=wasmExports["memory"];Module["wasmMemory"]=wasmMemory;updateMemoryViews();wasmTable=wasmExports["__indirect_function_table"];assignWasmExports(wasmExports);removeRunDependency("wasm-instantiate");return wasmExports}addRunDependency("wasm-instantiate");function receiveInstantiationResult(result){return receiveInstance(result["instance"])}var info=getWasmImports();if(Module["instantiateWasm"]){return new Promise((resolve,reject)=>{Module["instantiateWasm"](info,(mod,inst)=>{resolve(receiveInstance(mod,inst))})})}wasmBinaryFile??=findWasmBinary();var result=await instantiateAsync(wasmBinary,wasmBinaryFile,info);var exports=receiveInstantiationResult(result);return exports}class ExitStatus{name="ExitStatus";constructor(status){this.message=`Program terminated with exit(${status})`;this.status=status}}var callRuntimeCallbacks=callbacks=>{while(callbacks.length>0){callbacks.shift()(Module)}};var onPostRuns=[];var addOnPostRun=cb=>onPostRuns.push(cb);var onPreRuns=[];var addOnPreRun=cb=>onPreRuns.push(cb);var noExitRuntime=true;var stackRestore=val=>__emscripten_stack_restore(val);var stackSave=()=>_emscripten_stack_get_current();var __abort_js=()=>abort("");var runtimeKeepaliveCounter=0;var __emscripten_runtime_keepalive_clear=()=>{noExitRuntime=false;runtimeKeepaliveCounter=0};var timers={};var handleException=e=>{if(e instanceof ExitStatus||e=="unwind"){return EXITSTATUS}quit_(1,e)};var keepRuntimeAlive=()=>noExitRuntime||runtimeKeepaliveCounter>0;var _proc_exit=code=>{EXITSTATUS=code;if(!keepRuntimeAlive()){Module["onExit"]?.(code);ABORT=true}quit_(code,new ExitStatus(code))};var exitJS=(status,implicit)=>{EXITSTATUS=status;_proc_exit(status)};var _exit=exitJS;var maybeExit=()=>{if(!keepRuntimeAlive()){try{_exit(EXITSTATUS)}catch(e){handleException(e)}}};var callUserCallback=func=>{if(ABORT){return}try{func();maybeExit()}catch(e){handleException(e)}};var _emscripten_get_now=()=>performance.now();var __setitimer_js=(which,timeout_ms)=>{if(timers[which]){clearTimeout(timers[which].id);delete timers[which]}if(!timeout_ms)return 0;var id=setTimeout(()=>{delete timers[which];callUserCallback(()=>__emscripten_timeout(which,_emscripten_get_now()))},timeout_ms);timers[which]={id,timeout_ms};return 0};var getHeapMax=()=>2147483648;var alignMemory=(size,alignment)=>Math.ceil(size/alignment)*alignment;var growMemory=size=>{var oldHeapSize=wasmMemory.buffer.byteLength;var pages=(size-oldHeapSize+65535)/65536|0;try{wasmMemory.grow(pages);updateMemoryViews();return 1}catch(e){}};var _emscripten_resize_heap=requestedSize=>{var oldSize=HEAPU8.length;requestedSize>>>=0;var maxHeapSize=getHeapMax();if(requestedSize>maxHeapSize){return false}for(var cutDown=1;cutDown<=4;cutDown*=2){var overGrownHeapSize=oldSize*(1+.2/cutDown);overGrownHeapSize=Math.min(overGrownHeapSize,requestedSize+100663296);var newSize=Math.min(maxHeapSize,alignMemory(Math.max(requestedSize,overGrownHeapSize),65536));var replacement=growMemory(newSize);if(replacement){return true}}return false};var uleb128EncodeWithLen=arr=>{const n=arr.length;return[n%128|128,n>>7,...arr]};var wasmTypeCodes={i:127,p:127,j:126,f:125,d:124,e:111};var generateTypePack=types=>uleb128EncodeWithLen(Array.from(types,type=>{var code=wasmTypeCodes[type];return code}));var convertJsFunctionToWasm=(func,sig)=>{var bytes=Uint8Array.of(0,97,115,109,1,0,0,0,1,...uleb128EncodeWithLen([1,96,...generateTypePack(sig.slice(1)),...generateTypePack(sig[0]==="v"?"":sig[0])]),2,7,1,1,101,1,102,0,0,7,5,1,1,102,0,0);var module=new WebAssembly.Module(bytes);var instance=new WebAssembly.Instance(module,{e:{f:func}});var wrappedFunc=instance.exports["f"];return wrappedFunc};var wasmTable;var getWasmTableEntry=funcPtr=>wasmTable.get(funcPtr);var updateTableMap=(offset,count)=>{if(functionsInTableMap){for(var i=offset;i<offset+count;i++){var item=getWasmTableEntry(i);if(item){functionsInTableMap.set(item,i)}}}};var functionsInTableMap;var getFunctionAddress=func=>{if(!functionsInTableMap){functionsInTableMap=new WeakMap;updateTableMap(0,wasmTable.length)}return functionsInTableMap.get(func)||0};var freeTableIndexes=[];var getEmptyTableSlot=()=>{if(freeTableIndexes.length){return freeTableIndexes.pop()}return wasmTable["grow"](1)};var setWasmTableEntry=(idx,func)=>wasmTable.set(idx,func);var addFunction=(func,sig)=>{var rtn=getFunctionAddress(func);if(rtn){return rtn}var ret=getEmptyTableSlot();try{setWasmTableEntry(ret,func)}catch(err){if(!(err instanceof TypeError)){throw err}var wrapped=convertJsFunctionToWasm(func,sig);setWasmTableEntry(ret,wrapped)}functionsInTableMap.set(func,ret);return ret};var removeFunction=index=>{functionsInTableMap.delete(getWasmTableEntry(index));setWasmTableEntry(index,null);freeTableIndexes.push(index)};var stackAlloc=sz=>__emscripten_stack_alloc(sz);{if(Module["noExitRuntime"])noExitRuntime=Module["noExitRuntime"];if(Module["print"])out=Module["print"];if(Module["printErr"])err=Module["printErr"];if(Module["wasmBinary"])wasmBinary=Module["wasmBinary"];if(Module["arguments"])arguments_=Module["arguments"];if(Module["thisProgram"])thisProgram=Module["thisProgram"]}Module["wasmMemory"]=wasmMemory;Module["wasmExports"]=wasmExports;Module["stackSave"]=stackSave;Module["stackRestore"]=stackRestore;Module["stackAlloc"]=stackAlloc;Module["addFunction"]=addFunction;Module["removeFunction"]=removeFunction;var _hb_blob_create,_hb_blob_destroy,_hb_blob_get_length,_hb_blob_get_data,_hb_buffer_serialize,_hb_buffer_create,_hb_buffer_reset,_hb_buffer_reference,_hb_buffer_destroy,_hb_buffer_get_content_type,_hb_buffer_set_direction,_hb_buffer_set_script,_hb_buffer_set_language,_hb_buffer_set_flags,_hb_buffer_set_cluster_level,_hb_buffer_clear_contents,_hb_buffer_get_length,_hb_buffer_get_glyph_infos,_hb_buffer_get_glyph_positions,_hb_glyph_info_get_glyph_flags,_hb_buffer_guess_segment_properties,_hb_buffer_add_utf8,_hb_buffer_add_utf16,_hb_buffer_add_codepoints,_hb_buffer_set_message_func,_hb_language_from_string,_hb_language_to_string,_hb_script_from_string,_hb_version,_hb_version_string,_hb_feature_from_string,_malloc,_free,_hb_draw_funcs_set_move_to_func,_hb_draw_funcs_set_line_to_func,_hb_draw_funcs_set_quadratic_to_func,_hb_draw_funcs_set_cubic_to_func,_hb_draw_funcs_set_close_path_func,_hb_draw_funcs_create,_hb_draw_funcs_destroy,_hb_face_create,_hb_face_destroy,_hb_face_reference_table,_hb_face_get_upem,_hb_face_collect_unicodes,_hb_font_funcs_create,_hb_font_funcs_destroy,_hb_font_funcs_set_font_h_extents_func,_hb_font_funcs_set_font_v_extents_func,_hb_font_funcs_set_nominal_glyph_func,_hb_font_funcs_set_nominal_glyphs_func,_hb_font_funcs_set_variation_glyph_func,_hb_font_funcs_set_glyph_h_advance_func,_hb_font_funcs_set_glyph_v_advance_func,_hb_font_funcs_set_glyph_h_advances_func,_hb_font_funcs_set_glyph_v_advances_func,_hb_font_funcs_set_glyph_h_origin_func,_hb_font_funcs_set_glyph_v_origin_func,_hb_font_funcs_set_glyph_h_kerning_func,_hb_font_funcs_set_glyph_extents_func,_hb_font_funcs_set_glyph_name_func,_hb_font_funcs_set_glyph_from_name_func,_hb_font_get_h_extents,_hb_font_get_v_extents,_hb_font_get_glyph_h_advance,_hb_font_get_glyph_v_advance,_hb_font_get_glyph_h_origin,_hb_font_get_glyph_v_origin,_hb_font_get_glyph_extents,_hb_font_get_glyph_from_name,_hb_font_draw_glyph,_hb_font_glyph_to_string,_hb_font_create,_hb_font_set_variations,_hb_font_create_sub_font,_hb_font_reference,_hb_font_destroy,_hb_font_set_funcs,_hb_font_set_scale,_hb_ot_layout_table_get_script_tags,_hb_ot_layout_table_get_feature_tags,_hb_ot_layout_script_get_language_tags,_hb_ot_layout_language_get_feature_tags,_hb_ot_layout_feature_get_name_ids,_hb_ot_name_list_names,_hb_ot_name_get_utf16,_hb_set_create,_hb_set_destroy,_hb_ot_tag_to_script,_hb_ot_tag_to_language,_hb_ot_var_get_axis_infos,_hb_set_get_population,_hb_set_next_many,_hb_shape,__emscripten_timeout,__emscripten_stack_restore,__emscripten_stack_alloc,_emscripten_stack_get_current;function assignWasmExports(wasmExports){Module["_hb_blob_create"]=_hb_blob_create=wasmExports["hb_blob_create"];Module["_hb_blob_destroy"]=_hb_blob_destroy=wasmExports["hb_blob_destroy"];Module["_hb_blob_get_length"]=_hb_blob_get_length=wasmExports["hb_blob_get_length"];Module["_hb_blob_get_data"]=_hb_blob_get_data=wasmExports["hb_blob_get_data"];Module["_hb_buffer_serialize"]=_hb_buffer_serialize=wasmExports["hb_buffer_serialize"];Module["_hb_buffer_create"]=_hb_buffer_create=wasmExports["hb_buffer_create"];Module["_hb_buffer_reset"]=_hb_buffer_reset=wasmExports["hb_buffer_reset"];Module["_hb_buffer_reference"]=_hb_buffer_reference=wasmExports["hb_buffer_reference"];Module["_hb_buffer_destroy"]=_hb_buffer_destroy=wasmExports["hb_buffer_destroy"];Module["_hb_buffer_get_content_type"]=_hb_buffer_get_content_type=wasmExports["hb_buffer_get_content_type"];Module["_hb_buffer_set_direction"]=_hb_buffer_set_direction=wasmExports["hb_buffer_set_direction"];Module["_hb_buffer_set_script"]=_hb_buffer_set_script=wasmExports["hb_buffer_set_script"];Module["_hb_buffer_set_language"]=_hb_buffer_set_language=wasmExports["hb_buffer_set_language"];Module["_hb_buffer_set_flags"]=_hb_buffer_set_flags=wasmExports["hb_buffer_set_flags"];Module["_hb_buffer_set_cluster_level"]=_hb_buffer_set_cluster_level=wasmExports["hb_buffer_set_cluster_level"];Module["_hb_buffer_clear_contents"]=_hb_buffer_clear_contents=wasmExports["hb_buffer_clear_contents"];Module["_hb_buffer_get_length"]=_hb_buffer_get_length=wasmExports["hb_buffer_get_length"];Module["_hb_buffer_get_glyph_infos"]=_hb_buffer_get_glyph_infos=wasmExports["hb_buffer_get_glyph_infos"];Module["_hb_buffer_get_glyph_positions"]=_hb_buffer_get_glyph_positions=wasmExports["hb_buffer_get_glyph_positions"];Module["_hb_glyph_info_get_glyph_flags"]=_hb_glyph_info_get_glyph_flags=wasmExports["hb_glyph_info_get_glyph_flags"];Module["_hb_buffer_guess_segment_properties"]=_hb_buffer_guess_segment_properties=wasmExports["hb_buffer_guess_segment_properties"];Module["_hb_buffer_add_utf8"]=_hb_buffer_add_utf8=wasmExports["hb_buffer_add_utf8"];Module["_hb_buffer_add_utf16"]=_hb_buffer_add_utf16=wasmExports["hb_buffer_add_utf16"];Module["_hb_buffer_add_codepoints"]=_hb_buffer_add_codepoints=wasmExports["hb_buffer_add_codepoints"];Module["_hb_buffer_set_message_func"]=_hb_buffer_set_message_func=wasmExports["hb_buffer_set_message_func"];Module["_hb_language_from_string"]=_hb_language_from_string=wasmExports["hb_language_from_string"];Module["_hb_language_to_string"]=_hb_language_to_string=wasmExports["hb_language_to_string"];Module["_hb_script_from_string"]=_hb_script_from_string=wasmExports["hb_script_from_string"];Module["_hb_version"]=_hb_version=wasmExports["hb_version"];Module["_hb_version_string"]=_hb_version_string=wasmExports["hb_version_string"];Module["_hb_feature_from_string"]=_hb_feature_from_string=wasmExports["hb_feature_from_string"];Module["_malloc"]=_malloc=wasmExports["malloc"];Module["_free"]=_free=wasmExports["free"];Module["_hb_draw_funcs_set_move_to_func"]=_hb_draw_funcs_set_move_to_func=wasmExports["hb_draw_funcs_set_move_to_func"];Module["_hb_draw_funcs_set_line_to_func"]=_hb_draw_funcs_set_line_to_func=wasmExports["hb_draw_funcs_set_line_to_func"];Module["_hb_draw_funcs_set_quadratic_to_func"]=_hb_draw_funcs_set_quadratic_to_func=wasmExports["hb_draw_funcs_set_quadratic_to_func"];Module["_hb_draw_funcs_set_cubic_to_func"]=_hb_draw_funcs_set_cubic_to_func=wasmExports["hb_draw_funcs_set_cubic_to_func"];Module["_hb_draw_funcs_set_close_path_func"]=_hb_draw_funcs_set_close_path_func=wasmExports["hb_draw_funcs_set_close_path_func"];Module["_hb_draw_funcs_create"]=_hb_draw_funcs_create=wasmExports["hb_draw_funcs_create"];Module["_hb_draw_funcs_destroy"]=_hb_draw_funcs_destroy=wasmExports["hb_draw_funcs_destroy"];Module["_hb_face_create"]=_hb_face_create=wasmExports["hb_face_create"];Module["_hb_face_destroy"]=_hb_face_destroy=wasmExports["hb_face_destroy"];Module["_hb_face_reference_table"]=_hb_face_reference_table=wasmExports["hb_face_reference_table"];Module["_hb_face_get_upem"]=_hb_face_get_upem=wasmExports["hb_face_get_upem"];Module["_hb_face_collect_unicodes"]=_hb_face_collect_unicodes=wasmExports["hb_face_collect_unicodes"];Module["_hb_font_funcs_create"]=_hb_font_funcs_create=wasmExports["hb_font_funcs_create"];Module["_hb_font_funcs_destroy"]=_hb_font_funcs_destroy=wasmExports["hb_font_funcs_destroy"];Module["_hb_font_funcs_set_font_h_extents_func"]=_hb_font_funcs_set_font_h_extents_func=wasmExports["hb_font_funcs_set_font_h_extents_func"];Module["_hb_font_funcs_set_font_v_extents_func"]=_hb_font_funcs_set_font_v_extents_func=wasmExports["hb_font_funcs_set_font_v_extents_func"];Module["_hb_font_funcs_set_nominal_glyph_func"]=_hb_font_funcs_set_nominal_glyph_func=wasmExports["hb_font_funcs_set_nominal_glyph_func"];Module["_hb_font_funcs_set_nominal_glyphs_func"]=_hb_font_funcs_set_nominal_glyphs_func=wasmExports["hb_font_funcs_set_nominal_glyphs_func"];Module["_hb_font_funcs_set_variation_glyph_func"]=_hb_font_funcs_set_variation_glyph_func=wasmExports["hb_font_funcs_set_variation_glyph_func"];Module["_hb_font_funcs_set_glyph_h_advance_func"]=_hb_font_funcs_set_glyph_h_advance_func=wasmExports["hb_font_funcs_set_glyph_h_advance_func"];Module["_hb_font_funcs_set_glyph_v_advance_func"]=_hb_font_funcs_set_glyph_v_advance_func=wasmExports["hb_font_funcs_set_glyph_v_advance_func"];Module["_hb_font_funcs_set_glyph_h_advances_func"]=_hb_font_funcs_set_glyph_h_advances_func=wasmExports["hb_font_funcs_set_glyph_h_advances_func"];Module["_hb_font_funcs_set_glyph_v_advances_func"]=_hb_font_funcs_set_glyph_v_advances_func=wasmExports["hb_font_funcs_set_glyph_v_advances_func"];Module["_hb_font_funcs_set_glyph_h_origin_func"]=_hb_font_funcs_set_glyph_h_origin_func=wasmExports["hb_font_funcs_set_glyph_h_origin_func"];Module["_hb_font_funcs_set_glyph_v_origin_func"]=_hb_font_funcs_set_glyph_v_origin_func=wasmExports["hb_font_funcs_set_glyph_v_origin_func"];Module["_hb_font_funcs_set_glyph_h_kerning_func"]=_hb_font_funcs_set_glyph_h_kerning_func=wasmExports["hb_font_funcs_set_glyph_h_kerning_func"];Module["_hb_font_funcs_set_glyph_extents_func"]=_hb_font_funcs_set_glyph_extents_func=wasmExports["hb_font_funcs_set_glyph_extents_func"];Module["_hb_font_funcs_set_glyph_name_func"]=_hb_font_funcs_set_glyph_name_func=wasmExports["hb_font_funcs_set_glyph_name_func"];Module["_hb_font_funcs_set_glyph_from_name_func"]=_hb_font_funcs_set_glyph_from_name_func=wasmExports["hb_font_funcs_set_glyph_from_name_func"];Module["_hb_font_get_h_extents"]=_hb_font_get_h_extents=wasmExports["hb_font_get_h_extents"];Module["_hb_font_get_v_extents"]=_hb_font_get_v_extents=wasmExports["hb_font_get_v_extents"];Module["_hb_font_get_glyph_h_advance"]=_hb_font_get_glyph_h_advance=wasmExports["hb_font_get_glyph_h_advance"];Module["_hb_font_get_glyph_v_advance"]=_hb_font_get_glyph_v_advance=wasmExports["hb_font_get_glyph_v_advance"];Module["_hb_font_get_glyph_h_origin"]=_hb_font_get_glyph_h_origin=wasmExports["hb_font_get_glyph_h_origin"];Module["_hb_font_get_glyph_v_origin"]=_hb_font_get_glyph_v_origin=wasmExports["hb_font_get_glyph_v_origin"];Module["_hb_font_get_glyph_extents"]=_hb_font_get_glyph_extents=wasmExports["hb_font_get_glyph_extents"];Module["_hb_font_get_glyph_from_name"]=_hb_font_get_glyph_from_name=wasmExports["hb_font_get_glyph_from_name"];Module["_hb_font_draw_glyph"]=_hb_font_draw_glyph=wasmExports["hb_font_draw_glyph"];Module["_hb_font_glyph_to_string"]=_hb_font_glyph_to_string=wasmExports["hb_font_glyph_to_string"];Module["_hb_font_create"]=_hb_font_create=wasmExports["hb_font_create"];Module["_hb_font_set_variations"]=_hb_font_set_variations=wasmExports["hb_font_set_variations"];Module["_hb_font_create_sub_font"]=_hb_font_create_sub_font=wasmExports["hb_font_create_sub_font"];Module["_hb_font_reference"]=_hb_font_reference=wasmExports["hb_font_reference"];Module["_hb_font_destroy"]=_hb_font_destroy=wasmExports["hb_font_destroy"];Module["_hb_font_set_funcs"]=_hb_font_set_funcs=wasmExports["hb_font_set_funcs"];Module["_hb_font_set_scale"]=_hb_font_set_scale=wasmExports["hb_font_set_scale"];Module["_hb_ot_layout_table_get_script_tags"]=_hb_ot_layout_table_get_script_tags=wasmExports["hb_ot_layout_table_get_script_tags"];Module["_hb_ot_layout_table_get_feature_tags"]=_hb_ot_layout_table_get_feature_tags=wasmExports["hb_ot_layout_table_get_feature_tags"];Module["_hb_ot_layout_script_get_language_tags"]=_hb_ot_layout_script_get_language_tags=wasmExports["hb_ot_layout_script_get_language_tags"];Module["_hb_ot_layout_language_get_feature_tags"]=_hb_ot_layout_language_get_feature_tags=wasmExports["hb_ot_layout_language_get_feature_tags"];Module["_hb_ot_layout_feature_get_name_ids"]=_hb_ot_layout_feature_get_name_ids=wasmExports["hb_ot_layout_feature_get_name_ids"];Module["_hb_ot_name_list_names"]=_hb_ot_name_list_names=wasmExports["hb_ot_name_list_names"];Module["_hb_ot_name_get_utf16"]=_hb_ot_name_get_utf16=wasmExports["hb_ot_name_get_utf16"];Module["_hb_set_create"]=_hb_set_create=wasmExports["hb_set_create"];Module["_hb_set_destroy"]=_hb_set_destroy=wasmExports["hb_set_destroy"];Module["_hb_ot_tag_to_script"]=_hb_ot_tag_to_script=wasmExports["hb_ot_tag_to_script"];Module["_hb_ot_tag_to_language"]=_hb_ot_tag_to_language=wasmExports["hb_ot_tag_to_language"];Module["_hb_ot_var_get_axis_infos"]=_hb_ot_var_get_axis_infos=wasmExports["hb_ot_var_get_axis_infos"];Module["_hb_set_get_population"]=_hb_set_get_population=wasmExports["hb_set_get_population"];Module["_hb_set_next_many"]=_hb_set_next_many=wasmExports["hb_set_next_many"];Module["_hb_shape"]=_hb_shape=wasmExports["hb_shape"];__emscripten_timeout=wasmExports["_emscripten_timeout"];__emscripten_stack_restore=wasmExports["_emscripten_stack_restore"];__emscripten_stack_alloc=wasmExports["_emscripten_stack_alloc"];_emscripten_stack_get_current=wasmExports["emscripten_stack_get_current"]}var wasmImports={_abort_js:__abort_js,_emscripten_runtime_keepalive_clear:__emscripten_runtime_keepalive_clear,_setitimer_js:__setitimer_js,emscripten_resize_heap:_emscripten_resize_heap,proc_exit:_proc_exit};var wasmExports=await createWasm();function run(){if(runDependencies>0){dependenciesFulfilled=run;return}preRun();if(runDependencies>0){dependenciesFulfilled=run;return}function doRun(){Module["calledRun"]=true;if(ABORT)return;initRuntime();readyPromiseResolve?.(Module);Module["onRuntimeInitialized"]?.();postRun()}if(Module["setStatus"]){Module["setStatus"]("Running...");setTimeout(()=>{setTimeout(()=>Module["setStatus"](""),1);doRun()},1)}else{doRun()}}function preInit(){if(Module["preInit"]){if(typeof Module["preInit"]=="function")Module["preInit"]=[Module["preInit"]];while(Module["preInit"].length>0){Module["preInit"].shift()()}}}preInit();run();if(runtimeInitialized){moduleRtn=Module}else{moduleRtn=new Promise((resolve,reject)=>{readyPromiseResolve=resolve;readyPromiseReject=reject})}
|
|
1
|
+
var createHarfBuzz=(()=>{var _scriptName=typeof document!="undefined"?document.currentScript?.src:undefined;return async function(moduleArg={}){var moduleRtn;var Module=moduleArg;var ENVIRONMENT_IS_WEB=typeof window=="object";var ENVIRONMENT_IS_WORKER=typeof WorkerGlobalScope!="undefined";var ENVIRONMENT_IS_NODE=typeof process=="object"&&process.versions?.node&&process.type!="renderer";var arguments_=[];var thisProgram="./this.program";var quit_=(status,toThrow)=>{throw toThrow};if(typeof __filename!="undefined"){_scriptName=__filename}else if(ENVIRONMENT_IS_WORKER){_scriptName=self.location.href}var scriptDirectory="";function locateFile(path){if(Module["locateFile"]){return Module["locateFile"](path,scriptDirectory)}return scriptDirectory+path}var readAsync,readBinary;if(ENVIRONMENT_IS_NODE){var fs=require("fs");scriptDirectory=__dirname+"/";readBinary=filename=>{filename=isFileURI(filename)?new URL(filename):filename;var ret=fs.readFileSync(filename);return ret};readAsync=async(filename,binary=true)=>{filename=isFileURI(filename)?new URL(filename):filename;var ret=fs.readFileSync(filename,binary?undefined:"utf8");return ret};if(process.argv.length>1){thisProgram=process.argv[1].replace(/\\/g,"/")}arguments_=process.argv.slice(2);quit_=(status,toThrow)=>{process.exitCode=status;throw toThrow}}else if(ENVIRONMENT_IS_WEB||ENVIRONMENT_IS_WORKER){try{scriptDirectory=new URL(".",_scriptName).href}catch{}{if(ENVIRONMENT_IS_WORKER){readBinary=url=>{var xhr=new XMLHttpRequest;xhr.open("GET",url,false);xhr.responseType="arraybuffer";xhr.send(null);return new Uint8Array(xhr.response)}}readAsync=async url=>{if(isFileURI(url)){return new Promise((resolve,reject)=>{var xhr=new XMLHttpRequest;xhr.open("GET",url,true);xhr.responseType="arraybuffer";xhr.onload=()=>{if(xhr.status==200||xhr.status==0&&xhr.response){resolve(xhr.response);return}reject(xhr.status)};xhr.onerror=reject;xhr.send(null)})}var response=await fetch(url,{credentials:"same-origin"});if(response.ok){return response.arrayBuffer()}throw new Error(response.status+" : "+response.url)}}}else{}var out=console.log.bind(console);var err=console.error.bind(console);var wasmBinary;var ABORT=false;var EXITSTATUS;var isFileURI=filename=>filename.startsWith("file://");var readyPromiseResolve,readyPromiseReject;var wasmMemory;var HEAP8,HEAPU8,HEAP16,HEAPU16,HEAP32,HEAPU32,HEAPF32,HEAPF64;var HEAP64,HEAPU64;var runtimeInitialized=false;function updateMemoryViews(){var b=wasmMemory.buffer;Module["HEAP8"]=HEAP8=new Int8Array(b);HEAP16=new Int16Array(b);Module["HEAPU8"]=HEAPU8=new Uint8Array(b);Module["HEAPU16"]=HEAPU16=new Uint16Array(b);Module["HEAP32"]=HEAP32=new Int32Array(b);Module["HEAPU32"]=HEAPU32=new Uint32Array(b);Module["HEAPF32"]=HEAPF32=new Float32Array(b);HEAPF64=new Float64Array(b);HEAP64=new BigInt64Array(b);HEAPU64=new BigUint64Array(b)}function preRun(){if(Module["preRun"]){if(typeof Module["preRun"]=="function")Module["preRun"]=[Module["preRun"]];while(Module["preRun"].length){addOnPreRun(Module["preRun"].shift())}}callRuntimeCallbacks(onPreRuns)}function initRuntime(){runtimeInitialized=true;wasmExports["__wasm_call_ctors"]()}function postRun(){if(Module["postRun"]){if(typeof Module["postRun"]=="function")Module["postRun"]=[Module["postRun"]];while(Module["postRun"].length){addOnPostRun(Module["postRun"].shift())}}callRuntimeCallbacks(onPostRuns)}var runDependencies=0;var dependenciesFulfilled=null;function addRunDependency(id){runDependencies++;Module["monitorRunDependencies"]?.(runDependencies)}function removeRunDependency(id){runDependencies--;Module["monitorRunDependencies"]?.(runDependencies);if(runDependencies==0){if(dependenciesFulfilled){var callback=dependenciesFulfilled;dependenciesFulfilled=null;callback()}}}function abort(what){Module["onAbort"]?.(what);what="Aborted("+what+")";err(what);ABORT=true;what+=". Build with -sASSERTIONS for more info.";var e=new WebAssembly.RuntimeError(what);readyPromiseReject?.(e);throw e}var wasmBinaryFile;function findWasmBinary(){return locateFile("hb.wasm")}function getBinarySync(file){if(file==wasmBinaryFile&&wasmBinary){return new Uint8Array(wasmBinary)}if(readBinary){return readBinary(file)}throw"both async and sync fetching of the wasm failed"}async function getWasmBinary(binaryFile){if(!wasmBinary){try{var response=await readAsync(binaryFile);return new Uint8Array(response)}catch{}}return getBinarySync(binaryFile)}async function instantiateArrayBuffer(binaryFile,imports){try{var binary=await getWasmBinary(binaryFile);var instance=await WebAssembly.instantiate(binary,imports);return instance}catch(reason){err(`failed to asynchronously prepare wasm: ${reason}`);abort(reason)}}async function instantiateAsync(binary,binaryFile,imports){if(!binary&&!isFileURI(binaryFile)&&!ENVIRONMENT_IS_NODE){try{var response=fetch(binaryFile,{credentials:"same-origin"});var instantiationResult=await WebAssembly.instantiateStreaming(response,imports);return instantiationResult}catch(reason){err(`wasm streaming compile failed: ${reason}`);err("falling back to ArrayBuffer instantiation")}}return instantiateArrayBuffer(binaryFile,imports)}function getWasmImports(){return{env:wasmImports,wasi_snapshot_preview1:wasmImports}}async function createWasm(){function receiveInstance(instance,module){wasmExports=instance.exports;Module["wasmExports"]=wasmExports;wasmMemory=wasmExports["memory"];updateMemoryViews();wasmTable=wasmExports["__indirect_function_table"];assignWasmExports(wasmExports);removeRunDependency("wasm-instantiate");return wasmExports}addRunDependency("wasm-instantiate");function receiveInstantiationResult(result){return receiveInstance(result["instance"])}var info=getWasmImports();if(Module["instantiateWasm"]){return new Promise((resolve,reject)=>{Module["instantiateWasm"](info,(mod,inst)=>{resolve(receiveInstance(mod,inst))})})}wasmBinaryFile??=findWasmBinary();var result=await instantiateAsync(wasmBinary,wasmBinaryFile,info);var exports=receiveInstantiationResult(result);return exports}class ExitStatus{name="ExitStatus";constructor(status){this.message=`Program terminated with exit(${status})`;this.status=status}}var callRuntimeCallbacks=callbacks=>{while(callbacks.length>0){callbacks.shift()(Module)}};var onPostRuns=[];var addOnPostRun=cb=>onPostRuns.push(cb);var onPreRuns=[];var addOnPreRun=cb=>onPreRuns.push(cb);var noExitRuntime=true;var stackRestore=val=>__emscripten_stack_restore(val);var stackSave=()=>_emscripten_stack_get_current();var __abort_js=()=>abort("");var runtimeKeepaliveCounter=0;var __emscripten_runtime_keepalive_clear=()=>{noExitRuntime=false;runtimeKeepaliveCounter=0};var timers={};var handleException=e=>{if(e instanceof ExitStatus||e=="unwind"){return EXITSTATUS}quit_(1,e)};var keepRuntimeAlive=()=>noExitRuntime||runtimeKeepaliveCounter>0;var _proc_exit=code=>{EXITSTATUS=code;if(!keepRuntimeAlive()){Module["onExit"]?.(code);ABORT=true}quit_(code,new ExitStatus(code))};var exitJS=(status,implicit)=>{EXITSTATUS=status;_proc_exit(status)};var _exit=exitJS;var maybeExit=()=>{if(!keepRuntimeAlive()){try{_exit(EXITSTATUS)}catch(e){handleException(e)}}};var callUserCallback=func=>{if(ABORT){return}try{func();maybeExit()}catch(e){handleException(e)}};var _emscripten_get_now=()=>performance.now();var __setitimer_js=(which,timeout_ms)=>{if(timers[which]){clearTimeout(timers[which].id);delete timers[which]}if(!timeout_ms)return 0;var id=setTimeout(()=>{delete timers[which];callUserCallback(()=>__emscripten_timeout(which,_emscripten_get_now()))},timeout_ms);timers[which]={id,timeout_ms};return 0};var getHeapMax=()=>2147483648;var alignMemory=(size,alignment)=>Math.ceil(size/alignment)*alignment;var growMemory=size=>{var oldHeapSize=wasmMemory.buffer.byteLength;var pages=(size-oldHeapSize+65535)/65536|0;try{wasmMemory.grow(pages);updateMemoryViews();return 1}catch(e){}};var _emscripten_resize_heap=requestedSize=>{var oldSize=HEAPU8.length;requestedSize>>>=0;var maxHeapSize=getHeapMax();if(requestedSize>maxHeapSize){return false}for(var cutDown=1;cutDown<=4;cutDown*=2){var overGrownHeapSize=oldSize*(1+.2/cutDown);overGrownHeapSize=Math.min(overGrownHeapSize,requestedSize+100663296);var newSize=Math.min(maxHeapSize,alignMemory(Math.max(requestedSize,overGrownHeapSize),65536));var replacement=growMemory(newSize);if(replacement){return true}}return false};var uleb128EncodeWithLen=arr=>{const n=arr.length;return[n%128|128,n>>7,...arr]};var wasmTypeCodes={i:127,p:127,j:126,f:125,d:124,e:111};var generateTypePack=types=>uleb128EncodeWithLen(Array.from(types,type=>{var code=wasmTypeCodes[type];return code}));var convertJsFunctionToWasm=(func,sig)=>{var bytes=Uint8Array.of(0,97,115,109,1,0,0,0,1,...uleb128EncodeWithLen([1,96,...generateTypePack(sig.slice(1)),...generateTypePack(sig[0]==="v"?"":sig[0])]),2,7,1,1,101,1,102,0,0,7,5,1,1,102,0,0);var module=new WebAssembly.Module(bytes);var instance=new WebAssembly.Instance(module,{e:{f:func}});var wrappedFunc=instance.exports["f"];return wrappedFunc};var wasmTable;var getWasmTableEntry=funcPtr=>wasmTable.get(funcPtr);var updateTableMap=(offset,count)=>{if(functionsInTableMap){for(var i=offset;i<offset+count;i++){var item=getWasmTableEntry(i);if(item){functionsInTableMap.set(item,i)}}}};var functionsInTableMap;var getFunctionAddress=func=>{if(!functionsInTableMap){functionsInTableMap=new WeakMap;updateTableMap(0,wasmTable.length)}return functionsInTableMap.get(func)||0};var freeTableIndexes=[];var getEmptyTableSlot=()=>{if(freeTableIndexes.length){return freeTableIndexes.pop()}return wasmTable["grow"](1)};var setWasmTableEntry=(idx,func)=>wasmTable.set(idx,func);var addFunction=(func,sig)=>{var rtn=getFunctionAddress(func);if(rtn){return rtn}var ret=getEmptyTableSlot();try{setWasmTableEntry(ret,func)}catch(err){if(!(err instanceof TypeError)){throw err}var wrapped=convertJsFunctionToWasm(func,sig);setWasmTableEntry(ret,wrapped)}functionsInTableMap.set(func,ret);return ret};var removeFunction=index=>{functionsInTableMap.delete(getWasmTableEntry(index));setWasmTableEntry(index,null);freeTableIndexes.push(index)};var stackAlloc=sz=>__emscripten_stack_alloc(sz);{if(Module["noExitRuntime"])noExitRuntime=Module["noExitRuntime"];if(Module["print"])out=Module["print"];if(Module["printErr"])err=Module["printErr"];if(Module["wasmBinary"])wasmBinary=Module["wasmBinary"];if(Module["arguments"])arguments_=Module["arguments"];if(Module["thisProgram"])thisProgram=Module["thisProgram"]}Module["wasmExports"]=wasmExports;Module["stackSave"]=stackSave;Module["stackRestore"]=stackRestore;Module["stackAlloc"]=stackAlloc;Module["addFunction"]=addFunction;Module["removeFunction"]=removeFunction;var _hb_blob_create,_hb_blob_destroy,_hb_blob_get_length,_hb_blob_get_data,_hb_buffer_serialize,_hb_buffer_create,_hb_buffer_reset,_hb_buffer_reference,_hb_buffer_destroy,_hb_buffer_get_content_type,_hb_buffer_set_direction,_hb_buffer_set_script,_hb_buffer_set_language,_hb_buffer_set_flags,_hb_buffer_set_cluster_level,_hb_buffer_clear_contents,_hb_buffer_get_length,_hb_buffer_get_glyph_infos,_hb_buffer_get_glyph_positions,_hb_glyph_info_get_glyph_flags,_hb_buffer_guess_segment_properties,_hb_buffer_add_utf8,_hb_buffer_add_utf16,_hb_buffer_add_codepoints,_hb_buffer_set_message_func,_hb_language_from_string,_hb_language_to_string,_hb_script_from_string,_hb_version,_hb_version_string,_hb_feature_from_string,_malloc,_free,_hb_draw_funcs_set_move_to_func,_hb_draw_funcs_set_line_to_func,_hb_draw_funcs_set_quadratic_to_func,_hb_draw_funcs_set_cubic_to_func,_hb_draw_funcs_set_close_path_func,_hb_draw_funcs_create,_hb_draw_funcs_destroy,_hb_face_create,_hb_face_destroy,_hb_face_reference_table,_hb_face_get_upem,_hb_face_collect_unicodes,_hb_font_funcs_create,_hb_font_funcs_destroy,_hb_font_funcs_set_font_h_extents_func,_hb_font_funcs_set_font_v_extents_func,_hb_font_funcs_set_nominal_glyph_func,_hb_font_funcs_set_nominal_glyphs_func,_hb_font_funcs_set_variation_glyph_func,_hb_font_funcs_set_glyph_h_advance_func,_hb_font_funcs_set_glyph_v_advance_func,_hb_font_funcs_set_glyph_h_advances_func,_hb_font_funcs_set_glyph_v_advances_func,_hb_font_funcs_set_glyph_h_origin_func,_hb_font_funcs_set_glyph_v_origin_func,_hb_font_funcs_set_glyph_h_kerning_func,_hb_font_funcs_set_glyph_extents_func,_hb_font_funcs_set_glyph_name_func,_hb_font_funcs_set_glyph_from_name_func,_hb_font_get_h_extents,_hb_font_get_v_extents,_hb_font_get_glyph_h_advance,_hb_font_get_glyph_v_advance,_hb_font_get_glyph_h_origin,_hb_font_get_glyph_v_origin,_hb_font_get_glyph_extents,_hb_font_get_glyph_from_name,_hb_font_draw_glyph,_hb_font_glyph_to_string,_hb_font_create,_hb_font_set_variations,_hb_font_create_sub_font,_hb_font_reference,_hb_font_destroy,_hb_font_set_funcs,_hb_font_set_scale,_hb_ot_layout_get_glyph_class,_hb_ot_layout_table_get_script_tags,_hb_ot_layout_table_get_feature_tags,_hb_ot_layout_script_get_language_tags,_hb_ot_layout_language_get_feature_tags,_hb_ot_layout_feature_get_name_ids,_hb_ot_name_list_names,_hb_ot_name_get_utf16,_hb_set_create,_hb_set_destroy,_hb_ot_tag_to_script,_hb_ot_tag_to_language,_hb_ot_var_get_axis_infos,_hb_set_get_population,_hb_set_next_many,_hb_shape,__emscripten_timeout,__emscripten_stack_restore,__emscripten_stack_alloc,_emscripten_stack_get_current;function assignWasmExports(wasmExports){Module["_hb_blob_create"]=_hb_blob_create=wasmExports["hb_blob_create"];Module["_hb_blob_destroy"]=_hb_blob_destroy=wasmExports["hb_blob_destroy"];Module["_hb_blob_get_length"]=_hb_blob_get_length=wasmExports["hb_blob_get_length"];Module["_hb_blob_get_data"]=_hb_blob_get_data=wasmExports["hb_blob_get_data"];Module["_hb_buffer_serialize"]=_hb_buffer_serialize=wasmExports["hb_buffer_serialize"];Module["_hb_buffer_create"]=_hb_buffer_create=wasmExports["hb_buffer_create"];Module["_hb_buffer_reset"]=_hb_buffer_reset=wasmExports["hb_buffer_reset"];Module["_hb_buffer_reference"]=_hb_buffer_reference=wasmExports["hb_buffer_reference"];Module["_hb_buffer_destroy"]=_hb_buffer_destroy=wasmExports["hb_buffer_destroy"];Module["_hb_buffer_get_content_type"]=_hb_buffer_get_content_type=wasmExports["hb_buffer_get_content_type"];Module["_hb_buffer_set_direction"]=_hb_buffer_set_direction=wasmExports["hb_buffer_set_direction"];Module["_hb_buffer_set_script"]=_hb_buffer_set_script=wasmExports["hb_buffer_set_script"];Module["_hb_buffer_set_language"]=_hb_buffer_set_language=wasmExports["hb_buffer_set_language"];Module["_hb_buffer_set_flags"]=_hb_buffer_set_flags=wasmExports["hb_buffer_set_flags"];Module["_hb_buffer_set_cluster_level"]=_hb_buffer_set_cluster_level=wasmExports["hb_buffer_set_cluster_level"];Module["_hb_buffer_clear_contents"]=_hb_buffer_clear_contents=wasmExports["hb_buffer_clear_contents"];Module["_hb_buffer_get_length"]=_hb_buffer_get_length=wasmExports["hb_buffer_get_length"];Module["_hb_buffer_get_glyph_infos"]=_hb_buffer_get_glyph_infos=wasmExports["hb_buffer_get_glyph_infos"];Module["_hb_buffer_get_glyph_positions"]=_hb_buffer_get_glyph_positions=wasmExports["hb_buffer_get_glyph_positions"];Module["_hb_glyph_info_get_glyph_flags"]=_hb_glyph_info_get_glyph_flags=wasmExports["hb_glyph_info_get_glyph_flags"];Module["_hb_buffer_guess_segment_properties"]=_hb_buffer_guess_segment_properties=wasmExports["hb_buffer_guess_segment_properties"];Module["_hb_buffer_add_utf8"]=_hb_buffer_add_utf8=wasmExports["hb_buffer_add_utf8"];Module["_hb_buffer_add_utf16"]=_hb_buffer_add_utf16=wasmExports["hb_buffer_add_utf16"];Module["_hb_buffer_add_codepoints"]=_hb_buffer_add_codepoints=wasmExports["hb_buffer_add_codepoints"];Module["_hb_buffer_set_message_func"]=_hb_buffer_set_message_func=wasmExports["hb_buffer_set_message_func"];Module["_hb_language_from_string"]=_hb_language_from_string=wasmExports["hb_language_from_string"];Module["_hb_language_to_string"]=_hb_language_to_string=wasmExports["hb_language_to_string"];Module["_hb_script_from_string"]=_hb_script_from_string=wasmExports["hb_script_from_string"];Module["_hb_version"]=_hb_version=wasmExports["hb_version"];Module["_hb_version_string"]=_hb_version_string=wasmExports["hb_version_string"];Module["_hb_feature_from_string"]=_hb_feature_from_string=wasmExports["hb_feature_from_string"];Module["_malloc"]=_malloc=wasmExports["malloc"];Module["_free"]=_free=wasmExports["free"];Module["_hb_draw_funcs_set_move_to_func"]=_hb_draw_funcs_set_move_to_func=wasmExports["hb_draw_funcs_set_move_to_func"];Module["_hb_draw_funcs_set_line_to_func"]=_hb_draw_funcs_set_line_to_func=wasmExports["hb_draw_funcs_set_line_to_func"];Module["_hb_draw_funcs_set_quadratic_to_func"]=_hb_draw_funcs_set_quadratic_to_func=wasmExports["hb_draw_funcs_set_quadratic_to_func"];Module["_hb_draw_funcs_set_cubic_to_func"]=_hb_draw_funcs_set_cubic_to_func=wasmExports["hb_draw_funcs_set_cubic_to_func"];Module["_hb_draw_funcs_set_close_path_func"]=_hb_draw_funcs_set_close_path_func=wasmExports["hb_draw_funcs_set_close_path_func"];Module["_hb_draw_funcs_create"]=_hb_draw_funcs_create=wasmExports["hb_draw_funcs_create"];Module["_hb_draw_funcs_destroy"]=_hb_draw_funcs_destroy=wasmExports["hb_draw_funcs_destroy"];Module["_hb_face_create"]=_hb_face_create=wasmExports["hb_face_create"];Module["_hb_face_destroy"]=_hb_face_destroy=wasmExports["hb_face_destroy"];Module["_hb_face_reference_table"]=_hb_face_reference_table=wasmExports["hb_face_reference_table"];Module["_hb_face_get_upem"]=_hb_face_get_upem=wasmExports["hb_face_get_upem"];Module["_hb_face_collect_unicodes"]=_hb_face_collect_unicodes=wasmExports["hb_face_collect_unicodes"];Module["_hb_font_funcs_create"]=_hb_font_funcs_create=wasmExports["hb_font_funcs_create"];Module["_hb_font_funcs_destroy"]=_hb_font_funcs_destroy=wasmExports["hb_font_funcs_destroy"];Module["_hb_font_funcs_set_font_h_extents_func"]=_hb_font_funcs_set_font_h_extents_func=wasmExports["hb_font_funcs_set_font_h_extents_func"];Module["_hb_font_funcs_set_font_v_extents_func"]=_hb_font_funcs_set_font_v_extents_func=wasmExports["hb_font_funcs_set_font_v_extents_func"];Module["_hb_font_funcs_set_nominal_glyph_func"]=_hb_font_funcs_set_nominal_glyph_func=wasmExports["hb_font_funcs_set_nominal_glyph_func"];Module["_hb_font_funcs_set_nominal_glyphs_func"]=_hb_font_funcs_set_nominal_glyphs_func=wasmExports["hb_font_funcs_set_nominal_glyphs_func"];Module["_hb_font_funcs_set_variation_glyph_func"]=_hb_font_funcs_set_variation_glyph_func=wasmExports["hb_font_funcs_set_variation_glyph_func"];Module["_hb_font_funcs_set_glyph_h_advance_func"]=_hb_font_funcs_set_glyph_h_advance_func=wasmExports["hb_font_funcs_set_glyph_h_advance_func"];Module["_hb_font_funcs_set_glyph_v_advance_func"]=_hb_font_funcs_set_glyph_v_advance_func=wasmExports["hb_font_funcs_set_glyph_v_advance_func"];Module["_hb_font_funcs_set_glyph_h_advances_func"]=_hb_font_funcs_set_glyph_h_advances_func=wasmExports["hb_font_funcs_set_glyph_h_advances_func"];Module["_hb_font_funcs_set_glyph_v_advances_func"]=_hb_font_funcs_set_glyph_v_advances_func=wasmExports["hb_font_funcs_set_glyph_v_advances_func"];Module["_hb_font_funcs_set_glyph_h_origin_func"]=_hb_font_funcs_set_glyph_h_origin_func=wasmExports["hb_font_funcs_set_glyph_h_origin_func"];Module["_hb_font_funcs_set_glyph_v_origin_func"]=_hb_font_funcs_set_glyph_v_origin_func=wasmExports["hb_font_funcs_set_glyph_v_origin_func"];Module["_hb_font_funcs_set_glyph_h_kerning_func"]=_hb_font_funcs_set_glyph_h_kerning_func=wasmExports["hb_font_funcs_set_glyph_h_kerning_func"];Module["_hb_font_funcs_set_glyph_extents_func"]=_hb_font_funcs_set_glyph_extents_func=wasmExports["hb_font_funcs_set_glyph_extents_func"];Module["_hb_font_funcs_set_glyph_name_func"]=_hb_font_funcs_set_glyph_name_func=wasmExports["hb_font_funcs_set_glyph_name_func"];Module["_hb_font_funcs_set_glyph_from_name_func"]=_hb_font_funcs_set_glyph_from_name_func=wasmExports["hb_font_funcs_set_glyph_from_name_func"];Module["_hb_font_get_h_extents"]=_hb_font_get_h_extents=wasmExports["hb_font_get_h_extents"];Module["_hb_font_get_v_extents"]=_hb_font_get_v_extents=wasmExports["hb_font_get_v_extents"];Module["_hb_font_get_glyph_h_advance"]=_hb_font_get_glyph_h_advance=wasmExports["hb_font_get_glyph_h_advance"];Module["_hb_font_get_glyph_v_advance"]=_hb_font_get_glyph_v_advance=wasmExports["hb_font_get_glyph_v_advance"];Module["_hb_font_get_glyph_h_origin"]=_hb_font_get_glyph_h_origin=wasmExports["hb_font_get_glyph_h_origin"];Module["_hb_font_get_glyph_v_origin"]=_hb_font_get_glyph_v_origin=wasmExports["hb_font_get_glyph_v_origin"];Module["_hb_font_get_glyph_extents"]=_hb_font_get_glyph_extents=wasmExports["hb_font_get_glyph_extents"];Module["_hb_font_get_glyph_from_name"]=_hb_font_get_glyph_from_name=wasmExports["hb_font_get_glyph_from_name"];Module["_hb_font_draw_glyph"]=_hb_font_draw_glyph=wasmExports["hb_font_draw_glyph"];Module["_hb_font_glyph_to_string"]=_hb_font_glyph_to_string=wasmExports["hb_font_glyph_to_string"];Module["_hb_font_create"]=_hb_font_create=wasmExports["hb_font_create"];Module["_hb_font_set_variations"]=_hb_font_set_variations=wasmExports["hb_font_set_variations"];Module["_hb_font_create_sub_font"]=_hb_font_create_sub_font=wasmExports["hb_font_create_sub_font"];Module["_hb_font_reference"]=_hb_font_reference=wasmExports["hb_font_reference"];Module["_hb_font_destroy"]=_hb_font_destroy=wasmExports["hb_font_destroy"];Module["_hb_font_set_funcs"]=_hb_font_set_funcs=wasmExports["hb_font_set_funcs"];Module["_hb_font_set_scale"]=_hb_font_set_scale=wasmExports["hb_font_set_scale"];Module["_hb_ot_layout_get_glyph_class"]=_hb_ot_layout_get_glyph_class=wasmExports["hb_ot_layout_get_glyph_class"];Module["_hb_ot_layout_table_get_script_tags"]=_hb_ot_layout_table_get_script_tags=wasmExports["hb_ot_layout_table_get_script_tags"];Module["_hb_ot_layout_table_get_feature_tags"]=_hb_ot_layout_table_get_feature_tags=wasmExports["hb_ot_layout_table_get_feature_tags"];Module["_hb_ot_layout_script_get_language_tags"]=_hb_ot_layout_script_get_language_tags=wasmExports["hb_ot_layout_script_get_language_tags"];Module["_hb_ot_layout_language_get_feature_tags"]=_hb_ot_layout_language_get_feature_tags=wasmExports["hb_ot_layout_language_get_feature_tags"];Module["_hb_ot_layout_feature_get_name_ids"]=_hb_ot_layout_feature_get_name_ids=wasmExports["hb_ot_layout_feature_get_name_ids"];Module["_hb_ot_name_list_names"]=_hb_ot_name_list_names=wasmExports["hb_ot_name_list_names"];Module["_hb_ot_name_get_utf16"]=_hb_ot_name_get_utf16=wasmExports["hb_ot_name_get_utf16"];Module["_hb_set_create"]=_hb_set_create=wasmExports["hb_set_create"];Module["_hb_set_destroy"]=_hb_set_destroy=wasmExports["hb_set_destroy"];Module["_hb_ot_tag_to_script"]=_hb_ot_tag_to_script=wasmExports["hb_ot_tag_to_script"];Module["_hb_ot_tag_to_language"]=_hb_ot_tag_to_language=wasmExports["hb_ot_tag_to_language"];Module["_hb_ot_var_get_axis_infos"]=_hb_ot_var_get_axis_infos=wasmExports["hb_ot_var_get_axis_infos"];Module["_hb_set_get_population"]=_hb_set_get_population=wasmExports["hb_set_get_population"];Module["_hb_set_next_many"]=_hb_set_next_many=wasmExports["hb_set_next_many"];Module["_hb_shape"]=_hb_shape=wasmExports["hb_shape"];__emscripten_timeout=wasmExports["_emscripten_timeout"];__emscripten_stack_restore=wasmExports["_emscripten_stack_restore"];__emscripten_stack_alloc=wasmExports["_emscripten_stack_alloc"];_emscripten_stack_get_current=wasmExports["emscripten_stack_get_current"]}var wasmImports={_abort_js:__abort_js,_emscripten_runtime_keepalive_clear:__emscripten_runtime_keepalive_clear,_setitimer_js:__setitimer_js,emscripten_resize_heap:_emscripten_resize_heap,proc_exit:_proc_exit};var wasmExports=await createWasm();function run(){if(runDependencies>0){dependenciesFulfilled=run;return}preRun();if(runDependencies>0){dependenciesFulfilled=run;return}function doRun(){Module["calledRun"]=true;if(ABORT)return;initRuntime();readyPromiseResolve?.(Module);Module["onRuntimeInitialized"]?.();postRun()}if(Module["setStatus"]){Module["setStatus"]("Running...");setTimeout(()=>{setTimeout(()=>Module["setStatus"](""),1);doRun()},1)}else{doRun()}}function preInit(){if(Module["preInit"]){if(typeof Module["preInit"]=="function")Module["preInit"]=[Module["preInit"]];while(Module["preInit"].length>0){Module["preInit"].shift()()}}}preInit();run();if(runtimeInitialized){moduleRtn=Module}else{moduleRtn=new Promise((resolve,reject)=>{readyPromiseResolve=resolve;readyPromiseReject=reject})}
|
|
2
2
|
;return moduleRtn}})();if(typeof exports==="object"&&typeof module==="object"){module.exports=createHarfBuzz;module.exports.default=createHarfBuzz}else if(typeof define==="function"&&define["amd"])define([],()=>createHarfBuzz);
|
package/hb.symbols
CHANGED
|
@@ -74,6 +74,7 @@ _hb_ot_layout_table_get_script_tags
|
|
|
74
74
|
_hb_ot_layout_table_get_feature_tags
|
|
75
75
|
_hb_ot_layout_script_get_language_tags
|
|
76
76
|
_hb_ot_layout_language_get_feature_tags
|
|
77
|
+
_hb_ot_layout_get_glyph_class
|
|
77
78
|
_hb_ot_layout_feature_get_name_ids
|
|
78
79
|
_hb_ot_name_list_names
|
|
79
80
|
_hb_ot_name_get_utf16
|
package/hb.wasm
CHANGED
|
Binary file
|
package/hbjs.js
CHANGED
|
@@ -110,7 +110,7 @@ function hbjs(Module) {
|
|
|
110
110
|
|
|
111
111
|
function _string_to_utf16_ptr(text) {
|
|
112
112
|
const ptr = exports.malloc(text.length * 2);
|
|
113
|
-
const words =
|
|
113
|
+
const words = Module.HEAPU16.subarray(ptr / 2, ptr / 2 + text.length);
|
|
114
114
|
for (let i = 0; i < words.length; ++i) words[i] = text.charCodeAt(i);
|
|
115
115
|
return {
|
|
116
116
|
ptr: ptr,
|
|
@@ -325,6 +325,27 @@ function hbjs(Module) {
|
|
|
325
325
|
stackRestore(sp);
|
|
326
326
|
return tags;
|
|
327
327
|
},
|
|
328
|
+
/**
|
|
329
|
+
* Get the GDEF class of the requested glyph.
|
|
330
|
+
* @param {number} glyph The glyph to get the class of.
|
|
331
|
+
* @returns {string} The class of the glyph. Which can be either
|
|
332
|
+
* UNCLASSIFIED, BASE_GLYPH, LIGATURE, MARK, or COMPONENT.
|
|
333
|
+
**/
|
|
334
|
+
getGlyphClass: function (glyph) {
|
|
335
|
+
const gclass = exports.hb_ot_layout_get_glyph_class(ptr, glyph);
|
|
336
|
+
switch (gclass) {
|
|
337
|
+
case 0:
|
|
338
|
+
return 'UNCLASSIFIED';
|
|
339
|
+
case 1:
|
|
340
|
+
return 'BASE_GLYPH';
|
|
341
|
+
case 2:
|
|
342
|
+
return 'LIGATURE';
|
|
343
|
+
case 3:
|
|
344
|
+
return 'MARK';
|
|
345
|
+
case 4:
|
|
346
|
+
return 'COMPONENT';
|
|
347
|
+
}
|
|
348
|
+
},
|
|
328
349
|
/**
|
|
329
350
|
* Return all names in the specified face's name table.
|
|
330
351
|
**/
|
|
@@ -987,7 +1008,7 @@ function hbjs(Module) {
|
|
|
987
1008
|
*/
|
|
988
1009
|
addCodePoints: function (codePoints, itemOffset = 0, itemLength = null) {
|
|
989
1010
|
let codePointsPtr = exports.malloc(codePoints.length * 4);
|
|
990
|
-
let codePointsArray =
|
|
1011
|
+
let codePointsArray = Module.HEAPU32.subarray(codePointsPtr / 4, codePointsPtr / 4 + codePoints.length);
|
|
991
1012
|
codePointsArray.set(codePoints);
|
|
992
1013
|
if (itemLength == null) itemLength = codePoints.length;
|
|
993
1014
|
exports.hb_buffer_add_codepoints(ptr, codePointsPtr, codePoints.length, itemOffset, itemLength);
|
|
@@ -1118,10 +1139,17 @@ function hbjs(Module) {
|
|
|
1118
1139
|
var infosArray = Module.HEAPU32.subarray(infosPtr32, infosPtr32 + this.getLength() * 5);
|
|
1119
1140
|
var infos = [];
|
|
1120
1141
|
for (var i = 0; i < infosArray.length; i += 5) {
|
|
1121
|
-
|
|
1142
|
+
var info = {
|
|
1122
1143
|
codepoint: infosArray[i],
|
|
1123
1144
|
cluster: infosArray[i + 2],
|
|
1124
|
-
}
|
|
1145
|
+
};
|
|
1146
|
+
for (var [name, idx] of [['mask', 1], ['var1', 3], ['var2', 4]]) {
|
|
1147
|
+
Object.defineProperty(info, name, {
|
|
1148
|
+
value: infosArray[i + idx],
|
|
1149
|
+
enumerable: false
|
|
1150
|
+
});
|
|
1151
|
+
}
|
|
1152
|
+
infos.push(info);
|
|
1125
1153
|
}
|
|
1126
1154
|
return infos;
|
|
1127
1155
|
},
|
|
@@ -1146,12 +1174,17 @@ function hbjs(Module) {
|
|
|
1146
1174
|
var positionsArray = Module.HEAP32.subarray(positionsPtr32, positionsPtr32 + this.getLength() * 5);
|
|
1147
1175
|
var positions = [];
|
|
1148
1176
|
for (var i = 0; i < positionsArray.length; i += 5) {
|
|
1149
|
-
|
|
1177
|
+
var position = {
|
|
1150
1178
|
x_advance: positionsArray[i],
|
|
1151
1179
|
y_advance: positionsArray[i + 1],
|
|
1152
1180
|
x_offset: positionsArray[i + 2],
|
|
1153
1181
|
y_offset: positionsArray[i + 3],
|
|
1182
|
+
};
|
|
1183
|
+
Object.defineProperty(position, 'var', {
|
|
1184
|
+
value: positionsArray[i + 4],
|
|
1185
|
+
enumerable: false
|
|
1154
1186
|
});
|
|
1187
|
+
positions.push(position);
|
|
1155
1188
|
}
|
|
1156
1189
|
return positions;
|
|
1157
1190
|
},
|
package/package.json
CHANGED
package/test/index.js
CHANGED
|
@@ -111,6 +111,16 @@ describe('Face', function () {
|
|
|
111
111
|
});
|
|
112
112
|
});
|
|
113
113
|
|
|
114
|
+
it('getGlyphClass returns the class of a glyph', function () {
|
|
115
|
+
blob = hb.createBlob(fs.readFileSync(path.join(__dirname, 'fonts/noto/NotoSans-Regular.ttf')));
|
|
116
|
+
face = hb.createFace(blob);
|
|
117
|
+
font = hb.createFont(face);
|
|
118
|
+
expect(face.getGlyphClass(0)).to.equal('UNCLASSIFIED');
|
|
119
|
+
expect(face.getGlyphClass(font.glyphFromName('w'))).to.equal('BASE_GLYPH');
|
|
120
|
+
expect(face.getGlyphClass(font.glyphFromName('fi'))).to.equal('LIGATURE');
|
|
121
|
+
expect(face.getGlyphClass(font.glyphFromName('gravecomb'))).to.equal('MARK');
|
|
122
|
+
});
|
|
123
|
+
|
|
114
124
|
it('listNames fetches all names', function () {
|
|
115
125
|
blob = hb.createBlob(fs.readFileSync(path.join(__dirname, 'fonts/noto/NotoSans-Regular.ttf')));
|
|
116
126
|
face = hb.createFace(blob);
|
|
@@ -687,6 +697,27 @@ describe('Buffer', function () {
|
|
|
687
697
|
]);
|
|
688
698
|
});
|
|
689
699
|
|
|
700
|
+
it('glyph infos and positions have private properties', function () {
|
|
701
|
+
blob = hb.createBlob(fs.readFileSync(path.join(__dirname, 'fonts/noto/NotoSans-Regular.ttf')));
|
|
702
|
+
face = hb.createFace(blob);
|
|
703
|
+
font = hb.createFont(face);
|
|
704
|
+
buffer = hb.createBuffer();
|
|
705
|
+
buffer.addText('fi');
|
|
706
|
+
buffer.guessSegmentProperties();
|
|
707
|
+
hb.shape(font, buffer);
|
|
708
|
+
const infos = buffer.getGlyphInfos();
|
|
709
|
+
const positions = buffer.getGlyphPositions();
|
|
710
|
+
|
|
711
|
+
expect(infos.length).to.equal(1);
|
|
712
|
+
expect(positions.length).to.equal(1);
|
|
713
|
+
expect(Object.keys(infos[0])).to.deep.equal(['codepoint', 'cluster']);
|
|
714
|
+
expect(Object.keys(positions[0])).to.deep.equal(['x_advance', 'y_advance', 'x_offset', 'y_offset']);
|
|
715
|
+
expect(infos[0].mask).to.not.be.undefined;
|
|
716
|
+
expect(infos[0].var1).to.not.be.undefined;
|
|
717
|
+
expect(infos[0].var2).to.not.be.undefined;
|
|
718
|
+
expect(positions[0].var).to.not.be.undefined;
|
|
719
|
+
});
|
|
720
|
+
|
|
690
721
|
it('getPositions returns empty array for buffer without positions', function () {
|
|
691
722
|
blob = hb.createBlob(fs.readFileSync(path.join(__dirname, 'fonts/noto/NotoSans-Regular.ttf')));
|
|
692
723
|
face = hb.createFace(blob);
|
|
@@ -993,3 +1024,4 @@ describe('misc', function () {
|
|
|
993
1024
|
}
|
|
994
1025
|
});
|
|
995
1026
|
});
|
|
1027
|
+
|
package/harfbuzz.ts
DELETED
|
@@ -1,289 +0,0 @@
|
|
|
1
|
-
type Pointer = number;
|
|
2
|
-
|
|
3
|
-
const HB_MEMORY_MODE_WRITABLE: number = 2;
|
|
4
|
-
const HB_SET_VALUE_INVALID: Pointer = -1;
|
|
5
|
-
|
|
6
|
-
class HarfBuzzExports {
|
|
7
|
-
readonly heapu8: Uint8Array;
|
|
8
|
-
readonly heapu32: Uint32Array;
|
|
9
|
-
readonly heapi32: Int32Array;
|
|
10
|
-
readonly utf8Encoder: TextEncoder;
|
|
11
|
-
|
|
12
|
-
//exported HarfBuzz methods
|
|
13
|
-
readonly malloc: (length: number) => Pointer
|
|
14
|
-
readonly free: (ptr: Pointer) => void
|
|
15
|
-
readonly free_ptr: () => Pointer
|
|
16
|
-
readonly hb_blob_create: (data: Pointer, length: number, memoryMode: number, useData: Pointer, destroyFunction: Pointer) => Pointer
|
|
17
|
-
readonly hb_blob_destroy: (ptr: Pointer) => void
|
|
18
|
-
readonly hb_face_create: (blobPtr: Pointer, index: number) => Pointer
|
|
19
|
-
readonly hb_face_get_upem: (facePtr: Pointer) => number
|
|
20
|
-
readonly hb_face_destroy: (ptr: Pointer) => void
|
|
21
|
-
readonly hb_font_create: (facePtr: Pointer) => Pointer
|
|
22
|
-
readonly hb_font_set_scale: (fontPtr: Pointer, xScale: number, yScale: number) => void
|
|
23
|
-
readonly hb_font_destroy: (ptr: Pointer) => void
|
|
24
|
-
readonly hb_face_collect_unicodes: (facePtr: Pointer, setPtr: Pointer) => void
|
|
25
|
-
readonly hb_set_create: () => Pointer
|
|
26
|
-
readonly hb_set_destroy: (setPtr: Pointer) => void
|
|
27
|
-
readonly hb_set_get_population: (setPtr: Pointer) => number
|
|
28
|
-
readonly hb_set_next_many: (
|
|
29
|
-
setPtr: Pointer,
|
|
30
|
-
greaterThanUnicodePtr: Pointer,
|
|
31
|
-
outputU32ArrayPtr: Pointer,
|
|
32
|
-
size: number,
|
|
33
|
-
) => number
|
|
34
|
-
readonly hb_buffer_create: () => Pointer
|
|
35
|
-
readonly hb_buffer_add_utf8: (bufferPtr: Pointer, stringPtr: Pointer, stringLength: number, itemOffset: number, itemLength: number) => void
|
|
36
|
-
readonly hb_buffer_guess_segment_properties: (bufferPtr: Pointer) => void
|
|
37
|
-
readonly hb_buffer_set_direction: (bufferPtr: Pointer, direction: number) => void
|
|
38
|
-
readonly hb_shape: (fontPtr: Pointer, bufferPtr: Pointer, features: any, numFeatures: number) => void
|
|
39
|
-
readonly hb_buffer_get_length: (bufferPtr: Pointer) => number
|
|
40
|
-
readonly hb_buffer_get_glyph_infos: (bufferPtr: Pointer, length: number) => any
|
|
41
|
-
readonly hb_buffer_get_glyph_positions: (bufferPtr: Pointer, length: number) => any
|
|
42
|
-
readonly hb_buffer_destroy: (bufferPtr: Pointer) => void
|
|
43
|
-
|
|
44
|
-
constructor(exports: any) {
|
|
45
|
-
this.heapu8 = new Uint8Array(exports.memory.buffer);
|
|
46
|
-
this.heapu32 = new Uint32Array(exports.memory.buffer);
|
|
47
|
-
this.heapi32 = new Int32Array(exports.memory.buffer);
|
|
48
|
-
this.utf8Encoder = new TextEncoder();
|
|
49
|
-
|
|
50
|
-
this.malloc = exports.malloc;
|
|
51
|
-
this.free = exports.free;
|
|
52
|
-
this.free_ptr = exports.free_ptr;
|
|
53
|
-
this.hb_blob_destroy = exports.hb_blob_destroy;
|
|
54
|
-
this.hb_blob_create = exports.hb_blob_create;
|
|
55
|
-
this.hb_face_create = exports.hb_face_create;
|
|
56
|
-
this.hb_face_get_upem = exports.hb_face_get_upem;
|
|
57
|
-
this.hb_face_destroy = exports.hb_face_destroy;
|
|
58
|
-
this.hb_face_collect_unicodes = exports.hb_face_collect_unicodes;
|
|
59
|
-
this.hb_set_create = exports.hb_set_create;
|
|
60
|
-
this.hb_set_destroy = exports.hb_set_destroy;
|
|
61
|
-
this.hb_set_get_population = exports.hb_set_get_population;
|
|
62
|
-
this.hb_set_next_many = exports.hb_set_next_many;
|
|
63
|
-
this.hb_font_create = exports.hb_font_create;
|
|
64
|
-
this.hb_font_set_scale = exports.hb_font_set_scale;
|
|
65
|
-
this.hb_font_destroy = exports.hb_font_destroy;
|
|
66
|
-
this.hb_buffer_create = exports.hb_buffer_create;
|
|
67
|
-
this.hb_buffer_add_utf8 = exports.hb_buffer_add_utf8;
|
|
68
|
-
this.hb_buffer_guess_segment_properties = exports.hb_buffer_guess_segment_properties;
|
|
69
|
-
this.hb_buffer_set_direction = exports.hb_buffer_set_direction;
|
|
70
|
-
this.hb_shape = exports.hb_shape;
|
|
71
|
-
this.hb_buffer_get_length = exports.hb_buffer_get_length;
|
|
72
|
-
this.hb_buffer_get_glyph_infos = exports.hb_buffer_get_glyph_infos;
|
|
73
|
-
this.hb_buffer_get_glyph_positions = exports.hb_buffer_get_glyph_positions;
|
|
74
|
-
this.hb_buffer_destroy = exports.hb_buffer_destroy;
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
let hb: HarfBuzzExports;
|
|
80
|
-
|
|
81
|
-
class CString {
|
|
82
|
-
readonly ptr: Pointer;
|
|
83
|
-
readonly length: number;
|
|
84
|
-
|
|
85
|
-
constructor(text: string) {
|
|
86
|
-
var bytes = hb.utf8Encoder.encode(text);
|
|
87
|
-
this.ptr = hb.malloc(bytes.byteLength);
|
|
88
|
-
hb.heapu8.set(bytes, this.ptr);
|
|
89
|
-
this.length = bytes.byteLength;
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
destroy() {
|
|
93
|
-
hb.free(this.ptr);
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
export class HarfBuzzBlob {
|
|
98
|
-
readonly ptr: Pointer;
|
|
99
|
-
|
|
100
|
-
constructor(data: Uint8Array) {
|
|
101
|
-
let blobPtr = hb.malloc(data.length);
|
|
102
|
-
hb.heapu8.set(data, blobPtr);
|
|
103
|
-
this.ptr = hb.hb_blob_create(blobPtr, data.byteLength, HB_MEMORY_MODE_WRITABLE, blobPtr, hb.free_ptr());
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
destroy() {
|
|
107
|
-
hb.hb_blob_destroy(this.ptr);
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
function typedArrayFromSet<T extends 'u8' | 'u32' | 'i32'>(setPtr: Pointer, arrayType: T) {
|
|
112
|
-
const heap = hb[`heap${arrayType}`];
|
|
113
|
-
const bytesPerElment = heap.BYTES_PER_ELEMENT;
|
|
114
|
-
const setCount = hb.hb_set_get_population(setPtr);
|
|
115
|
-
const arrayPtr = hb.malloc(
|
|
116
|
-
setCount * bytesPerElment,
|
|
117
|
-
);
|
|
118
|
-
const arrayOffset = arrayPtr / bytesPerElment;
|
|
119
|
-
const array = heap.subarray(
|
|
120
|
-
arrayOffset,
|
|
121
|
-
arrayOffset + setCount,
|
|
122
|
-
) as typeof hb[`heap${T}`];
|
|
123
|
-
heap.set(array, arrayOffset);
|
|
124
|
-
hb.hb_set_next_many(
|
|
125
|
-
setPtr,
|
|
126
|
-
HB_SET_VALUE_INVALID,
|
|
127
|
-
arrayPtr,
|
|
128
|
-
setCount,
|
|
129
|
-
);
|
|
130
|
-
return array;
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
export class HarfBuzzFace {
|
|
134
|
-
readonly ptr: Pointer;
|
|
135
|
-
|
|
136
|
-
constructor(blob: HarfBuzzBlob, index: number) {
|
|
137
|
-
this.ptr = hb.hb_face_create(blob.ptr, index);
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
getUnitsPerEM() {
|
|
141
|
-
return hb.hb_face_get_upem(this.ptr);
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
collectUnicodes() {
|
|
145
|
-
const unicodeSetPtr = hb.hb_set_create();
|
|
146
|
-
hb.hb_face_collect_unicodes(this.ptr, unicodeSetPtr);
|
|
147
|
-
const result = typedArrayFromSet(unicodeSetPtr, 'u32');
|
|
148
|
-
hb.hb_set_destroy(unicodeSetPtr);
|
|
149
|
-
return result;
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
destroy() {
|
|
153
|
-
hb.hb_face_destroy(this.ptr);
|
|
154
|
-
}
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
export class HarfBuzzFont {
|
|
158
|
-
readonly ptr: Pointer
|
|
159
|
-
readonly unitsPerEM: number
|
|
160
|
-
|
|
161
|
-
constructor(face: HarfBuzzFace) {
|
|
162
|
-
this.ptr = hb.hb_font_create(face.ptr);
|
|
163
|
-
this.unitsPerEM = face.getUnitsPerEM();
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
setScale(xScale: number, yScale: number) {
|
|
167
|
-
hb.hb_font_set_scale(this.ptr, xScale, yScale);
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
destroy() {
|
|
171
|
-
hb.hb_font_destroy(this.ptr);
|
|
172
|
-
}
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
export type HarfBuzzDirection = "ltr" | "rtl" | "ttb" | "btt"
|
|
176
|
-
|
|
177
|
-
class GlyphInformation {
|
|
178
|
-
readonly GlyphId: number
|
|
179
|
-
readonly Cluster: number
|
|
180
|
-
readonly XAdvance: number
|
|
181
|
-
readonly YAdvance: number
|
|
182
|
-
readonly XOffset: number
|
|
183
|
-
readonly YOffset: number
|
|
184
|
-
|
|
185
|
-
constructor(glyphId: number, cluster: number, xAdvance: number, yAdvance: number, xOffset: number, yOffset: number) {
|
|
186
|
-
this.GlyphId = glyphId;
|
|
187
|
-
this.Cluster = cluster;
|
|
188
|
-
this.XAdvance = xAdvance;
|
|
189
|
-
this.YAdvance = yAdvance;
|
|
190
|
-
this.XOffset = xOffset;
|
|
191
|
-
this.YOffset = yOffset;
|
|
192
|
-
}
|
|
193
|
-
}
|
|
194
|
-
|
|
195
|
-
export class HarfBuzzBuffer {
|
|
196
|
-
readonly ptr: Pointer
|
|
197
|
-
|
|
198
|
-
constructor() {
|
|
199
|
-
this.ptr = hb.hb_buffer_create();
|
|
200
|
-
}
|
|
201
|
-
|
|
202
|
-
addText(text: string) {
|
|
203
|
-
let str = new CString(text);
|
|
204
|
-
hb.hb_buffer_add_utf8(this.ptr, str.ptr, str.length, 0, str.length);
|
|
205
|
-
str.destroy();
|
|
206
|
-
}
|
|
207
|
-
|
|
208
|
-
guessSegmentProperties() {
|
|
209
|
-
hb.hb_buffer_guess_segment_properties(this.ptr);
|
|
210
|
-
}
|
|
211
|
-
|
|
212
|
-
setDirection(direction: HarfBuzzDirection) {
|
|
213
|
-
let d = { "ltr": 4, "rtl": 5, "ttb": 6, "btt": 7 }[direction];
|
|
214
|
-
hb.hb_buffer_set_direction(this.ptr, d);
|
|
215
|
-
}
|
|
216
|
-
|
|
217
|
-
json() {
|
|
218
|
-
var length = hb.hb_buffer_get_length(this.ptr);
|
|
219
|
-
var result = new Array<GlyphInformation>();
|
|
220
|
-
var infosPtr32 = hb.hb_buffer_get_glyph_infos(this.ptr, 0) / 4;
|
|
221
|
-
var positionsPtr32 = hb.hb_buffer_get_glyph_positions(this.ptr, 0) / 4;
|
|
222
|
-
var infos = hb.heapu32.subarray(infosPtr32, infosPtr32 + 5 * length);
|
|
223
|
-
var positions = hb.heapi32.subarray(positionsPtr32, positionsPtr32 + 5 * length);
|
|
224
|
-
for (var i = 0; i < length; ++i) {
|
|
225
|
-
result.push(new GlyphInformation(
|
|
226
|
-
infos[i * 5 + 0],
|
|
227
|
-
infos[i * 5 + 2],
|
|
228
|
-
positions[i * 5 + 0],
|
|
229
|
-
positions[i * 5 + 1],
|
|
230
|
-
positions[i * 5 + 2],
|
|
231
|
-
positions[i * 5 + 3]));
|
|
232
|
-
}
|
|
233
|
-
return result;
|
|
234
|
-
}
|
|
235
|
-
|
|
236
|
-
destroy() {
|
|
237
|
-
hb.hb_buffer_destroy(this.ptr)
|
|
238
|
-
}
|
|
239
|
-
}
|
|
240
|
-
|
|
241
|
-
export function shape(text: string, font: HarfBuzzFont, features: any): Array<GlyphInformation> {
|
|
242
|
-
let buffer = new HarfBuzzBuffer();
|
|
243
|
-
buffer.addText(text);
|
|
244
|
-
buffer.guessSegmentProperties();
|
|
245
|
-
buffer.shape(font, features);
|
|
246
|
-
let result = buffer.json();
|
|
247
|
-
buffer.destroy();
|
|
248
|
-
return result;
|
|
249
|
-
}
|
|
250
|
-
|
|
251
|
-
export function getWidth(text: string, font: HarfBuzzFont, fontSizeInPixel: number, features: any): number {
|
|
252
|
-
let scale = fontSizeInPixel / font.unitsPerEM;
|
|
253
|
-
let shapeResult = shape(text, font, features);
|
|
254
|
-
let totalWidth = shapeResult.map((glyphInformation) => {
|
|
255
|
-
return glyphInformation.XAdvance;
|
|
256
|
-
}).reduce((previous, current, i, arr) => {
|
|
257
|
-
return previous + current;
|
|
258
|
-
}, 0.0);
|
|
259
|
-
|
|
260
|
-
return totalWidth * scale;
|
|
261
|
-
}
|
|
262
|
-
|
|
263
|
-
export const harfbuzzFonts = new Map<string, HarfBuzzFont>();
|
|
264
|
-
|
|
265
|
-
export function loadHarfbuzz(webAssemblyUrl: string): Promise<void> {
|
|
266
|
-
return fetch(webAssemblyUrl).then(response => {
|
|
267
|
-
return response.arrayBuffer();
|
|
268
|
-
}).then(wasm => {
|
|
269
|
-
return WebAssembly.instantiate(wasm);
|
|
270
|
-
}).then(result => {
|
|
271
|
-
//@ts-ignore
|
|
272
|
-
hb = new HarfBuzzExports(result.instance.exports);
|
|
273
|
-
});
|
|
274
|
-
}
|
|
275
|
-
|
|
276
|
-
export function loadAndCacheFont(fontName: string, fontUrl: string): Promise<void> {
|
|
277
|
-
return fetch(fontUrl).then((response) => {
|
|
278
|
-
return response.arrayBuffer().then((blob) => {
|
|
279
|
-
let fontBlob = new Uint8Array(blob);
|
|
280
|
-
let harfbuzzBlob = new HarfBuzzBlob(fontBlob);
|
|
281
|
-
let harfbuzzFace = new HarfBuzzFace(harfbuzzBlob, 0);
|
|
282
|
-
let harfbuzzFont = new HarfBuzzFont(harfbuzzFace);
|
|
283
|
-
|
|
284
|
-
harfbuzzFonts.set(fontName, harfbuzzFont);
|
|
285
|
-
harfbuzzFace.destroy();
|
|
286
|
-
harfbuzzBlob.destroy();
|
|
287
|
-
});
|
|
288
|
-
});
|
|
289
|
-
}
|
package/tsconfig.json
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"compileOnSave": true,
|
|
3
|
-
"compilerOptions": {
|
|
4
|
-
"module": "es6",
|
|
5
|
-
"target": "es6",
|
|
6
|
-
"sourceMap": true,
|
|
7
|
-
"alwaysStrict": true,
|
|
8
|
-
"noImplicitThis": true,
|
|
9
|
-
"noImplicitAny": true,
|
|
10
|
-
"noImplicitReturns": true,
|
|
11
|
-
"strictNullChecks": true,
|
|
12
|
-
"skipLibCheck": true,
|
|
13
|
-
"strictPropertyInitialization": true
|
|
14
|
-
},
|
|
15
|
-
"exclude": [
|
|
16
|
-
"node_modules"
|
|
17
|
-
]
|
|
18
|
-
}
|