harfbuzzjs 1.0.0-beta.2 → 1.1.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/dist/harfbuzz.js +1 -1
- package/dist/harfbuzz.wasm +0 -0
- package/dist/index.d.mts +241 -189
- package/dist/index.mjs +93 -0
- package/package.json +1 -1
package/dist/harfbuzz.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
async function createHarfBuzz(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";if(ENVIRONMENT_IS_NODE){const{createRequire}=await import("module");var require=createRequire(import.meta.url)}var arguments_=[];var thisProgram="./this.program";var quit_=(status,toThrow)=>{throw toThrow};var _scriptName=import.meta.url;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");if(_scriptName.startsWith("file:")){scriptDirectory=require("path").dirname(require("url").fileURLToPath(_scriptName))+"/"}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(){if(Module["locateFile"]){return locateFile("harfbuzz.wasm")}return new URL("harfbuzz.wasm",import.meta.url).href}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_add,_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,_hb_feature_to_string,_hb_variation_from_string,_hb_variation_to_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_add"]=_hb_buffer_add=wasmExports["hb_buffer_add"];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["_hb_feature_to_string"]=_hb_feature_to_string=wasmExports["hb_feature_to_string"];Module["_hb_variation_from_string"]=_hb_variation_from_string=wasmExports["hb_variation_from_string"];Module["_hb_variation_to_string"]=_hb_variation_to_string=wasmExports["hb_variation_to_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})}
|
|
1
|
+
async function createHarfBuzz(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";if(ENVIRONMENT_IS_NODE){const{createRequire}=await import("module");var require=createRequire(import.meta.url)}var arguments_=[];var thisProgram="./this.program";var quit_=(status,toThrow)=>{throw toThrow};var _scriptName=import.meta.url;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");if(_scriptName.startsWith("file:")){scriptDirectory=require("path").dirname(require("url").fileURLToPath(_scriptName))+"/"}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(){if(Module["locateFile"]){return locateFile("harfbuzz.wasm")}return new URL("harfbuzz.wasm",import.meta.url).href}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_add,_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,_hb_feature_to_string,_hb_variation_from_string,_hb_variation_to_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,_hb_font_get_nominal_glyph,_hb_font_get_variation_glyph,_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_lookups,_hb_ot_layout_feature_get_name_ids,_hb_ot_layout_lookup_get_optical_bound,_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_add"]=_hb_buffer_add=wasmExports["hb_buffer_add"];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["_hb_feature_to_string"]=_hb_feature_to_string=wasmExports["hb_feature_to_string"];Module["_hb_variation_from_string"]=_hb_variation_from_string=wasmExports["hb_variation_from_string"];Module["_hb_variation_to_string"]=_hb_variation_to_string=wasmExports["hb_variation_to_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"]=_hb_font_get_glyph=wasmExports["hb_font_get_glyph"];Module["_hb_font_get_nominal_glyph"]=_hb_font_get_nominal_glyph=wasmExports["hb_font_get_nominal_glyph"];Module["_hb_font_get_variation_glyph"]=_hb_font_get_variation_glyph=wasmExports["hb_font_get_variation_glyph"];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_lookups"]=_hb_ot_layout_feature_get_lookups=wasmExports["hb_ot_layout_feature_get_lookups"];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_layout_lookup_get_optical_bound"]=_hb_ot_layout_lookup_get_optical_bound=wasmExports["hb_ot_layout_lookup_get_optical_bound"];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}export default createHarfBuzz;
|
package/dist/harfbuzz.wasm
CHANGED
|
Binary file
|
package/dist/index.d.mts
CHANGED
|
@@ -155,6 +155,14 @@ declare class Face {
|
|
|
155
155
|
* @returns An array of 4-character feature tag strings.
|
|
156
156
|
*/
|
|
157
157
|
getLanguageFeatureTags(table: string, scriptIndex: number, languageIndex: number): string[];
|
|
158
|
+
/**
|
|
159
|
+
* Fetches a list of all lookups enumerated for the specified feature, in
|
|
160
|
+
* the specified face's GSUB table or GPOS table.
|
|
161
|
+
* @param table The table to query, either "GSUB" or "GPOS".
|
|
162
|
+
* @param featureIndex The index of the requested feature.
|
|
163
|
+
* @returns An array of lookup indexes.
|
|
164
|
+
*/
|
|
165
|
+
getFeatureLookups(table: string, featureIndex: number): number[];
|
|
158
166
|
/**
|
|
159
167
|
* Get the GDEF class of the requested glyph.
|
|
160
168
|
* @param glyph The glyph to get the class of.
|
|
@@ -182,6 +190,197 @@ declare class Face {
|
|
|
182
190
|
getFeatureNameIds(table: string, featureIndex: number): FeatureNameIds | undefined;
|
|
183
191
|
}
|
|
184
192
|
//#endregion
|
|
193
|
+
//#region src/buffer.d.ts
|
|
194
|
+
declare const BufferContentType: {
|
|
195
|
+
readonly INVALID: 0;
|
|
196
|
+
readonly UNICODE: 1;
|
|
197
|
+
readonly GLYPHS: 2;
|
|
198
|
+
};
|
|
199
|
+
type BufferContentType = ValueOf<typeof BufferContentType>;
|
|
200
|
+
declare const BufferSerializeFlag: {
|
|
201
|
+
readonly DEFAULT: 0;
|
|
202
|
+
readonly NO_CLUSTERS: 1;
|
|
203
|
+
readonly NO_POSITIONS: 2;
|
|
204
|
+
readonly NO_GLYPH_NAMES: 4;
|
|
205
|
+
readonly GLYPH_EXTENTS: 8;
|
|
206
|
+
readonly GLYPH_FLAGS: 16;
|
|
207
|
+
readonly NO_ADVANCES: 32;
|
|
208
|
+
readonly DEFINED: 63;
|
|
209
|
+
};
|
|
210
|
+
type BufferSerializeFlag = ValueOf<typeof BufferSerializeFlag>;
|
|
211
|
+
declare const BufferFlag: {
|
|
212
|
+
readonly DEFAULT: 0;
|
|
213
|
+
readonly BOT: 1;
|
|
214
|
+
readonly EOT: 2;
|
|
215
|
+
readonly PRESERVE_DEFAULT_IGNORABLES: 4;
|
|
216
|
+
readonly REMOVE_DEFAULT_IGNORABLES: 8;
|
|
217
|
+
readonly DO_NOT_INSERT_DOTTED_CIRCLE: 16;
|
|
218
|
+
readonly VERIFY: 32;
|
|
219
|
+
readonly PRODUCE_UNSAFE_TO_CONCAT: 64;
|
|
220
|
+
readonly PRODUCE_SAFE_TO_INSERT_TATWEEL: 128;
|
|
221
|
+
readonly DEFINED: 255;
|
|
222
|
+
};
|
|
223
|
+
type BufferFlag = ValueOf<typeof BufferFlag>;
|
|
224
|
+
declare const Direction: {
|
|
225
|
+
readonly INVALID: 0;
|
|
226
|
+
readonly LTR: 4;
|
|
227
|
+
readonly RTL: 5;
|
|
228
|
+
readonly TTB: 6;
|
|
229
|
+
readonly BTT: 7;
|
|
230
|
+
};
|
|
231
|
+
type Direction = ValueOf<typeof Direction>;
|
|
232
|
+
declare const ClusterLevel: {
|
|
233
|
+
readonly MONOTONE_GRAPHEMES: 0;
|
|
234
|
+
readonly MONOTONE_CHARACTERS: 1;
|
|
235
|
+
readonly CHARACTERS: 2;
|
|
236
|
+
readonly GRAPHEMES: 3;
|
|
237
|
+
readonly DEFAULT: 0;
|
|
238
|
+
};
|
|
239
|
+
type ClusterLevel = ValueOf<typeof ClusterLevel>;
|
|
240
|
+
declare const BufferSerializeFormat: {
|
|
241
|
+
readonly INVALID: 0;
|
|
242
|
+
readonly TEXT: number;
|
|
243
|
+
readonly JSON: number;
|
|
244
|
+
};
|
|
245
|
+
type BufferSerializeFormat = ValueOf<typeof BufferSerializeFormat>;
|
|
246
|
+
/**
|
|
247
|
+
* An object representing a {@link https://harfbuzz.github.io/harfbuzz-hb-buffer.html | HarfBuzz buffer}.
|
|
248
|
+
* A buffer holds the input text and its properties before shaping, and the
|
|
249
|
+
* output glyphs and their information after shaping.
|
|
250
|
+
*/
|
|
251
|
+
declare class Buffer {
|
|
252
|
+
readonly ptr: number;
|
|
253
|
+
/**
|
|
254
|
+
* @param existingPtr @internal Wrap an existing buffer pointer.
|
|
255
|
+
*/
|
|
256
|
+
constructor(existingPtr?: number);
|
|
257
|
+
/**
|
|
258
|
+
* Appends a character with the Unicode value of `codePoint` to the buffer,
|
|
259
|
+
* and gives it the initial cluster value of `cluster`. Clusters can be any
|
|
260
|
+
* thing the client wants, they are usually used to refer to the index of the
|
|
261
|
+
* character in the input text stream and are output in the `cluster` field
|
|
262
|
+
* of {@link GlyphInfo}.
|
|
263
|
+
*
|
|
264
|
+
* This function does not check the validity of `codePoint`, it is up to the
|
|
265
|
+
* caller to ensure it is a valid Unicode code point.
|
|
266
|
+
* @param codePoint A Unicode code point.
|
|
267
|
+
* @param cluster The cluster value of `codePoint`.
|
|
268
|
+
*/
|
|
269
|
+
add(codePoint: number, cluster: number): void;
|
|
270
|
+
/**
|
|
271
|
+
* Add text to the buffer.
|
|
272
|
+
* @param text Text to be added to the buffer.
|
|
273
|
+
* @param itemOffset The offset of the first character to add to the buffer.
|
|
274
|
+
* @param itemLength The number of characters to add to the buffer, or omit for the end of text.
|
|
275
|
+
*/
|
|
276
|
+
addText(text: string, itemOffset?: number, itemLength?: number): void;
|
|
277
|
+
/**
|
|
278
|
+
* Add code points to the buffer.
|
|
279
|
+
* @param codePoints Array of code points to be added to the buffer.
|
|
280
|
+
* @param itemOffset The offset of the first code point to add to the buffer.
|
|
281
|
+
* @param itemLength The number of code points to add to the buffer, or omit for the end of the array.
|
|
282
|
+
*/
|
|
283
|
+
addCodePoints(codePoints: number[], itemOffset?: number, itemLength?: number): void;
|
|
284
|
+
/**
|
|
285
|
+
* Set buffer script, language and direction.
|
|
286
|
+
*
|
|
287
|
+
* This needs to be done before shaping.
|
|
288
|
+
*/
|
|
289
|
+
guessSegmentProperties(): void;
|
|
290
|
+
/**
|
|
291
|
+
* Set buffer direction explicitly.
|
|
292
|
+
* @param dir A {@link Direction} value.
|
|
293
|
+
*/
|
|
294
|
+
setDirection(dir: Direction): void;
|
|
295
|
+
/**
|
|
296
|
+
* Set buffer flags explicitly.
|
|
297
|
+
* @param flags A combination of {@link BufferFlag} values (OR them together).
|
|
298
|
+
*/
|
|
299
|
+
setFlags(flags: number): void;
|
|
300
|
+
/**
|
|
301
|
+
* Set buffer language explicitly.
|
|
302
|
+
* @param language The buffer language
|
|
303
|
+
*/
|
|
304
|
+
setLanguage(language: string): void;
|
|
305
|
+
/**
|
|
306
|
+
* Set buffer script explicitly.
|
|
307
|
+
* @param script The buffer script
|
|
308
|
+
*/
|
|
309
|
+
setScript(script: string): void;
|
|
310
|
+
/**
|
|
311
|
+
* Set the HarfBuzz clustering level.
|
|
312
|
+
*
|
|
313
|
+
* Affects the cluster values returned from shaping.
|
|
314
|
+
* @param level A {@link ClusterLevel} value. See the HarfBuzz manual chapter on Clusters.
|
|
315
|
+
*/
|
|
316
|
+
setClusterLevel(level: ClusterLevel): void;
|
|
317
|
+
/** Reset the buffer to its initial status. */
|
|
318
|
+
reset(): void;
|
|
319
|
+
/**
|
|
320
|
+
* Similar to reset(), but does not clear the Unicode functions and the
|
|
321
|
+
* replacement code point.
|
|
322
|
+
*/
|
|
323
|
+
clearContents(): void;
|
|
324
|
+
/**
|
|
325
|
+
* Set message func.
|
|
326
|
+
* @param func The function to set. It receives the buffer, font, and message
|
|
327
|
+
* string as arguments. Returning false will skip this shaping step and move
|
|
328
|
+
* to the next one.
|
|
329
|
+
*/
|
|
330
|
+
setMessageFunc(func: (buffer: Buffer, font: Font, message: string) => boolean): void;
|
|
331
|
+
/**
|
|
332
|
+
* Get the the number of items in the buffer.
|
|
333
|
+
* @returns The buffer length.
|
|
334
|
+
*/
|
|
335
|
+
getLength(): number;
|
|
336
|
+
/**
|
|
337
|
+
* Get the glyph information from the buffer.
|
|
338
|
+
* @returns An array of {@link GlyphInfo} objects.
|
|
339
|
+
*/
|
|
340
|
+
getGlyphInfos(): GlyphInfo[];
|
|
341
|
+
/**
|
|
342
|
+
* Get the glyph positions from the buffer.
|
|
343
|
+
* @returns An array of {@link GlyphPosition} objects.
|
|
344
|
+
*/
|
|
345
|
+
getGlyphPositions(): GlyphPosition[];
|
|
346
|
+
/**
|
|
347
|
+
* Get the glyph information and positions from the buffer.
|
|
348
|
+
* @returns The glyph information and positions.
|
|
349
|
+
*
|
|
350
|
+
* The glyph information is returned as an array of objects with the
|
|
351
|
+
* properties from getGlyphInfos and getGlyphPositions combined.
|
|
352
|
+
*/
|
|
353
|
+
getGlyphInfosAndPositions(): (GlyphInfo & Partial<GlyphPosition>)[];
|
|
354
|
+
/**
|
|
355
|
+
* Update the glyph positions in the buffer.
|
|
356
|
+
* WARNING: Do not use unless you know what you are doing.
|
|
357
|
+
*/
|
|
358
|
+
updateGlyphPositions(positions: GlyphPosition[]): void;
|
|
359
|
+
/**
|
|
360
|
+
* Serialize the buffer contents to a string.
|
|
361
|
+
* @param options Serialization options:
|
|
362
|
+
* - `font`: the font to use for serialization;
|
|
363
|
+
* - `start`: the starting index of the glyphs (default `0`);
|
|
364
|
+
* - `end`: the ending index of the glyphs (default end of buffer);
|
|
365
|
+
* - `format`: a {@link BufferSerializeFormat} value (default `TEXT`);
|
|
366
|
+
* - `flags`: a combination of {@link BufferSerializeFlag} values (default `0`).
|
|
367
|
+
* @returns The serialized buffer contents.
|
|
368
|
+
*/
|
|
369
|
+
serialize(options?: {
|
|
370
|
+
font?: Font;
|
|
371
|
+
start?: number;
|
|
372
|
+
end?: number;
|
|
373
|
+
format?: BufferSerializeFormat;
|
|
374
|
+
flags?: number;
|
|
375
|
+
}): string;
|
|
376
|
+
/**
|
|
377
|
+
* Return the buffer content type.
|
|
378
|
+
*
|
|
379
|
+
* @returns The buffer content type as a {@link BufferContentType} value.
|
|
380
|
+
*/
|
|
381
|
+
getContentType(): BufferContentType;
|
|
382
|
+
}
|
|
383
|
+
//#endregion
|
|
185
384
|
//#region src/font-funcs.d.ts
|
|
186
385
|
/**
|
|
187
386
|
* An object representing {@link https://harfbuzz.github.io/harfbuzz-hb-font.html | HarfBuzz font functions}.
|
|
@@ -380,6 +579,41 @@ declare class Font {
|
|
|
380
579
|
* @returns An object with xBearing, yBearing, width, and height, or undefined.
|
|
381
580
|
*/
|
|
382
581
|
glyphExtents(glyphId: number): GlyphExtents | undefined;
|
|
582
|
+
/**
|
|
583
|
+
* Fetches the glyph ID for a Unicode code point in the specified
|
|
584
|
+
* font, with an optional variation selector.
|
|
585
|
+
*
|
|
586
|
+
* If `variationSelector` is 0, it is equivalent to
|
|
587
|
+
* {@link Font.nominalGlyph}; otherwise it is equivalent to
|
|
588
|
+
* {@link Font.variationGlyph}.
|
|
589
|
+
*
|
|
590
|
+
* @param unicode The Unicode code point to query.
|
|
591
|
+
* @param variationSelector A variation-selector code point.
|
|
592
|
+
* @returns The glyph ID, or undefined if not found.
|
|
593
|
+
*/
|
|
594
|
+
glyph(unicode: number, variationSelector?: number): number | undefined;
|
|
595
|
+
/**
|
|
596
|
+
* Fetches the nominal glyph ID for a Unicode code point in the
|
|
597
|
+
* specified font.
|
|
598
|
+
*
|
|
599
|
+
* This version of the function should not be used to fetch glyph IDs
|
|
600
|
+
* for code points modified by variation selectors. For variation-selector
|
|
601
|
+
* support, use {@link Font.variationGlyph} or {@link Font.glyph}.
|
|
602
|
+
*
|
|
603
|
+
* @param unicode The Unicode code point to query.
|
|
604
|
+
* @returns The glyph ID, or undefined if not found.
|
|
605
|
+
*/
|
|
606
|
+
nominalGlyph(unicode: number): number | undefined;
|
|
607
|
+
/**
|
|
608
|
+
* Fetches the glyph ID for a Unicode code point when followed by
|
|
609
|
+
* by the specified variation-selector code point, in the specified
|
|
610
|
+
* font.
|
|
611
|
+
*
|
|
612
|
+
* @param unicode The Unicode code point to query.
|
|
613
|
+
* @param variationSelector The variation-selector code point to query.
|
|
614
|
+
* @returns The glyph ID, or undefined if not found.
|
|
615
|
+
*/
|
|
616
|
+
variationGlyph(unicode: number, variationSelector: number): number | undefined;
|
|
383
617
|
/**
|
|
384
618
|
* Return glyph ID from name.
|
|
385
619
|
* @param name Name of the requested glyph in the font.
|
|
@@ -412,197 +646,15 @@ declare class Font {
|
|
|
412
646
|
setVariations(variations: Variation[]): void;
|
|
413
647
|
/** Set the font's font functions. */
|
|
414
648
|
setFuncs(fontFuncs: FontFuncs): void;
|
|
415
|
-
}
|
|
416
|
-
//#endregion
|
|
417
|
-
//#region src/buffer.d.ts
|
|
418
|
-
declare const BufferContentType: {
|
|
419
|
-
readonly INVALID: 0;
|
|
420
|
-
readonly UNICODE: 1;
|
|
421
|
-
readonly GLYPHS: 2;
|
|
422
|
-
};
|
|
423
|
-
type BufferContentType = ValueOf<typeof BufferContentType>;
|
|
424
|
-
declare const BufferSerializeFlag: {
|
|
425
|
-
readonly DEFAULT: 0;
|
|
426
|
-
readonly NO_CLUSTERS: 1;
|
|
427
|
-
readonly NO_POSITIONS: 2;
|
|
428
|
-
readonly NO_GLYPH_NAMES: 4;
|
|
429
|
-
readonly GLYPH_EXTENTS: 8;
|
|
430
|
-
readonly GLYPH_FLAGS: 16;
|
|
431
|
-
readonly NO_ADVANCES: 32;
|
|
432
|
-
readonly DEFINED: 63;
|
|
433
|
-
};
|
|
434
|
-
type BufferSerializeFlag = ValueOf<typeof BufferSerializeFlag>;
|
|
435
|
-
declare const BufferFlag: {
|
|
436
|
-
readonly DEFAULT: 0;
|
|
437
|
-
readonly BOT: 1;
|
|
438
|
-
readonly EOT: 2;
|
|
439
|
-
readonly PRESERVE_DEFAULT_IGNORABLES: 4;
|
|
440
|
-
readonly REMOVE_DEFAULT_IGNORABLES: 8;
|
|
441
|
-
readonly DO_NOT_INSERT_DOTTED_CIRCLE: 16;
|
|
442
|
-
readonly VERIFY: 32;
|
|
443
|
-
readonly PRODUCE_UNSAFE_TO_CONCAT: 64;
|
|
444
|
-
readonly PRODUCE_SAFE_TO_INSERT_TATWEEL: 128;
|
|
445
|
-
readonly DEFINED: 255;
|
|
446
|
-
};
|
|
447
|
-
type BufferFlag = ValueOf<typeof BufferFlag>;
|
|
448
|
-
declare const Direction: {
|
|
449
|
-
readonly INVALID: 0;
|
|
450
|
-
readonly LTR: 4;
|
|
451
|
-
readonly RTL: 5;
|
|
452
|
-
readonly TTB: 6;
|
|
453
|
-
readonly BTT: 7;
|
|
454
|
-
};
|
|
455
|
-
type Direction = ValueOf<typeof Direction>;
|
|
456
|
-
declare const ClusterLevel: {
|
|
457
|
-
readonly MONOTONE_GRAPHEMES: 0;
|
|
458
|
-
readonly MONOTONE_CHARACTERS: 1;
|
|
459
|
-
readonly CHARACTERS: 2;
|
|
460
|
-
readonly GRAPHEMES: 3;
|
|
461
|
-
readonly DEFAULT: 0;
|
|
462
|
-
};
|
|
463
|
-
type ClusterLevel = ValueOf<typeof ClusterLevel>;
|
|
464
|
-
declare const BufferSerializeFormat: {
|
|
465
|
-
readonly INVALID: 0;
|
|
466
|
-
readonly TEXT: number;
|
|
467
|
-
readonly JSON: number;
|
|
468
|
-
};
|
|
469
|
-
type BufferSerializeFormat = ValueOf<typeof BufferSerializeFormat>;
|
|
470
|
-
/**
|
|
471
|
-
* An object representing a {@link https://harfbuzz.github.io/harfbuzz-hb-buffer.html | HarfBuzz buffer}.
|
|
472
|
-
* A buffer holds the input text and its properties before shaping, and the
|
|
473
|
-
* output glyphs and their information after shaping.
|
|
474
|
-
*/
|
|
475
|
-
declare class Buffer {
|
|
476
|
-
readonly ptr: number;
|
|
477
|
-
/**
|
|
478
|
-
* @param existingPtr @internal Wrap an existing buffer pointer.
|
|
479
|
-
*/
|
|
480
|
-
constructor(existingPtr?: number);
|
|
481
|
-
/**
|
|
482
|
-
* Appends a character with the Unicode value of `codePoint` to the buffer,
|
|
483
|
-
* and gives it the initial cluster value of `cluster`. Clusters can be any
|
|
484
|
-
* thing the client wants, they are usually used to refer to the index of the
|
|
485
|
-
* character in the input text stream and are output in the `cluster` field
|
|
486
|
-
* of {@link GlyphInfo}.
|
|
487
|
-
*
|
|
488
|
-
* This function does not check the validity of `codePoint`, it is up to the
|
|
489
|
-
* caller to ensure it is a valid Unicode code point.
|
|
490
|
-
* @param codePoint A Unicode code point.
|
|
491
|
-
* @param cluster The cluster value of `codePoint`.
|
|
492
|
-
*/
|
|
493
|
-
add(codePoint: number, cluster: number): void;
|
|
494
|
-
/**
|
|
495
|
-
* Add text to the buffer.
|
|
496
|
-
* @param text Text to be added to the buffer.
|
|
497
|
-
* @param itemOffset The offset of the first character to add to the buffer.
|
|
498
|
-
* @param itemLength The number of characters to add to the buffer, or omit for the end of text.
|
|
499
|
-
*/
|
|
500
|
-
addText(text: string, itemOffset?: number, itemLength?: number): void;
|
|
501
|
-
/**
|
|
502
|
-
* Add code points to the buffer.
|
|
503
|
-
* @param codePoints Array of code points to be added to the buffer.
|
|
504
|
-
* @param itemOffset The offset of the first code point to add to the buffer.
|
|
505
|
-
* @param itemLength The number of code points to add to the buffer, or omit for the end of the array.
|
|
506
|
-
*/
|
|
507
|
-
addCodePoints(codePoints: number[], itemOffset?: number, itemLength?: number): void;
|
|
508
|
-
/**
|
|
509
|
-
* Set buffer script, language and direction.
|
|
510
|
-
*
|
|
511
|
-
* This needs to be done before shaping.
|
|
512
|
-
*/
|
|
513
|
-
guessSegmentProperties(): void;
|
|
514
|
-
/**
|
|
515
|
-
* Set buffer direction explicitly.
|
|
516
|
-
* @param dir A {@link Direction} value.
|
|
517
|
-
*/
|
|
518
|
-
setDirection(dir: Direction): void;
|
|
519
|
-
/**
|
|
520
|
-
* Set buffer flags explicitly.
|
|
521
|
-
* @param flags A combination of {@link BufferFlag} values (OR them together).
|
|
522
|
-
*/
|
|
523
|
-
setFlags(flags: number): void;
|
|
524
|
-
/**
|
|
525
|
-
* Set buffer language explicitly.
|
|
526
|
-
* @param language The buffer language
|
|
527
|
-
*/
|
|
528
|
-
setLanguage(language: string): void;
|
|
529
|
-
/**
|
|
530
|
-
* Set buffer script explicitly.
|
|
531
|
-
* @param script The buffer script
|
|
532
|
-
*/
|
|
533
|
-
setScript(script: string): void;
|
|
534
649
|
/**
|
|
535
|
-
*
|
|
536
|
-
*
|
|
537
|
-
*
|
|
538
|
-
* @param
|
|
650
|
+
* Fetches the optical bound of a glyph positioned at the margin of text.
|
|
651
|
+
* The direction identifies which edge of the glyph to query.
|
|
652
|
+
* @param lookupIndex Index of the feature lookup to query.
|
|
653
|
+
* @param direction Edge of the glyph to query.
|
|
654
|
+
* @param glyph A glyph id.
|
|
655
|
+
* @returns Adjustment value. Negative values mean the glyph will stick out of the margin.
|
|
539
656
|
*/
|
|
540
|
-
|
|
541
|
-
/** Reset the buffer to its initial status. */
|
|
542
|
-
reset(): void;
|
|
543
|
-
/**
|
|
544
|
-
* Similar to reset(), but does not clear the Unicode functions and the
|
|
545
|
-
* replacement code point.
|
|
546
|
-
*/
|
|
547
|
-
clearContents(): void;
|
|
548
|
-
/**
|
|
549
|
-
* Set message func.
|
|
550
|
-
* @param func The function to set. It receives the buffer, font, and message
|
|
551
|
-
* string as arguments. Returning false will skip this shaping step and move
|
|
552
|
-
* to the next one.
|
|
553
|
-
*/
|
|
554
|
-
setMessageFunc(func: (buffer: Buffer, font: Font, message: string) => boolean): void;
|
|
555
|
-
/**
|
|
556
|
-
* Get the the number of items in the buffer.
|
|
557
|
-
* @returns The buffer length.
|
|
558
|
-
*/
|
|
559
|
-
getLength(): number;
|
|
560
|
-
/**
|
|
561
|
-
* Get the glyph information from the buffer.
|
|
562
|
-
* @returns An array of {@link GlyphInfo} objects.
|
|
563
|
-
*/
|
|
564
|
-
getGlyphInfos(): GlyphInfo[];
|
|
565
|
-
/**
|
|
566
|
-
* Get the glyph positions from the buffer.
|
|
567
|
-
* @returns An array of {@link GlyphPosition} objects.
|
|
568
|
-
*/
|
|
569
|
-
getGlyphPositions(): GlyphPosition[];
|
|
570
|
-
/**
|
|
571
|
-
* Get the glyph information and positions from the buffer.
|
|
572
|
-
* @returns The glyph information and positions.
|
|
573
|
-
*
|
|
574
|
-
* The glyph information is returned as an array of objects with the
|
|
575
|
-
* properties from getGlyphInfos and getGlyphPositions combined.
|
|
576
|
-
*/
|
|
577
|
-
getGlyphInfosAndPositions(): (GlyphInfo & Partial<GlyphPosition>)[];
|
|
578
|
-
/**
|
|
579
|
-
* Update the glyph positions in the buffer.
|
|
580
|
-
* WARNING: Do not use unless you know what you are doing.
|
|
581
|
-
*/
|
|
582
|
-
updateGlyphPositions(positions: GlyphPosition[]): void;
|
|
583
|
-
/**
|
|
584
|
-
* Serialize the buffer contents to a string.
|
|
585
|
-
* @param options Serialization options:
|
|
586
|
-
* - `font`: the font to use for serialization;
|
|
587
|
-
* - `start`: the starting index of the glyphs (default `0`);
|
|
588
|
-
* - `end`: the ending index of the glyphs (default end of buffer);
|
|
589
|
-
* - `format`: a {@link BufferSerializeFormat} value (default `TEXT`);
|
|
590
|
-
* - `flags`: a combination of {@link BufferSerializeFlag} values (default `0`).
|
|
591
|
-
* @returns The serialized buffer contents.
|
|
592
|
-
*/
|
|
593
|
-
serialize(options?: {
|
|
594
|
-
font?: Font;
|
|
595
|
-
start?: number;
|
|
596
|
-
end?: number;
|
|
597
|
-
format?: BufferSerializeFormat;
|
|
598
|
-
flags?: number;
|
|
599
|
-
}): string;
|
|
600
|
-
/**
|
|
601
|
-
* Return the buffer content type.
|
|
602
|
-
*
|
|
603
|
-
* @returns The buffer content type as a {@link BufferContentType} value.
|
|
604
|
-
*/
|
|
605
|
-
getContentType(): BufferContentType;
|
|
657
|
+
getLookupOpticalBound(lookupIndex: number, direction: Direction, glyph: number): number;
|
|
606
658
|
}
|
|
607
659
|
//#endregion
|
|
608
660
|
//#region src/feature.d.ts
|
package/dist/index.mjs
CHANGED
|
@@ -308,6 +308,32 @@ var Face = class {
|
|
|
308
308
|
return tags;
|
|
309
309
|
}
|
|
310
310
|
/**
|
|
311
|
+
* Fetches a list of all lookups enumerated for the specified feature, in
|
|
312
|
+
* the specified face's GSUB table or GPOS table.
|
|
313
|
+
* @param table The table to query, either "GSUB" or "GPOS".
|
|
314
|
+
* @param featureIndex The index of the requested feature.
|
|
315
|
+
* @returns An array of lookup indexes.
|
|
316
|
+
*/
|
|
317
|
+
getFeatureLookups(table, featureIndex) {
|
|
318
|
+
const sp = Module.stackSave();
|
|
319
|
+
const tableTag = hb_tag(table);
|
|
320
|
+
let startOffset = 0;
|
|
321
|
+
let lookupCount = 128;
|
|
322
|
+
const lookupCountPtr = Module.stackAlloc(4);
|
|
323
|
+
const lookupIndexesPtr = Module.stackAlloc(512);
|
|
324
|
+
const lookups = [];
|
|
325
|
+
while (lookupCount == 128) {
|
|
326
|
+
Module.HEAPU32[lookupCountPtr / 4] = lookupCount;
|
|
327
|
+
exports.hb_ot_layout_feature_get_lookups(this.ptr, tableTag, featureIndex, startOffset, lookupCountPtr, lookupIndexesPtr);
|
|
328
|
+
lookupCount = Module.HEAPU32[lookupCountPtr / 4];
|
|
329
|
+
const lookupIndexes = Module.HEAPU32.subarray(lookupIndexesPtr / 4, lookupIndexesPtr / 4 + lookupCount);
|
|
330
|
+
lookups.push(...Array.from(lookupIndexes));
|
|
331
|
+
startOffset += lookupCount;
|
|
332
|
+
}
|
|
333
|
+
Module.stackRestore(sp);
|
|
334
|
+
return lookups;
|
|
335
|
+
}
|
|
336
|
+
/**
|
|
311
337
|
* Get the GDEF class of the requested glyph.
|
|
312
338
|
* @param glyph The glyph to get the class of.
|
|
313
339
|
* @returns The {@link GlyphClass} of the glyph.
|
|
@@ -564,6 +590,62 @@ var Font = class Font {
|
|
|
564
590
|
return extents;
|
|
565
591
|
}
|
|
566
592
|
/**
|
|
593
|
+
* Fetches the glyph ID for a Unicode code point in the specified
|
|
594
|
+
* font, with an optional variation selector.
|
|
595
|
+
*
|
|
596
|
+
* If `variationSelector` is 0, it is equivalent to
|
|
597
|
+
* {@link Font.nominalGlyph}; otherwise it is equivalent to
|
|
598
|
+
* {@link Font.variationGlyph}.
|
|
599
|
+
*
|
|
600
|
+
* @param unicode The Unicode code point to query.
|
|
601
|
+
* @param variationSelector A variation-selector code point.
|
|
602
|
+
* @returns The glyph ID, or undefined if not found.
|
|
603
|
+
*/
|
|
604
|
+
glyph(unicode, variationSelector = 0) {
|
|
605
|
+
const sp = Module.stackSave();
|
|
606
|
+
const glyphIdPtr = Module.stackAlloc(4);
|
|
607
|
+
let glyphId;
|
|
608
|
+
if (exports.hb_font_get_glyph(this.ptr, unicode, variationSelector, glyphIdPtr)) glyphId = Module.HEAPU32[glyphIdPtr / 4];
|
|
609
|
+
Module.stackRestore(sp);
|
|
610
|
+
return glyphId;
|
|
611
|
+
}
|
|
612
|
+
/**
|
|
613
|
+
* Fetches the nominal glyph ID for a Unicode code point in the
|
|
614
|
+
* specified font.
|
|
615
|
+
*
|
|
616
|
+
* This version of the function should not be used to fetch glyph IDs
|
|
617
|
+
* for code points modified by variation selectors. For variation-selector
|
|
618
|
+
* support, use {@link Font.variationGlyph} or {@link Font.glyph}.
|
|
619
|
+
*
|
|
620
|
+
* @param unicode The Unicode code point to query.
|
|
621
|
+
* @returns The glyph ID, or undefined if not found.
|
|
622
|
+
*/
|
|
623
|
+
nominalGlyph(unicode) {
|
|
624
|
+
const sp = Module.stackSave();
|
|
625
|
+
const glyphIdPtr = Module.stackAlloc(4);
|
|
626
|
+
let glyphId;
|
|
627
|
+
if (exports.hb_font_get_nominal_glyph(this.ptr, unicode, glyphIdPtr)) glyphId = Module.HEAPU32[glyphIdPtr / 4];
|
|
628
|
+
Module.stackRestore(sp);
|
|
629
|
+
return glyphId;
|
|
630
|
+
}
|
|
631
|
+
/**
|
|
632
|
+
* Fetches the glyph ID for a Unicode code point when followed by
|
|
633
|
+
* by the specified variation-selector code point, in the specified
|
|
634
|
+
* font.
|
|
635
|
+
*
|
|
636
|
+
* @param unicode The Unicode code point to query.
|
|
637
|
+
* @param variationSelector The variation-selector code point to query.
|
|
638
|
+
* @returns The glyph ID, or undefined if not found.
|
|
639
|
+
*/
|
|
640
|
+
variationGlyph(unicode, variationSelector) {
|
|
641
|
+
const sp = Module.stackSave();
|
|
642
|
+
const glyphIdPtr = Module.stackAlloc(4);
|
|
643
|
+
let glyphId;
|
|
644
|
+
if (exports.hb_font_get_variation_glyph(this.ptr, unicode, variationSelector, glyphIdPtr)) glyphId = Module.HEAPU32[glyphIdPtr / 4];
|
|
645
|
+
Module.stackRestore(sp);
|
|
646
|
+
return glyphId;
|
|
647
|
+
}
|
|
648
|
+
/**
|
|
567
649
|
* Return glyph ID from name.
|
|
568
650
|
* @param name Name of the requested glyph in the font.
|
|
569
651
|
* @returns The glyph ID, or undefined if not found.
|
|
@@ -624,6 +706,17 @@ var Font = class Font {
|
|
|
624
706
|
setFuncs(fontFuncs) {
|
|
625
707
|
exports.hb_font_set_funcs(this.ptr, fontFuncs.ptr);
|
|
626
708
|
}
|
|
709
|
+
/**
|
|
710
|
+
* Fetches the optical bound of a glyph positioned at the margin of text.
|
|
711
|
+
* The direction identifies which edge of the glyph to query.
|
|
712
|
+
* @param lookupIndex Index of the feature lookup to query.
|
|
713
|
+
* @param direction Edge of the glyph to query.
|
|
714
|
+
* @param glyph A glyph id.
|
|
715
|
+
* @returns Adjustment value. Negative values mean the glyph will stick out of the margin.
|
|
716
|
+
*/
|
|
717
|
+
getLookupOpticalBound(lookupIndex, direction, glyph) {
|
|
718
|
+
return exports.hb_ot_layout_lookup_get_optical_bound(this.ptr, lookupIndex, direction, glyph);
|
|
719
|
+
}
|
|
627
720
|
};
|
|
628
721
|
//#endregion
|
|
629
722
|
//#region src/font-funcs.ts
|