harfbuzzjs 0.7.0 → 0.8.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/hb-subset.wasm +0 -0
- package/hb.js +1 -1
- package/hb.symbols +4 -1
- package/hb.wasm +0 -0
- package/hbjs.js +284 -129
- package/package.json +1 -1
- package/test/index.js +191 -4
- package/.vscode/settings.json +0 -3
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_glyphs,_hb_buffer_create,_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_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_glyphs"]=_hb_buffer_serialize_glyphs=wasmExports["hb_buffer_serialize_glyphs"];Module["_hb_buffer_create"]=_hb_buffer_create=wasmExports["hb_buffer_create"];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_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"];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})}
|
|
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
|
@@ -6,6 +6,7 @@ _hb_buffer_add_utf16
|
|
|
6
6
|
_hb_buffer_add_utf8
|
|
7
7
|
_hb_buffer_add_codepoints
|
|
8
8
|
_hb_buffer_create
|
|
9
|
+
_hb_buffer_reference
|
|
9
10
|
_hb_buffer_destroy
|
|
10
11
|
_hb_buffer_get_glyph_infos
|
|
11
12
|
_hb_buffer_get_glyph_positions
|
|
@@ -17,8 +18,10 @@ _hb_buffer_set_direction
|
|
|
17
18
|
_hb_buffer_set_flags
|
|
18
19
|
_hb_buffer_set_language
|
|
19
20
|
_hb_buffer_set_script
|
|
21
|
+
_hb_buffer_reset
|
|
22
|
+
_hb_buffer_clear_contents
|
|
20
23
|
_hb_buffer_set_message_func
|
|
21
|
-
|
|
24
|
+
_hb_buffer_serialize
|
|
22
25
|
_hb_face_create
|
|
23
26
|
_hb_face_collect_unicodes
|
|
24
27
|
_hb_face_destroy
|
package/hb.wasm
CHANGED
|
Binary file
|
package/hbjs.js
CHANGED
|
@@ -6,6 +6,9 @@ function hbjs(Module) {
|
|
|
6
6
|
var utf8Encoder = new TextEncoder("utf8");
|
|
7
7
|
let addFunction = Module.addFunction;
|
|
8
8
|
let removeFunction = Module.removeFunction;
|
|
9
|
+
let stackSave = Module.stackSave;
|
|
10
|
+
let stackRestore = Module.stackRestore;
|
|
11
|
+
let stackAlloc = Module.stackAlloc;
|
|
9
12
|
|
|
10
13
|
var freeFuncPtr = addFunction(function (ptr) { exports.free(ptr); }, 'vi');
|
|
11
14
|
|
|
@@ -17,11 +20,35 @@ function hbjs(Module) {
|
|
|
17
20
|
|
|
18
21
|
const HB_MEMORY_MODE_WRITABLE = 2;
|
|
19
22
|
const HB_SET_VALUE_INVALID = -1;
|
|
20
|
-
const HB_BUFFER_CONTENT_TYPE_GLYPHS = 2;
|
|
21
|
-
const HB_BUFFER_SERIALIZE_FORMAT_JSON = _hb_tag('JSON');
|
|
22
|
-
const HB_BUFFER_SERIALIZE_FLAG_NO_GLYPH_NAMES = 4;
|
|
23
23
|
const HB_OT_NAME_ID_INVALID = 0xFFFF;
|
|
24
24
|
|
|
25
|
+
const bufferContentType = {
|
|
26
|
+
0: "INVALID",
|
|
27
|
+
1: "UNICODE",
|
|
28
|
+
2: "GLYPHS",
|
|
29
|
+
};
|
|
30
|
+
const bufferSerializeFlags = {
|
|
31
|
+
"DEFAULT": 0x00000000,
|
|
32
|
+
"NO_CLUSTERS": 0x00000001,
|
|
33
|
+
"NO_POSITIONS": 0x00000002,
|
|
34
|
+
"NO_GLYPH_NAMES": 0x00000004,
|
|
35
|
+
"GLYPH_EXTENTS": 0x00000008,
|
|
36
|
+
"GLYPH_FLAGS": 0x00000010,
|
|
37
|
+
"NO_ADVANCES": 0x00000020,
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
const bufferFlags = {
|
|
41
|
+
"DEFAULT": 0x00000000,
|
|
42
|
+
"BOT": 0x00000001,
|
|
43
|
+
"EOT": 0x00000002,
|
|
44
|
+
"PRESERVE_DEFAULT_IGNORABLES": 0x00000004,
|
|
45
|
+
"REMOVE_DEFAULT_IGNORABLES": 0x00000008,
|
|
46
|
+
"DO_NOT_INSERT_DOTTED_CIRCLE": 0x00000010,
|
|
47
|
+
"VERIFY": 0x00000020,
|
|
48
|
+
"PRODUCE_UNSAFE_TO_CONCAT": 0x00000040,
|
|
49
|
+
"PRODUCE_SAFE_TO_INSERT_TATWEEL": 0x00000080,
|
|
50
|
+
};
|
|
51
|
+
|
|
25
52
|
function _hb_tag(s) {
|
|
26
53
|
return (
|
|
27
54
|
(s.charCodeAt(0) & 0xFF) << 24 |
|
|
@@ -92,16 +119,6 @@ function hbjs(Module) {
|
|
|
92
119
|
};
|
|
93
120
|
}
|
|
94
121
|
|
|
95
|
-
function _buffer_flag(s) {
|
|
96
|
-
if (s == "BOT") { return 0x1; }
|
|
97
|
-
if (s == "EOT") { return 0x2; }
|
|
98
|
-
if (s == "PRESERVE_DEFAULT_IGNORABLES") { return 0x4; }
|
|
99
|
-
if (s == "REMOVE_DEFAULT_IGNORABLES") { return 0x8; }
|
|
100
|
-
if (s == "DO_NOT_INSERT_DOTTED_CIRCLE") { return 0x10; }
|
|
101
|
-
if (s == "PRODUCE_UNSAFE_TO_CONCAT") { return 0x40; }
|
|
102
|
-
return 0x0;
|
|
103
|
-
}
|
|
104
|
-
|
|
105
122
|
function _language_to_string(language) {
|
|
106
123
|
var ptr = exports.hb_language_to_string(language);
|
|
107
124
|
return _utf8_ptr_to_string(ptr);
|
|
@@ -174,8 +191,9 @@ function hbjs(Module) {
|
|
|
174
191
|
* Return variation axis infos
|
|
175
192
|
*/
|
|
176
193
|
getAxisInfos: function () {
|
|
177
|
-
var
|
|
178
|
-
var
|
|
194
|
+
var sp = stackSave();
|
|
195
|
+
var axis = stackAlloc(64 * 32);
|
|
196
|
+
var c = stackAlloc(4);
|
|
179
197
|
Module.HEAPU32[c / 4] = 64;
|
|
180
198
|
exports.hb_ot_var_get_axis_infos(ptr, 0, c, axis);
|
|
181
199
|
var result = {};
|
|
@@ -186,8 +204,7 @@ function hbjs(Module) {
|
|
|
186
204
|
max: Module.HEAPF32[axis / 4 + i * 8 + 6]
|
|
187
205
|
};
|
|
188
206
|
});
|
|
189
|
-
|
|
190
|
-
exports.free(axis);
|
|
207
|
+
stackRestore(sp);
|
|
191
208
|
return result;
|
|
192
209
|
},
|
|
193
210
|
/**
|
|
@@ -206,12 +223,12 @@ function hbjs(Module) {
|
|
|
206
223
|
* @param {string} table: The table to query, either "GSUB" or "GPOS".
|
|
207
224
|
**/
|
|
208
225
|
getTableScriptTags: function (table) {
|
|
209
|
-
var sp =
|
|
226
|
+
var sp = stackSave();
|
|
210
227
|
var tableTag = _hb_tag(table);
|
|
211
228
|
var startOffset = 0;
|
|
212
229
|
var scriptCount = STATIC_ARRAY_SIZE;
|
|
213
|
-
var scriptCountPtr =
|
|
214
|
-
var scriptTagsPtr =
|
|
230
|
+
var scriptCountPtr = stackAlloc(4);
|
|
231
|
+
var scriptTagsPtr = stackAlloc(STATIC_ARRAY_SIZE * 4);
|
|
215
232
|
var tags = [];
|
|
216
233
|
while (scriptCount == STATIC_ARRAY_SIZE) {
|
|
217
234
|
Module.HEAPU32[scriptCountPtr / 4] = scriptCount;
|
|
@@ -223,7 +240,7 @@ function hbjs(Module) {
|
|
|
223
240
|
tags.push(...Array.from(scriptTags).map(_hb_untag));
|
|
224
241
|
startOffset += scriptCount;
|
|
225
242
|
}
|
|
226
|
-
|
|
243
|
+
stackRestore(sp);
|
|
227
244
|
return tags;
|
|
228
245
|
},
|
|
229
246
|
/**
|
|
@@ -232,12 +249,12 @@ function hbjs(Module) {
|
|
|
232
249
|
* @param {string} table: The table to query, either "GSUB" or "GPOS".
|
|
233
250
|
**/
|
|
234
251
|
getTableFeatureTags: function (table) {
|
|
235
|
-
var sp =
|
|
252
|
+
var sp = stackSave();
|
|
236
253
|
var tableTag = _hb_tag(table);
|
|
237
254
|
var startOffset = 0;
|
|
238
255
|
var featureCount = STATIC_ARRAY_SIZE;
|
|
239
|
-
var featureCountPtr =
|
|
240
|
-
var featureTagsPtr =
|
|
256
|
+
var featureCountPtr = stackAlloc(4);
|
|
257
|
+
var featureTagsPtr = stackAlloc(STATIC_ARRAY_SIZE * 4);
|
|
241
258
|
var tags = [];
|
|
242
259
|
while (featureCount == STATIC_ARRAY_SIZE) {
|
|
243
260
|
Module.HEAPU32[featureCountPtr / 4] = featureCount;
|
|
@@ -249,7 +266,7 @@ function hbjs(Module) {
|
|
|
249
266
|
tags.push(...Array.from(scriptTags).map(_hb_untag));
|
|
250
267
|
startOffset += featureCount;
|
|
251
268
|
}
|
|
252
|
-
|
|
269
|
+
stackRestore(sp);
|
|
253
270
|
return tags;
|
|
254
271
|
|
|
255
272
|
},
|
|
@@ -260,12 +277,12 @@ function hbjs(Module) {
|
|
|
260
277
|
* @param {number} scriptIndex: The index of the script to query.
|
|
261
278
|
**/
|
|
262
279
|
getScriptLanguageTags: function (table, scriptIndex) {
|
|
263
|
-
var sp =
|
|
280
|
+
var sp = stackSave();
|
|
264
281
|
var tableTag = _hb_tag(table);
|
|
265
282
|
var startOffset = 0;
|
|
266
283
|
var languageCount = STATIC_ARRAY_SIZE;
|
|
267
|
-
var languageCountPtr =
|
|
268
|
-
var languageTagsPtr =
|
|
284
|
+
var languageCountPtr = stackAlloc(4);
|
|
285
|
+
var languageTagsPtr = stackAlloc(STATIC_ARRAY_SIZE * 4);
|
|
269
286
|
var tags = [];
|
|
270
287
|
while (languageCount == STATIC_ARRAY_SIZE) {
|
|
271
288
|
Module.HEAPU32[languageCountPtr / 4] = languageCount;
|
|
@@ -277,7 +294,7 @@ function hbjs(Module) {
|
|
|
277
294
|
tags.push(...Array.from(languageTags).map(_hb_untag));
|
|
278
295
|
startOffset += languageCount;
|
|
279
296
|
}
|
|
280
|
-
|
|
297
|
+
stackRestore(sp);
|
|
281
298
|
return tags;
|
|
282
299
|
},
|
|
283
300
|
/**
|
|
@@ -288,12 +305,12 @@ function hbjs(Module) {
|
|
|
288
305
|
* @param {number} languageIndex: The index of the language to query.
|
|
289
306
|
**/
|
|
290
307
|
getLanguageFeatureTags: function (table, scriptIndex, languageIndex) {
|
|
291
|
-
var sp =
|
|
308
|
+
var sp = stackSave();
|
|
292
309
|
var tableTag = _hb_tag(table);
|
|
293
310
|
var startOffset = 0;
|
|
294
311
|
var featureCount = STATIC_ARRAY_SIZE;
|
|
295
|
-
var featureCountPtr =
|
|
296
|
-
var featureTagsPtr =
|
|
312
|
+
var featureCountPtr = stackAlloc(4);
|
|
313
|
+
var featureTagsPtr = stackAlloc(STATIC_ARRAY_SIZE * 4);
|
|
297
314
|
var tags = [];
|
|
298
315
|
while (featureCount == STATIC_ARRAY_SIZE) {
|
|
299
316
|
Module.HEAPU32[featureCountPtr / 4] = featureCount;
|
|
@@ -305,15 +322,15 @@ function hbjs(Module) {
|
|
|
305
322
|
tags.push(...Array.from(featureTags).map(_hb_untag));
|
|
306
323
|
startOffset += featureCount;
|
|
307
324
|
}
|
|
308
|
-
|
|
325
|
+
stackRestore(sp);
|
|
309
326
|
return tags;
|
|
310
327
|
},
|
|
311
328
|
/**
|
|
312
329
|
* Return all names in the specified face's name table.
|
|
313
330
|
**/
|
|
314
331
|
listNames: function () {
|
|
315
|
-
var sp =
|
|
316
|
-
var numEntriesPtr =
|
|
332
|
+
var sp = stackSave();
|
|
333
|
+
var numEntriesPtr = stackAlloc(4);
|
|
317
334
|
var entriesPtr = exports.hb_ot_name_list_names(ptr, numEntriesPtr);
|
|
318
335
|
var numEntries = Module.HEAPU32[numEntriesPtr / 4];
|
|
319
336
|
var entries = [];
|
|
@@ -326,7 +343,7 @@ function hbjs(Module) {
|
|
|
326
343
|
language: _language_to_string(Module.HEAPU32[(entriesPtr / 4) + (i * 3) + 2])
|
|
327
344
|
});
|
|
328
345
|
}
|
|
329
|
-
|
|
346
|
+
stackRestore(sp);
|
|
330
347
|
return entries;
|
|
331
348
|
},
|
|
332
349
|
/**
|
|
@@ -335,16 +352,16 @@ function hbjs(Module) {
|
|
|
335
352
|
* @param {string} language The language of the name to get.
|
|
336
353
|
**/
|
|
337
354
|
getName: function (nameId, language) {
|
|
338
|
-
var sp =
|
|
355
|
+
var sp = stackSave();
|
|
339
356
|
var languagePtr = _language_from_string(language);
|
|
340
357
|
var nameLen = exports.hb_ot_name_get_utf16(ptr, nameId, languagePtr, 0, 0) + 1;
|
|
341
|
-
var textSizePtr =
|
|
358
|
+
var textSizePtr = stackAlloc(4);
|
|
342
359
|
var textPtr = exports.malloc(nameLen * 2);
|
|
343
360
|
Module.HEAPU32[textSizePtr / 4] = nameLen;
|
|
344
361
|
exports.hb_ot_name_get_utf16(ptr, nameId, languagePtr, textSizePtr, textPtr);
|
|
345
362
|
var name = _utf16_ptr_to_string(textPtr, nameLen - 1);
|
|
346
363
|
exports.free(textPtr);
|
|
347
|
-
|
|
364
|
+
stackRestore(sp);
|
|
348
365
|
return name;
|
|
349
366
|
},
|
|
350
367
|
/**
|
|
@@ -353,13 +370,13 @@ function hbjs(Module) {
|
|
|
353
370
|
* @param {number} featureIndex The index of the feature to query.
|
|
354
371
|
**/
|
|
355
372
|
getFeatureNameIds: function (table, featureIndex) {
|
|
356
|
-
var sp =
|
|
373
|
+
var sp = stackSave();
|
|
357
374
|
var tableTag = _hb_tag(table);
|
|
358
|
-
var labelIdPtr =
|
|
359
|
-
var tooltipIdPtr =
|
|
360
|
-
var sampleIdPtr =
|
|
361
|
-
var numNamedParametersPtr =
|
|
362
|
-
var firstParameterIdPtr =
|
|
375
|
+
var labelIdPtr = stackAlloc(4);
|
|
376
|
+
var tooltipIdPtr = stackAlloc(4);
|
|
377
|
+
var sampleIdPtr = stackAlloc(4);
|
|
378
|
+
var numNamedParametersPtr = stackAlloc(4);
|
|
379
|
+
var firstParameterIdPtr = stackAlloc(4);
|
|
363
380
|
|
|
364
381
|
var found = exports.hb_ot_layout_feature_get_name_ids(ptr, tableTag, featureIndex,
|
|
365
382
|
labelIdPtr, tooltipIdPtr, sampleIdPtr, numNamedParametersPtr, firstParameterIdPtr);
|
|
@@ -380,7 +397,7 @@ function hbjs(Module) {
|
|
|
380
397
|
};
|
|
381
398
|
}
|
|
382
399
|
|
|
383
|
-
|
|
400
|
+
stackRestore(sp);
|
|
384
401
|
return names;
|
|
385
402
|
},
|
|
386
403
|
/**
|
|
@@ -394,9 +411,6 @@ function hbjs(Module) {
|
|
|
394
411
|
|
|
395
412
|
var pathBuffer = "";
|
|
396
413
|
|
|
397
|
-
var nameBufferSize = 256; // should be enough for most glyphs
|
|
398
|
-
var nameBuffer = exports.malloc(nameBufferSize); // permanently allocated
|
|
399
|
-
|
|
400
414
|
/**
|
|
401
415
|
* Create an object representing a Harfbuzz font.
|
|
402
416
|
* @param {object} blob An object returned from `createFace`.
|
|
@@ -456,13 +470,13 @@ function hbjs(Module) {
|
|
|
456
470
|
* @param {number} glyphId ID of the requested glyph in the font.
|
|
457
471
|
**/
|
|
458
472
|
function glyphName(glyphId) {
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
);
|
|
465
|
-
return
|
|
473
|
+
var sp = stackSave();
|
|
474
|
+
var strSize = 256;
|
|
475
|
+
var strPtr = stackAlloc(strSize);
|
|
476
|
+
exports.hb_font_glyph_to_string(ptr, glyphId, strPtr, strSize);
|
|
477
|
+
var name = _utf8_ptr_to_string(strPtr);
|
|
478
|
+
stackRestore(sp);
|
|
479
|
+
return name;
|
|
466
480
|
}
|
|
467
481
|
|
|
468
482
|
return {
|
|
@@ -479,15 +493,15 @@ function hbjs(Module) {
|
|
|
479
493
|
* @returns {object} Object with ascender, descender, and lineGap properties.
|
|
480
494
|
**/
|
|
481
495
|
hExtents: function () {
|
|
482
|
-
var sp =
|
|
483
|
-
var extentsPtr =
|
|
496
|
+
var sp = stackSave();
|
|
497
|
+
var extentsPtr = stackAlloc(12);
|
|
484
498
|
exports.hb_font_get_h_extents(ptr, extentsPtr);
|
|
485
499
|
var extents = {
|
|
486
500
|
ascender: Module.HEAP32[extentsPtr / 4],
|
|
487
501
|
descender: Module.HEAP32[extentsPtr / 4 + 1],
|
|
488
502
|
lineGap: Module.HEAP32[extentsPtr / 4 + 2],
|
|
489
503
|
};
|
|
490
|
-
|
|
504
|
+
stackRestore(sp);
|
|
491
505
|
return extents;
|
|
492
506
|
},
|
|
493
507
|
/**
|
|
@@ -495,15 +509,15 @@ function hbjs(Module) {
|
|
|
495
509
|
* @returns {object} Object with ascender, descender, and lineGap properties.
|
|
496
510
|
**/
|
|
497
511
|
vExtents: function () {
|
|
498
|
-
var sp =
|
|
499
|
-
var extentsPtr =
|
|
512
|
+
var sp = stackSave();
|
|
513
|
+
var extentsPtr = stackAlloc(12);
|
|
500
514
|
exports.hb_font_get_v_extents(ptr, extentsPtr);
|
|
501
515
|
var extents = {
|
|
502
516
|
ascender: Module.HEAP32[extentsPtr / 4],
|
|
503
517
|
descender: Module.HEAP32[extentsPtr / 4 + 1],
|
|
504
518
|
lineGap: Module.HEAP32[extentsPtr / 4 + 2],
|
|
505
519
|
};
|
|
506
|
-
|
|
520
|
+
stackRestore(sp);
|
|
507
521
|
return extents;
|
|
508
522
|
},
|
|
509
523
|
glyphName: glyphName,
|
|
@@ -527,14 +541,14 @@ function hbjs(Module) {
|
|
|
527
541
|
* @param {number} glyphId ID of the requested glyph in the font.
|
|
528
542
|
**/
|
|
529
543
|
glyphHOrigin: function (glyphId) {
|
|
530
|
-
var sp =
|
|
531
|
-
let xPtr =
|
|
532
|
-
let yPtr =
|
|
544
|
+
var sp = stackSave();
|
|
545
|
+
let xPtr = stackAlloc(4);
|
|
546
|
+
let yPtr = stackAlloc(4);
|
|
533
547
|
let origin = null;
|
|
534
548
|
if (exports.hb_font_get_glyph_h_origin(ptr, glyphId, xPtr, yPtr)) {
|
|
535
549
|
origin = [Module.HEAP32[xPtr / 4], Module.HEAP32[yPtr / 4]];
|
|
536
550
|
}
|
|
537
|
-
|
|
551
|
+
stackRestore(sp);
|
|
538
552
|
return origin;
|
|
539
553
|
},
|
|
540
554
|
/**
|
|
@@ -542,14 +556,14 @@ function hbjs(Module) {
|
|
|
542
556
|
* @param {number} glyphId ID of the requested glyph in the font.
|
|
543
557
|
**/
|
|
544
558
|
glyphVOrigin: function (glyphId) {
|
|
545
|
-
var sp =
|
|
546
|
-
let xPtr =
|
|
547
|
-
let yPtr =
|
|
559
|
+
var sp = stackSave();
|
|
560
|
+
let xPtr = stackAlloc(4);
|
|
561
|
+
let yPtr = stackAlloc(4);
|
|
548
562
|
let origin = null;
|
|
549
563
|
if (exports.hb_font_get_glyph_v_origin(ptr, glyphId, xPtr, yPtr)) {
|
|
550
564
|
origin = [Module.HEAP32[xPtr / 4], Module.HEAP32[yPtr / 4]];
|
|
551
565
|
}
|
|
552
|
-
|
|
566
|
+
stackRestore(sp);
|
|
553
567
|
return origin;
|
|
554
568
|
},
|
|
555
569
|
/**
|
|
@@ -557,8 +571,8 @@ function hbjs(Module) {
|
|
|
557
571
|
* @param {number} glyphId ID of the requested glyph in the font.
|
|
558
572
|
**/
|
|
559
573
|
glyphExtents: function (glyphId) {
|
|
560
|
-
var sp =
|
|
561
|
-
var extentsPtr =
|
|
574
|
+
var sp = stackSave();
|
|
575
|
+
var extentsPtr = stackAlloc(16);
|
|
562
576
|
var extents = null;
|
|
563
577
|
if (exports.hb_font_get_glyph_extents(ptr, glyphId, extentsPtr)) {
|
|
564
578
|
extents = {
|
|
@@ -568,7 +582,7 @@ function hbjs(Module) {
|
|
|
568
582
|
height: Module.HEAP32[extentsPtr / 4 + 3]
|
|
569
583
|
};
|
|
570
584
|
}
|
|
571
|
-
|
|
585
|
+
stackRestore(sp);
|
|
572
586
|
return extents;
|
|
573
587
|
},
|
|
574
588
|
/**
|
|
@@ -576,15 +590,15 @@ function hbjs(Module) {
|
|
|
576
590
|
* @param {string} name Name of the requested glyph in the font.
|
|
577
591
|
**/
|
|
578
592
|
glyphFromName: function (name) {
|
|
579
|
-
var sp =
|
|
580
|
-
var glyphIdPtr =
|
|
593
|
+
var sp = stackSave();
|
|
594
|
+
var glyphIdPtr = stackAlloc(4);
|
|
581
595
|
var namePtr = _string_to_utf8_ptr(name);
|
|
582
596
|
var glyphId = null;
|
|
583
597
|
if (exports.hb_font_get_glyph_from_name(ptr, namePtr.ptr, namePtr.length, glyphIdPtr)) {
|
|
584
598
|
glyphId = Module.HEAPU32[glyphIdPtr / 4];
|
|
585
599
|
}
|
|
586
600
|
namePtr.free();
|
|
587
|
-
|
|
601
|
+
stackRestore(sp);
|
|
588
602
|
return glyphId;
|
|
589
603
|
},
|
|
590
604
|
/**
|
|
@@ -947,9 +961,10 @@ function hbjs(Module) {
|
|
|
947
961
|
|
|
948
962
|
/**
|
|
949
963
|
* Create an object representing a Harfbuzz buffer.
|
|
964
|
+
* @param {number} ptr Optional. The pointer to the buffer.
|
|
950
965
|
**/
|
|
951
|
-
function createBuffer() {
|
|
952
|
-
var ptr = exports.hb_buffer_create();
|
|
966
|
+
function createBuffer(ptr) {
|
|
967
|
+
var ptr = ptr ? exports.hb_buffer_reference(ptr) : exports.hb_buffer_create();
|
|
953
968
|
return {
|
|
954
969
|
ptr: ptr,
|
|
955
970
|
/**
|
|
@@ -1001,20 +1016,20 @@ function hbjs(Module) {
|
|
|
1001
1016
|
/**
|
|
1002
1017
|
* Set buffer flags explicitly.
|
|
1003
1018
|
* @param {string[]} flags: A list of strings which may be either:
|
|
1019
|
+
* "DEFAULT"
|
|
1004
1020
|
* "BOT"
|
|
1005
1021
|
* "EOT"
|
|
1006
1022
|
* "PRESERVE_DEFAULT_IGNORABLES"
|
|
1007
1023
|
* "REMOVE_DEFAULT_IGNORABLES"
|
|
1008
1024
|
* "DO_NOT_INSERT_DOTTED_CIRCLE"
|
|
1025
|
+
* "VERIFY"
|
|
1009
1026
|
* "PRODUCE_UNSAFE_TO_CONCAT"
|
|
1027
|
+
* "PRODUCE_SAFE_TO_INSERT_TATWEEL"
|
|
1010
1028
|
*/
|
|
1011
1029
|
setFlags: function (flags) {
|
|
1012
|
-
var
|
|
1013
|
-
flags.forEach(
|
|
1014
|
-
|
|
1015
|
-
})
|
|
1016
|
-
|
|
1017
|
-
exports.hb_buffer_set_flags(ptr, flagValue);
|
|
1030
|
+
var flagsValue = 0
|
|
1031
|
+
flags.forEach(s => flagsValue |= bufferFlags[s] || 0);
|
|
1032
|
+
exports.hb_buffer_set_flags(ptr, flagsValue);
|
|
1018
1033
|
},
|
|
1019
1034
|
/**
|
|
1020
1035
|
* Set buffer language explicitly.
|
|
@@ -1034,7 +1049,6 @@ function hbjs(Module) {
|
|
|
1034
1049
|
exports.hb_buffer_set_script(ptr, exports.hb_script_from_string(str.ptr, -1));
|
|
1035
1050
|
str.free();
|
|
1036
1051
|
},
|
|
1037
|
-
|
|
1038
1052
|
/**
|
|
1039
1053
|
* Set the Harfbuzz clustering level.
|
|
1040
1054
|
*
|
|
@@ -1046,6 +1060,171 @@ function hbjs(Module) {
|
|
|
1046
1060
|
exports.hb_buffer_set_cluster_level(ptr, level)
|
|
1047
1061
|
},
|
|
1048
1062
|
/**
|
|
1063
|
+
* Reset the buffer to its initial status.
|
|
1064
|
+
**/
|
|
1065
|
+
reset: function () {
|
|
1066
|
+
exports.hb_buffer_reset(ptr);
|
|
1067
|
+
},
|
|
1068
|
+
/**
|
|
1069
|
+
* Similar to reset(), but does not clear the Unicode functions and the
|
|
1070
|
+
* replacement code point.
|
|
1071
|
+
**/
|
|
1072
|
+
clearContents: function () {
|
|
1073
|
+
exports.hb_buffer_clear_contents(ptr);
|
|
1074
|
+
},
|
|
1075
|
+
/**
|
|
1076
|
+
* Set message func.
|
|
1077
|
+
* @param {function} func The function to set.
|
|
1078
|
+
*
|
|
1079
|
+
* The function should accept three arguments:
|
|
1080
|
+
* @param {object} buffer The buffer
|
|
1081
|
+
* @param {object} font The font
|
|
1082
|
+
* @param {string} message The message
|
|
1083
|
+
*
|
|
1084
|
+
* Returning false from this function will skip this shaping step and move to the next one.
|
|
1085
|
+
*/
|
|
1086
|
+
setMessageFunc: function (func) {
|
|
1087
|
+
var traceFunc = function (bufferPtr, fontPtr, messagePtr, user_data) {
|
|
1088
|
+
var message = _utf8_ptr_to_string(messagePtr);
|
|
1089
|
+
var buffer = createBuffer(bufferPtr);
|
|
1090
|
+
var font = createFont(null, fontPtr);
|
|
1091
|
+
var result = func(buffer, font, message);
|
|
1092
|
+
buffer.destroy();
|
|
1093
|
+
font.destroy();
|
|
1094
|
+
return result ? 1 : 0;
|
|
1095
|
+
}
|
|
1096
|
+
var traceFuncPtr = addFunction(traceFunc, 'iiiii');
|
|
1097
|
+
exports.hb_buffer_set_message_func(ptr, traceFuncPtr, 0, 0);
|
|
1098
|
+
},
|
|
1099
|
+
/**
|
|
1100
|
+
* Get the the number of items in the buffer.
|
|
1101
|
+
* @returns {number} The buffer length.
|
|
1102
|
+
*/
|
|
1103
|
+
getLength: function () {
|
|
1104
|
+
return exports.hb_buffer_get_length(ptr);
|
|
1105
|
+
},
|
|
1106
|
+
/**
|
|
1107
|
+
* Get the glyph information from the buffer.
|
|
1108
|
+
* @returns {object[]} The glyph information.
|
|
1109
|
+
*
|
|
1110
|
+
* The glyph information is returned as an array of objects with the
|
|
1111
|
+
* following properties:
|
|
1112
|
+
* @param {number} codepoint either a Unicode code point (before shaping) or a glyph index (after shaping).
|
|
1113
|
+
* @param {number} cluster The cluster index of the glyph.
|
|
1114
|
+
*/
|
|
1115
|
+
getGlyphInfos: function () {
|
|
1116
|
+
var infosPtr32 = exports.hb_buffer_get_glyph_infos(ptr, 0) / 4;
|
|
1117
|
+
// hb_glyph_info_t struct: { codepoint, mask, cluster, var1, var2 } (5 uint32s)
|
|
1118
|
+
var infosArray = Module.HEAPU32.subarray(infosPtr32, infosPtr32 + this.getLength() * 5);
|
|
1119
|
+
var infos = [];
|
|
1120
|
+
for (var i = 0; i < infosArray.length; i += 5) {
|
|
1121
|
+
infos.push({
|
|
1122
|
+
codepoint: infosArray[i],
|
|
1123
|
+
cluster: infosArray[i + 2],
|
|
1124
|
+
});
|
|
1125
|
+
}
|
|
1126
|
+
return infos;
|
|
1127
|
+
},
|
|
1128
|
+
/**
|
|
1129
|
+
* Get the glyph positions from the buffer.
|
|
1130
|
+
* @returns {object[]} The glyph positions.
|
|
1131
|
+
*
|
|
1132
|
+
* The glyph positions are returned as an array of objects with the
|
|
1133
|
+
* following properties:
|
|
1134
|
+
* @param {number} x_advance The x advance of the glyph.
|
|
1135
|
+
* @param {number} y_advance The y advance of the glyph.
|
|
1136
|
+
* @param {number} x_offset The x offset of the glyph.
|
|
1137
|
+
* @param {number} y_offset The y offset of the glyph.
|
|
1138
|
+
*
|
|
1139
|
+
*/
|
|
1140
|
+
getGlyphPositions: function () {
|
|
1141
|
+
var positionsPtr32 = exports.hb_buffer_get_glyph_positions(ptr, 0) / 4;
|
|
1142
|
+
if (positionsPtr32 == 0) {
|
|
1143
|
+
return [];
|
|
1144
|
+
}
|
|
1145
|
+
// hb_glyph_position_t struct: { x_advance, y_advance, x_offset, y_offset, var } (5 int32s)
|
|
1146
|
+
var positionsArray = Module.HEAP32.subarray(positionsPtr32, positionsPtr32 + this.getLength() * 5);
|
|
1147
|
+
var positions = [];
|
|
1148
|
+
for (var i = 0; i < positionsArray.length; i += 5) {
|
|
1149
|
+
positions.push({
|
|
1150
|
+
x_advance: positionsArray[i],
|
|
1151
|
+
y_advance: positionsArray[i + 1],
|
|
1152
|
+
x_offset: positionsArray[i + 2],
|
|
1153
|
+
y_offset: positionsArray[i + 3],
|
|
1154
|
+
});
|
|
1155
|
+
}
|
|
1156
|
+
return positions;
|
|
1157
|
+
},
|
|
1158
|
+
/**
|
|
1159
|
+
* Update the glyph positions in the buffer.
|
|
1160
|
+
* @param {object[]} positions The new glyph positions.
|
|
1161
|
+
*
|
|
1162
|
+
* WARNING: Do not use unless you know what you are doing.
|
|
1163
|
+
*/
|
|
1164
|
+
updateGlyphPositions: function (positions) {
|
|
1165
|
+
var positionsPtr32 = exports.hb_buffer_get_glyph_positions(ptr, 0) / 4;
|
|
1166
|
+
if (positionsPtr32 == 0) {
|
|
1167
|
+
return;
|
|
1168
|
+
}
|
|
1169
|
+
var len = Math.min(positions.length, this.getLength());
|
|
1170
|
+
var positionsArray = Module.HEAP32.subarray(positionsPtr32, positionsPtr32 + len * 5);
|
|
1171
|
+
for (var i = 0; i < len; i++) {
|
|
1172
|
+
positionsArray[i * 5] = positions[i].x_advance;
|
|
1173
|
+
positionsArray[i * 5 + 1] = positions[i].y_advance;
|
|
1174
|
+
positionsArray[i * 5 + 2] = positions[i].x_offset;
|
|
1175
|
+
positionsArray[i * 5 + 3] = positions[i].y_offset;
|
|
1176
|
+
}
|
|
1177
|
+
},
|
|
1178
|
+
/**
|
|
1179
|
+
* Serialize the buffer contents to a string.
|
|
1180
|
+
* @param {object} font Optional. The font to use for serialization.
|
|
1181
|
+
* @param {number} start Optional. The starting index of the glyphs to serialize.
|
|
1182
|
+
* @param {number} end Optional. The ending index of the glyphs to serialize.
|
|
1183
|
+
* @param {string} format Optional. The format to serialize the buffer contents to.
|
|
1184
|
+
* @param {string[]} flags Optional. The flags to use for serialization. A list of strings which may be either:
|
|
1185
|
+
* "DEFAULT"
|
|
1186
|
+
* "NO_CLUSTERS"
|
|
1187
|
+
* "NO_POSITIONS"
|
|
1188
|
+
* "NO_GLYPH_NAMES"
|
|
1189
|
+
* "GLYPH_EXTENTS"
|
|
1190
|
+
* "GLYPH_FLAGS"
|
|
1191
|
+
* "NO_ADVANCES"
|
|
1192
|
+
*
|
|
1193
|
+
* @returns {string} The serialized buffer contents.
|
|
1194
|
+
*/
|
|
1195
|
+
serialize: function (font, start = 0, end = null, format = "TEXT", flags = []) {
|
|
1196
|
+
var sp = stackSave();
|
|
1197
|
+
if (end == null) end = this.getLength();
|
|
1198
|
+
var bufLen = 32 * 1024;
|
|
1199
|
+
var bufPtr = exports.malloc(bufLen);
|
|
1200
|
+
var bufConsumedPtr = stackAlloc(4);
|
|
1201
|
+
var flagsValue = 0;
|
|
1202
|
+
flags.forEach(flag => flagsValue |= bufferSerializeFlags[flag] || 0);
|
|
1203
|
+
var result = "";
|
|
1204
|
+
while (start < end) {
|
|
1205
|
+
start += exports.hb_buffer_serialize(ptr, start, end,
|
|
1206
|
+
bufPtr, bufLen, bufConsumedPtr,
|
|
1207
|
+
font ? font.ptr : 0, _hb_tag(format), flagsValue);
|
|
1208
|
+
var bufConsumed = Module.HEAPU32[bufConsumedPtr / 4];
|
|
1209
|
+
if (bufConsumed == 0) break;
|
|
1210
|
+
result += _utf8_ptr_to_string(bufPtr, bufConsumed);
|
|
1211
|
+
}
|
|
1212
|
+
exports.free(bufPtr);
|
|
1213
|
+
stackRestore(sp);
|
|
1214
|
+
return result;
|
|
1215
|
+
},
|
|
1216
|
+
/**
|
|
1217
|
+
* Return the buffer content type.
|
|
1218
|
+
*
|
|
1219
|
+
* @returns {string} The buffer content type. One of:
|
|
1220
|
+
* "INVALID"
|
|
1221
|
+
* "UNICODE"
|
|
1222
|
+
* "GLYPHS"
|
|
1223
|
+
*/
|
|
1224
|
+
getContentType: function () {
|
|
1225
|
+
return bufferContentType[exports.hb_buffer_get_content_type(ptr)];
|
|
1226
|
+
},
|
|
1227
|
+
/**
|
|
1049
1228
|
* Return the buffer contents as a JSON object.
|
|
1050
1229
|
*
|
|
1051
1230
|
* After shaping, this function will return an array of glyph information
|
|
@@ -1060,25 +1239,15 @@ function hbjs(Module) {
|
|
|
1060
1239
|
* - flags: Glyph flags like `HB_GLYPH_FLAG_UNSAFE_TO_BREAK` (0x1)
|
|
1061
1240
|
**/
|
|
1062
1241
|
json: function () {
|
|
1063
|
-
var
|
|
1064
|
-
var
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
g: infos[i * 5 + 0],
|
|
1073
|
-
cl: infos[i * 5 + 2],
|
|
1074
|
-
ax: positions[i * 5 + 0],
|
|
1075
|
-
ay: positions[i * 5 + 1],
|
|
1076
|
-
dx: positions[i * 5 + 2],
|
|
1077
|
-
dy: positions[i * 5 + 3],
|
|
1078
|
-
flags: exports.hb_glyph_info_get_glyph_flags(infosPtr + i * 20)
|
|
1079
|
-
});
|
|
1080
|
-
}
|
|
1081
|
-
return result;
|
|
1242
|
+
var buf = this.serialize(null, 0, null, "JSON", ["NO_GLYPH_NAMES", "GLYPH_FLAGS"]);
|
|
1243
|
+
var json = JSON.parse(buf);
|
|
1244
|
+
// For backward compatibility, as harfbuzz uses 'fl' for flags but earlier
|
|
1245
|
+
// we were doing the serialization ourselves and used 'flags'.
|
|
1246
|
+
json.forEach(function (glyph) {
|
|
1247
|
+
glyph.flags = glyph.fl || 0;
|
|
1248
|
+
delete glyph.fl;
|
|
1249
|
+
});
|
|
1250
|
+
return json;
|
|
1082
1251
|
},
|
|
1083
1252
|
/**
|
|
1084
1253
|
* Free the object.
|
|
@@ -1139,11 +1308,7 @@ function hbjs(Module) {
|
|
|
1139
1308
|
var stopping = false;
|
|
1140
1309
|
var failure = false;
|
|
1141
1310
|
|
|
1142
|
-
|
|
1143
|
-
var traceBufPtr = exports.malloc(traceBufLen);
|
|
1144
|
-
|
|
1145
|
-
var traceFunc = function (bufferPtr, fontPtr, messagePtr, user_data) {
|
|
1146
|
-
var message = _utf8_ptr_to_string(messagePtr);
|
|
1311
|
+
buffer.setMessageFunc((buffer, font, message) => {
|
|
1147
1312
|
if (message.startsWith("start table GSUB"))
|
|
1148
1313
|
currentPhase = TRACE_PHASE_GSUB;
|
|
1149
1314
|
else if (message.startsWith("start table GPOS"))
|
|
@@ -1153,49 +1318,39 @@ function hbjs(Module) {
|
|
|
1153
1318
|
stopping = false;
|
|
1154
1319
|
|
|
1155
1320
|
if (failure)
|
|
1156
|
-
return
|
|
1321
|
+
return true;
|
|
1157
1322
|
|
|
1158
1323
|
if (stop_phase != TRACE_PHASE_DONT_STOP && currentPhase == stop_phase && message.startsWith("end lookup " + stop_at))
|
|
1159
1324
|
stopping = true;
|
|
1160
1325
|
|
|
1161
1326
|
if (stopping)
|
|
1162
|
-
return
|
|
1327
|
+
return false;
|
|
1163
1328
|
|
|
1164
|
-
|
|
1165
|
-
bufferPtr,
|
|
1166
|
-
0, exports.hb_buffer_get_length(bufferPtr),
|
|
1167
|
-
traceBufPtr, traceBufLen, 0,
|
|
1168
|
-
fontPtr,
|
|
1169
|
-
HB_BUFFER_SERIALIZE_FORMAT_JSON,
|
|
1170
|
-
HB_BUFFER_SERIALIZE_FLAG_NO_GLYPH_NAMES);
|
|
1329
|
+
var traceBuf = buffer.serialize(font, 0, null, "JSON", ["NO_GLYPH_NAMES"]);
|
|
1171
1330
|
|
|
1172
1331
|
trace.push({
|
|
1173
1332
|
m: message,
|
|
1174
|
-
t: JSON.parse(
|
|
1175
|
-
glyphs:
|
|
1333
|
+
t: JSON.parse(traceBuf),
|
|
1334
|
+
glyphs: buffer.getContentType() == "GLYPHS",
|
|
1176
1335
|
});
|
|
1177
1336
|
|
|
1178
|
-
return
|
|
1179
|
-
}
|
|
1337
|
+
return true;
|
|
1338
|
+
});
|
|
1180
1339
|
|
|
1181
|
-
var traceFuncPtr = addFunction(traceFunc, 'iiiii');
|
|
1182
|
-
exports.hb_buffer_set_message_func(buffer.ptr, traceFuncPtr, 0, 0);
|
|
1183
1340
|
shape(font, buffer, features, 0);
|
|
1184
|
-
exports.free(traceBufPtr);
|
|
1185
|
-
removeFunction(traceFuncPtr);
|
|
1186
|
-
|
|
1187
1341
|
return trace;
|
|
1188
1342
|
}
|
|
1189
1343
|
|
|
1190
1344
|
function version() {
|
|
1191
|
-
var
|
|
1345
|
+
var sp = stackSave();
|
|
1346
|
+
var versionPtr = stackAlloc(12);
|
|
1192
1347
|
exports.hb_version(versionPtr, versionPtr + 4, versionPtr + 8);
|
|
1193
1348
|
var version = {
|
|
1194
1349
|
major: Module.HEAPU32[versionPtr / 4],
|
|
1195
1350
|
minor: Module.HEAPU32[(versionPtr + 4) / 4],
|
|
1196
1351
|
micro: Module.HEAPU32[(versionPtr + 8) / 4],
|
|
1197
1352
|
};
|
|
1198
|
-
|
|
1353
|
+
stackRestore(sp);
|
|
1199
1354
|
return version;
|
|
1200
1355
|
}
|
|
1201
1356
|
|
package/package.json
CHANGED
package/test/index.js
CHANGED
|
@@ -569,6 +569,195 @@ describe('Buffer', function () {
|
|
|
569
569
|
const glyphs = buffer.json();
|
|
570
570
|
expect(glyphs[0].g).not.to.equal(3 /* space */);
|
|
571
571
|
});
|
|
572
|
+
|
|
573
|
+
it('setFlags ignores invalid flags', function () {
|
|
574
|
+
blob = hb.createBlob(fs.readFileSync(path.join(__dirname, 'fonts/noto/NotoSans-Regular.ttf')));
|
|
575
|
+
face = hb.createFace(blob);
|
|
576
|
+
font = hb.createFont(face);
|
|
577
|
+
buffer = hb.createBuffer();
|
|
578
|
+
buffer.addText('abc');
|
|
579
|
+
buffer.setFlags(['invalidFlag']);
|
|
580
|
+
buffer.guessSegmentProperties();
|
|
581
|
+
hb.shape(font, buffer)
|
|
582
|
+
const glyphs = buffer.json();
|
|
583
|
+
expect(glyphs[0].g).to.equal(68 /* a */);
|
|
584
|
+
});
|
|
585
|
+
|
|
586
|
+
it('setFlags with PRODUCE_SAFE_TO_INSERT_TATWEEL affects glyph flags', function () {
|
|
587
|
+
blob = hb.createBlob(fs.readFileSync(path.join(__dirname, 'fonts/noto/NotoSansArabic-Variable.ttf')));
|
|
588
|
+
face = hb.createFace(blob);
|
|
589
|
+
font = hb.createFont(face);
|
|
590
|
+
buffer = hb.createBuffer();
|
|
591
|
+
buffer.addText('بلا');
|
|
592
|
+
buffer.setFlags(['PRODUCE_SAFE_TO_INSERT_TATWEEL']);
|
|
593
|
+
buffer.guessSegmentProperties();
|
|
594
|
+
hb.shape(font, buffer)
|
|
595
|
+
const flags = Array.from(buffer.json().map(g => g.flags));
|
|
596
|
+
expect(flags).to.deep.equal([5, 0]);
|
|
597
|
+
|
|
598
|
+
buffer.clearContents();
|
|
599
|
+
buffer.addText('بلا');
|
|
600
|
+
buffer.setFlags([]);
|
|
601
|
+
buffer.guessSegmentProperties();
|
|
602
|
+
hb.shape(font, buffer)
|
|
603
|
+
const flags2 = Array.from(buffer.json().map(g => g.flags));
|
|
604
|
+
expect(flags2).to.deep.equal([1, 0]);
|
|
605
|
+
});
|
|
606
|
+
|
|
607
|
+
it('serialize ignores invalid flags', function () {
|
|
608
|
+
blob = hb.createBlob(fs.readFileSync(path.join(__dirname, 'fonts/noto/NotoSans-Regular.ttf')));
|
|
609
|
+
face = hb.createFace(blob);
|
|
610
|
+
font = hb.createFont(face);
|
|
611
|
+
buffer = hb.createBuffer();
|
|
612
|
+
buffer.addText('abc');
|
|
613
|
+
buffer.guessSegmentProperties();
|
|
614
|
+
hb.shape(font, buffer)
|
|
615
|
+
const glyphs = buffer.serialize(font, 0, null, "TEXT", ["invalidFlag"]);
|
|
616
|
+
expect(glyphs).to.deep.equal("[a=0+561|b=1+615|c=2+480]");
|
|
617
|
+
});
|
|
618
|
+
|
|
619
|
+
it('reset resets the buffer', function () {
|
|
620
|
+
blob = hb.createBlob(fs.readFileSync(path.join(__dirname, 'fonts/noto/NotoSans-Regular.ttf')));
|
|
621
|
+
face = hb.createFace(blob);
|
|
622
|
+
font = hb.createFont(face);
|
|
623
|
+
buffer = hb.createBuffer();
|
|
624
|
+
buffer.addText('abc');
|
|
625
|
+
buffer.guessSegmentProperties();
|
|
626
|
+
expect(buffer.getContentType()).to.equal("UNICODE");
|
|
627
|
+
hb.shape(font, buffer)
|
|
628
|
+
expect(buffer.getContentType()).to.equal("GLYPHS");
|
|
629
|
+
buffer.reset();
|
|
630
|
+
expect(buffer.getContentType()).to.equal("INVALID");
|
|
631
|
+
});
|
|
632
|
+
|
|
633
|
+
it('getLength gets the length before and after shaping', function () {
|
|
634
|
+
blob = hb.createBlob(fs.readFileSync(path.join(__dirname, 'fonts/noto/NotoSans-Regular.ttf')));
|
|
635
|
+
face = hb.createFace(blob);
|
|
636
|
+
font = hb.createFont(face);
|
|
637
|
+
buffer = hb.createBuffer();
|
|
638
|
+
buffer.addText('fi');
|
|
639
|
+
expect(buffer.getLength()).to.equal(2);
|
|
640
|
+
buffer.guessSegmentProperties();
|
|
641
|
+
hb.shape(font, buffer)
|
|
642
|
+
expect(buffer.getLength()).to.equal(1);
|
|
643
|
+
});
|
|
644
|
+
|
|
645
|
+
it('getInfos and getPositions return empty arrays for empty buffer', function () {
|
|
646
|
+
blob = hb.createBlob(fs.readFileSync(path.join(__dirname, 'fonts/noto/NotoSans-Regular.ttf')));
|
|
647
|
+
face = hb.createFace(blob);
|
|
648
|
+
font = hb.createFont(face);
|
|
649
|
+
buffer = hb.createBuffer();
|
|
650
|
+
expect(buffer.getGlyphInfos()).to.deep.equal([]);
|
|
651
|
+
expect(buffer.getGlyphPositions()).to.deep.equal([]);
|
|
652
|
+
});
|
|
653
|
+
|
|
654
|
+
it('getInfos and getPositions return non empty arrays for non empty buffer', function () {
|
|
655
|
+
blob = hb.createBlob(fs.readFileSync(path.join(__dirname, 'fonts/noto/NotoSans-Regular.ttf')));
|
|
656
|
+
face = hb.createFace(blob);
|
|
657
|
+
font = hb.createFont(face);
|
|
658
|
+
buffer = hb.createBuffer();
|
|
659
|
+
buffer.addText('x\u0300fi'); // combining mark and ligature to make the test more interesting
|
|
660
|
+
buffer.guessSegmentProperties();
|
|
661
|
+
|
|
662
|
+
// before shaping
|
|
663
|
+
expect(buffer.getGlyphInfos()).to.deep.equal([
|
|
664
|
+
{ codepoint: 120, cluster: 0 },
|
|
665
|
+
{ codepoint: 768, cluster: 1 },
|
|
666
|
+
{ codepoint: 102, cluster: 2 },
|
|
667
|
+
{ codepoint: 105, cluster: 3 }
|
|
668
|
+
]);
|
|
669
|
+
expect(buffer.getGlyphPositions()).to.deep.equal([
|
|
670
|
+
{ x_advance: 0, y_advance: 0, x_offset: 0, y_offset: 0 },
|
|
671
|
+
{ x_advance: 0, y_advance: 0, x_offset: 0, y_offset: 0 },
|
|
672
|
+
{ x_advance: 0, y_advance: 0, x_offset: 0, y_offset: 0 },
|
|
673
|
+
{ x_advance: 0, y_advance: 0, x_offset: 0, y_offset: 0 }
|
|
674
|
+
]);
|
|
675
|
+
|
|
676
|
+
hb.shape(font, buffer);
|
|
677
|
+
// after shaping
|
|
678
|
+
expect(buffer.getGlyphInfos()).to.deep.equal([
|
|
679
|
+
{ codepoint: 91, cluster: 0 },
|
|
680
|
+
{ codepoint: 2662, cluster: 0 },
|
|
681
|
+
{ codepoint: 1652, cluster: 2 }
|
|
682
|
+
]);
|
|
683
|
+
expect(buffer.getGlyphPositions()).to.deep.equal([
|
|
684
|
+
{ x_advance: 529, y_advance: 0, x_offset: 0, y_offset: 0 },
|
|
685
|
+
{ x_advance: 0, y_advance: 0, x_offset: 97, y_offset: 0 },
|
|
686
|
+
{ x_advance: 602, y_advance: 0, x_offset: 0, y_offset: 0 }
|
|
687
|
+
]);
|
|
688
|
+
});
|
|
689
|
+
|
|
690
|
+
it('getPositions returns empty array for buffer without positions', function () {
|
|
691
|
+
blob = hb.createBlob(fs.readFileSync(path.join(__dirname, 'fonts/noto/NotoSans-Regular.ttf')));
|
|
692
|
+
face = hb.createFace(blob);
|
|
693
|
+
font = hb.createFont(face);
|
|
694
|
+
buffer = hb.createBuffer();
|
|
695
|
+
buffer.addText('abc');
|
|
696
|
+
buffer.guessSegmentProperties();
|
|
697
|
+
var currentPhase = "";
|
|
698
|
+
buffer.setMessageFunc((buffer, font, message) => {
|
|
699
|
+
if (message.startsWith("start table GSUB"))
|
|
700
|
+
currentPhase = "GSUB";
|
|
701
|
+
else if (message.startsWith("start table GPOS"))
|
|
702
|
+
currentPhase = "GPOS";
|
|
703
|
+
|
|
704
|
+
if (currentPhase === "GSUB")
|
|
705
|
+
expect(buffer.getGlyphPositions()).to.deep.equal([]);
|
|
706
|
+
else if (currentPhase === "GPOS")
|
|
707
|
+
expect(buffer.getGlyphPositions()).to.not.deep.equal([]);
|
|
708
|
+
|
|
709
|
+
return true;
|
|
710
|
+
});
|
|
711
|
+
hb.shape(font, buffer);
|
|
712
|
+
});
|
|
713
|
+
|
|
714
|
+
it('updateGlyphPositions updates the glyph positions', function () {
|
|
715
|
+
blob = hb.createBlob(fs.readFileSync(path.join(__dirname, 'fonts/noto/NotoSans-Regular.ttf')));
|
|
716
|
+
face = hb.createFace(blob);
|
|
717
|
+
font = hb.createFont(face);
|
|
718
|
+
buffer = hb.createBuffer();
|
|
719
|
+
|
|
720
|
+
// text with a base glyph and two marks to test mkmk after manually updating glyph positions
|
|
721
|
+
var text = 'x\u0302\u0300';
|
|
722
|
+
|
|
723
|
+
// without updateGlyphPositions
|
|
724
|
+
buffer.addText(text);
|
|
725
|
+
buffer.guessSegmentProperties();
|
|
726
|
+
hb.shape(font, buffer);
|
|
727
|
+
var positions = buffer.getGlyphPositions();
|
|
728
|
+
expect(positions[1].y_offset).to.equal(0);
|
|
729
|
+
expect(positions[2].y_offset).to.equal(229);
|
|
730
|
+
|
|
731
|
+
// with updateGlyphPositions inside buffer message callback
|
|
732
|
+
buffer.clearContents();
|
|
733
|
+
buffer.addText(text);
|
|
734
|
+
buffer.guessSegmentProperties();
|
|
735
|
+
var currentPhase = "";
|
|
736
|
+
buffer.setMessageFunc((buffer, font, message) => {
|
|
737
|
+
if (message.startsWith("start table GSUB"))
|
|
738
|
+
currentPhase = "GSUB";
|
|
739
|
+
else if (message.startsWith("start table GPOS"))
|
|
740
|
+
currentPhase = "GPOS";
|
|
741
|
+
|
|
742
|
+
// modify the 2nd glyph y_offset after the last mark lookup and before mkmk lookups
|
|
743
|
+
if (currentPhase === "GPOS" && message.startsWith("end lookup 4 feature 'mark'")) {
|
|
744
|
+
var positions = buffer.getGlyphPositions();
|
|
745
|
+
expect(positions[1].y_offset).to.equal(0);
|
|
746
|
+
expect(positions[2].y_offset).to.equal(0);
|
|
747
|
+
positions[1].y_offset += 10;
|
|
748
|
+
buffer.updateGlyphPositions(positions);
|
|
749
|
+
}
|
|
750
|
+
|
|
751
|
+
return true;
|
|
752
|
+
});
|
|
753
|
+
|
|
754
|
+
hb.shape(font, buffer);
|
|
755
|
+
var positions = buffer.getGlyphPositions();
|
|
756
|
+
|
|
757
|
+
// both mark glyphs now be offset vertically by 10, since the second mark attaches to the first mark
|
|
758
|
+
expect(positions[1].y_offset).to.equal(10);
|
|
759
|
+
expect(positions[2].y_offset).to.equal(239);
|
|
760
|
+
});
|
|
572
761
|
});
|
|
573
762
|
|
|
574
763
|
describe('shape', function () {
|
|
@@ -714,9 +903,8 @@ describe('shape', function () {
|
|
|
714
903
|
var glyphs = buffer.json();
|
|
715
904
|
expect(glyphs).to.have.lengthOf(2);
|
|
716
905
|
expect(glyphs[0].g).to.equal(118);
|
|
717
|
-
buffer.destroy();
|
|
718
906
|
|
|
719
|
-
buffer
|
|
907
|
+
buffer.clearContents();
|
|
720
908
|
buffer.addText('५ल');
|
|
721
909
|
buffer.setLanguage('dty');
|
|
722
910
|
buffer.guessSegmentProperties();
|
|
@@ -737,9 +925,8 @@ describe('shape', function () {
|
|
|
737
925
|
var glyphs = buffer.json();
|
|
738
926
|
expect(glyphs).to.have.lengthOf(2);
|
|
739
927
|
expect(glyphs[0].g).to.equal(118);
|
|
740
|
-
buffer.destroy();
|
|
741
928
|
|
|
742
|
-
buffer
|
|
929
|
+
buffer.clearContents();
|
|
743
930
|
buffer.addText('५ल');
|
|
744
931
|
buffer.setLanguage('x-hbot-4e455020'); // 'NEP '
|
|
745
932
|
buffer.guessSegmentProperties();
|
package/.vscode/settings.json
DELETED