harfbuzzjs 1.0.0-beta.1 → 1.0.0-beta.2
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 +221 -82
- package/dist/index.mjs +256 -87
- 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_get_length,_hb_buffer_get_glyph_infos,_hb_buffer_get_glyph_positions,_hb_glyph_info_get_glyph_flags,_hb_buffer_guess_segment_properties,_hb_buffer_add_utf8,_hb_buffer_add_utf16,_hb_buffer_add_codepoints,_hb_buffer_set_message_func,_hb_language_from_string,_hb_language_to_string,_hb_script_from_string,_hb_version,_hb_version_string,_hb_feature_from_string,_malloc,_free,_hb_draw_funcs_set_move_to_func,_hb_draw_funcs_set_line_to_func,_hb_draw_funcs_set_quadratic_to_func,_hb_draw_funcs_set_cubic_to_func,_hb_draw_funcs_set_close_path_func,_hb_draw_funcs_create,_hb_draw_funcs_destroy,_hb_face_create,_hb_face_destroy,_hb_face_reference_table,_hb_face_get_upem,_hb_face_collect_unicodes,_hb_font_funcs_create,_hb_font_funcs_destroy,_hb_font_funcs_set_font_h_extents_func,_hb_font_funcs_set_font_v_extents_func,_hb_font_funcs_set_nominal_glyph_func,_hb_font_funcs_set_nominal_glyphs_func,_hb_font_funcs_set_variation_glyph_func,_hb_font_funcs_set_glyph_h_advance_func,_hb_font_funcs_set_glyph_v_advance_func,_hb_font_funcs_set_glyph_h_advances_func,_hb_font_funcs_set_glyph_v_advances_func,_hb_font_funcs_set_glyph_h_origin_func,_hb_font_funcs_set_glyph_v_origin_func,_hb_font_funcs_set_glyph_h_kerning_func,_hb_font_funcs_set_glyph_extents_func,_hb_font_funcs_set_glyph_name_func,_hb_font_funcs_set_glyph_from_name_func,_hb_font_get_h_extents,_hb_font_get_v_extents,_hb_font_get_glyph_h_advance,_hb_font_get_glyph_v_advance,_hb_font_get_glyph_h_origin,_hb_font_get_glyph_v_origin,_hb_font_get_glyph_extents,_hb_font_get_glyph_from_name,_hb_font_draw_glyph,_hb_font_glyph_to_string,_hb_font_create,_hb_font_set_variations,_hb_font_create_sub_font,_hb_font_reference,_hb_font_destroy,_hb_font_set_funcs,_hb_font_set_scale,_hb_ot_layout_get_glyph_class,_hb_ot_layout_table_get_script_tags,_hb_ot_layout_table_get_feature_tags,_hb_ot_layout_script_get_language_tags,_hb_ot_layout_language_get_feature_tags,_hb_ot_layout_feature_get_name_ids,_hb_ot_name_list_names,_hb_ot_name_get_utf16,_hb_set_create,_hb_set_destroy,_hb_ot_tag_to_script,_hb_ot_tag_to_language,_hb_ot_var_get_axis_infos,_hb_set_get_population,_hb_set_next_many,_hb_shape,__emscripten_timeout,__emscripten_stack_restore,__emscripten_stack_alloc,_emscripten_stack_get_current;function assignWasmExports(wasmExports){Module["_hb_blob_create"]=_hb_blob_create=wasmExports["hb_blob_create"];Module["_hb_blob_destroy"]=_hb_blob_destroy=wasmExports["hb_blob_destroy"];Module["_hb_blob_get_length"]=_hb_blob_get_length=wasmExports["hb_blob_get_length"];Module["_hb_blob_get_data"]=_hb_blob_get_data=wasmExports["hb_blob_get_data"];Module["_hb_buffer_serialize"]=_hb_buffer_serialize=wasmExports["hb_buffer_serialize"];Module["_hb_buffer_create"]=_hb_buffer_create=wasmExports["hb_buffer_create"];Module["_hb_buffer_reset"]=_hb_buffer_reset=wasmExports["hb_buffer_reset"];Module["_hb_buffer_reference"]=_hb_buffer_reference=wasmExports["hb_buffer_reference"];Module["_hb_buffer_destroy"]=_hb_buffer_destroy=wasmExports["hb_buffer_destroy"];Module["_hb_buffer_get_content_type"]=_hb_buffer_get_content_type=wasmExports["hb_buffer_get_content_type"];Module["_hb_buffer_set_direction"]=_hb_buffer_set_direction=wasmExports["hb_buffer_set_direction"];Module["_hb_buffer_set_script"]=_hb_buffer_set_script=wasmExports["hb_buffer_set_script"];Module["_hb_buffer_set_language"]=_hb_buffer_set_language=wasmExports["hb_buffer_set_language"];Module["_hb_buffer_set_flags"]=_hb_buffer_set_flags=wasmExports["hb_buffer_set_flags"];Module["_hb_buffer_set_cluster_level"]=_hb_buffer_set_cluster_level=wasmExports["hb_buffer_set_cluster_level"];Module["_hb_buffer_clear_contents"]=_hb_buffer_clear_contents=wasmExports["hb_buffer_clear_contents"];Module["_hb_buffer_get_length"]=_hb_buffer_get_length=wasmExports["hb_buffer_get_length"];Module["_hb_buffer_get_glyph_infos"]=_hb_buffer_get_glyph_infos=wasmExports["hb_buffer_get_glyph_infos"];Module["_hb_buffer_get_glyph_positions"]=_hb_buffer_get_glyph_positions=wasmExports["hb_buffer_get_glyph_positions"];Module["_hb_glyph_info_get_glyph_flags"]=_hb_glyph_info_get_glyph_flags=wasmExports["hb_glyph_info_get_glyph_flags"];Module["_hb_buffer_guess_segment_properties"]=_hb_buffer_guess_segment_properties=wasmExports["hb_buffer_guess_segment_properties"];Module["_hb_buffer_add_utf8"]=_hb_buffer_add_utf8=wasmExports["hb_buffer_add_utf8"];Module["_hb_buffer_add_utf16"]=_hb_buffer_add_utf16=wasmExports["hb_buffer_add_utf16"];Module["_hb_buffer_add_codepoints"]=_hb_buffer_add_codepoints=wasmExports["hb_buffer_add_codepoints"];Module["_hb_buffer_set_message_func"]=_hb_buffer_set_message_func=wasmExports["hb_buffer_set_message_func"];Module["_hb_language_from_string"]=_hb_language_from_string=wasmExports["hb_language_from_string"];Module["_hb_language_to_string"]=_hb_language_to_string=wasmExports["hb_language_to_string"];Module["_hb_script_from_string"]=_hb_script_from_string=wasmExports["hb_script_from_string"];Module["_hb_version"]=_hb_version=wasmExports["hb_version"];Module["_hb_version_string"]=_hb_version_string=wasmExports["hb_version_string"];Module["_hb_feature_from_string"]=_hb_feature_from_string=wasmExports["hb_feature_from_string"];Module["_malloc"]=_malloc=wasmExports["malloc"];Module["_free"]=_free=wasmExports["free"];Module["_hb_draw_funcs_set_move_to_func"]=_hb_draw_funcs_set_move_to_func=wasmExports["hb_draw_funcs_set_move_to_func"];Module["_hb_draw_funcs_set_line_to_func"]=_hb_draw_funcs_set_line_to_func=wasmExports["hb_draw_funcs_set_line_to_func"];Module["_hb_draw_funcs_set_quadratic_to_func"]=_hb_draw_funcs_set_quadratic_to_func=wasmExports["hb_draw_funcs_set_quadratic_to_func"];Module["_hb_draw_funcs_set_cubic_to_func"]=_hb_draw_funcs_set_cubic_to_func=wasmExports["hb_draw_funcs_set_cubic_to_func"];Module["_hb_draw_funcs_set_close_path_func"]=_hb_draw_funcs_set_close_path_func=wasmExports["hb_draw_funcs_set_close_path_func"];Module["_hb_draw_funcs_create"]=_hb_draw_funcs_create=wasmExports["hb_draw_funcs_create"];Module["_hb_draw_funcs_destroy"]=_hb_draw_funcs_destroy=wasmExports["hb_draw_funcs_destroy"];Module["_hb_face_create"]=_hb_face_create=wasmExports["hb_face_create"];Module["_hb_face_destroy"]=_hb_face_destroy=wasmExports["hb_face_destroy"];Module["_hb_face_reference_table"]=_hb_face_reference_table=wasmExports["hb_face_reference_table"];Module["_hb_face_get_upem"]=_hb_face_get_upem=wasmExports["hb_face_get_upem"];Module["_hb_face_collect_unicodes"]=_hb_face_collect_unicodes=wasmExports["hb_face_collect_unicodes"];Module["_hb_font_funcs_create"]=_hb_font_funcs_create=wasmExports["hb_font_funcs_create"];Module["_hb_font_funcs_destroy"]=_hb_font_funcs_destroy=wasmExports["hb_font_funcs_destroy"];Module["_hb_font_funcs_set_font_h_extents_func"]=_hb_font_funcs_set_font_h_extents_func=wasmExports["hb_font_funcs_set_font_h_extents_func"];Module["_hb_font_funcs_set_font_v_extents_func"]=_hb_font_funcs_set_font_v_extents_func=wasmExports["hb_font_funcs_set_font_v_extents_func"];Module["_hb_font_funcs_set_nominal_glyph_func"]=_hb_font_funcs_set_nominal_glyph_func=wasmExports["hb_font_funcs_set_nominal_glyph_func"];Module["_hb_font_funcs_set_nominal_glyphs_func"]=_hb_font_funcs_set_nominal_glyphs_func=wasmExports["hb_font_funcs_set_nominal_glyphs_func"];Module["_hb_font_funcs_set_variation_glyph_func"]=_hb_font_funcs_set_variation_glyph_func=wasmExports["hb_font_funcs_set_variation_glyph_func"];Module["_hb_font_funcs_set_glyph_h_advance_func"]=_hb_font_funcs_set_glyph_h_advance_func=wasmExports["hb_font_funcs_set_glyph_h_advance_func"];Module["_hb_font_funcs_set_glyph_v_advance_func"]=_hb_font_funcs_set_glyph_v_advance_func=wasmExports["hb_font_funcs_set_glyph_v_advance_func"];Module["_hb_font_funcs_set_glyph_h_advances_func"]=_hb_font_funcs_set_glyph_h_advances_func=wasmExports["hb_font_funcs_set_glyph_h_advances_func"];Module["_hb_font_funcs_set_glyph_v_advances_func"]=_hb_font_funcs_set_glyph_v_advances_func=wasmExports["hb_font_funcs_set_glyph_v_advances_func"];Module["_hb_font_funcs_set_glyph_h_origin_func"]=_hb_font_funcs_set_glyph_h_origin_func=wasmExports["hb_font_funcs_set_glyph_h_origin_func"];Module["_hb_font_funcs_set_glyph_v_origin_func"]=_hb_font_funcs_set_glyph_v_origin_func=wasmExports["hb_font_funcs_set_glyph_v_origin_func"];Module["_hb_font_funcs_set_glyph_h_kerning_func"]=_hb_font_funcs_set_glyph_h_kerning_func=wasmExports["hb_font_funcs_set_glyph_h_kerning_func"];Module["_hb_font_funcs_set_glyph_extents_func"]=_hb_font_funcs_set_glyph_extents_func=wasmExports["hb_font_funcs_set_glyph_extents_func"];Module["_hb_font_funcs_set_glyph_name_func"]=_hb_font_funcs_set_glyph_name_func=wasmExports["hb_font_funcs_set_glyph_name_func"];Module["_hb_font_funcs_set_glyph_from_name_func"]=_hb_font_funcs_set_glyph_from_name_func=wasmExports["hb_font_funcs_set_glyph_from_name_func"];Module["_hb_font_get_h_extents"]=_hb_font_get_h_extents=wasmExports["hb_font_get_h_extents"];Module["_hb_font_get_v_extents"]=_hb_font_get_v_extents=wasmExports["hb_font_get_v_extents"];Module["_hb_font_get_glyph_h_advance"]=_hb_font_get_glyph_h_advance=wasmExports["hb_font_get_glyph_h_advance"];Module["_hb_font_get_glyph_v_advance"]=_hb_font_get_glyph_v_advance=wasmExports["hb_font_get_glyph_v_advance"];Module["_hb_font_get_glyph_h_origin"]=_hb_font_get_glyph_h_origin=wasmExports["hb_font_get_glyph_h_origin"];Module["_hb_font_get_glyph_v_origin"]=_hb_font_get_glyph_v_origin=wasmExports["hb_font_get_glyph_v_origin"];Module["_hb_font_get_glyph_extents"]=_hb_font_get_glyph_extents=wasmExports["hb_font_get_glyph_extents"];Module["_hb_font_get_glyph_from_name"]=_hb_font_get_glyph_from_name=wasmExports["hb_font_get_glyph_from_name"];Module["_hb_font_draw_glyph"]=_hb_font_draw_glyph=wasmExports["hb_font_draw_glyph"];Module["_hb_font_glyph_to_string"]=_hb_font_glyph_to_string=wasmExports["hb_font_glyph_to_string"];Module["_hb_font_create"]=_hb_font_create=wasmExports["hb_font_create"];Module["_hb_font_set_variations"]=_hb_font_set_variations=wasmExports["hb_font_set_variations"];Module["_hb_font_create_sub_font"]=_hb_font_create_sub_font=wasmExports["hb_font_create_sub_font"];Module["_hb_font_reference"]=_hb_font_reference=wasmExports["hb_font_reference"];Module["_hb_font_destroy"]=_hb_font_destroy=wasmExports["hb_font_destroy"];Module["_hb_font_set_funcs"]=_hb_font_set_funcs=wasmExports["hb_font_set_funcs"];Module["_hb_font_set_scale"]=_hb_font_set_scale=wasmExports["hb_font_set_scale"];Module["_hb_ot_layout_get_glyph_class"]=_hb_ot_layout_get_glyph_class=wasmExports["hb_ot_layout_get_glyph_class"];Module["_hb_ot_layout_table_get_script_tags"]=_hb_ot_layout_table_get_script_tags=wasmExports["hb_ot_layout_table_get_script_tags"];Module["_hb_ot_layout_table_get_feature_tags"]=_hb_ot_layout_table_get_feature_tags=wasmExports["hb_ot_layout_table_get_feature_tags"];Module["_hb_ot_layout_script_get_language_tags"]=_hb_ot_layout_script_get_language_tags=wasmExports["hb_ot_layout_script_get_language_tags"];Module["_hb_ot_layout_language_get_feature_tags"]=_hb_ot_layout_language_get_feature_tags=wasmExports["hb_ot_layout_language_get_feature_tags"];Module["_hb_ot_layout_feature_get_name_ids"]=_hb_ot_layout_feature_get_name_ids=wasmExports["hb_ot_layout_feature_get_name_ids"];Module["_hb_ot_name_list_names"]=_hb_ot_name_list_names=wasmExports["hb_ot_name_list_names"];Module["_hb_ot_name_get_utf16"]=_hb_ot_name_get_utf16=wasmExports["hb_ot_name_get_utf16"];Module["_hb_set_create"]=_hb_set_create=wasmExports["hb_set_create"];Module["_hb_set_destroy"]=_hb_set_destroy=wasmExports["hb_set_destroy"];Module["_hb_ot_tag_to_script"]=_hb_ot_tag_to_script=wasmExports["hb_ot_tag_to_script"];Module["_hb_ot_tag_to_language"]=_hb_ot_tag_to_language=wasmExports["hb_ot_tag_to_language"];Module["_hb_ot_var_get_axis_infos"]=_hb_ot_var_get_axis_infos=wasmExports["hb_ot_var_get_axis_infos"];Module["_hb_set_get_population"]=_hb_set_get_population=wasmExports["hb_set_get_population"];Module["_hb_set_next_many"]=_hb_set_next_many=wasmExports["hb_set_next_many"];Module["_hb_shape"]=_hb_shape=wasmExports["hb_shape"];__emscripten_timeout=wasmExports["_emscripten_timeout"];__emscripten_stack_restore=wasmExports["_emscripten_stack_restore"];__emscripten_stack_alloc=wasmExports["_emscripten_stack_alloc"];_emscripten_stack_get_current=wasmExports["emscripten_stack_get_current"]}var wasmImports={_abort_js:__abort_js,_emscripten_runtime_keepalive_clear:__emscripten_runtime_keepalive_clear,_setitimer_js:__setitimer_js,emscripten_resize_heap:_emscripten_resize_heap,proc_exit:_proc_exit};var wasmExports=await createWasm();function run(){if(runDependencies>0){dependenciesFulfilled=run;return}preRun();if(runDependencies>0){dependenciesFulfilled=run;return}function doRun(){Module["calledRun"]=true;if(ABORT)return;initRuntime();readyPromiseResolve?.(Module);Module["onRuntimeInitialized"]?.();postRun()}if(Module["setStatus"]){Module["setStatus"]("Running...");setTimeout(()=>{setTimeout(()=>Module["setStatus"](""),1);doRun()},1)}else{doRun()}}function preInit(){if(Module["preInit"]){if(typeof Module["preInit"]=="function")Module["preInit"]=[Module["preInit"]];while(Module["preInit"].length>0){Module["preInit"].shift()()}}}preInit();run();if(runtimeInitialized){moduleRtn=Module}else{moduleRtn=new Promise((resolve,reject)=>{readyPromiseResolve=resolve;readyPromiseReject=reject})}
|
|
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})}
|
|
2
2
|
;return moduleRtn}export default createHarfBuzz;
|
package/dist/harfbuzz.wasm
CHANGED
|
Binary file
|
package/dist/index.d.mts
CHANGED
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
//#region src/helpers.d.ts
|
|
2
|
+
type ValueOf<T> = T[keyof T];
|
|
3
|
+
//#endregion
|
|
1
4
|
//#region src/types.d.ts
|
|
2
5
|
interface FontExtents {
|
|
3
6
|
ascender: number;
|
|
@@ -15,6 +18,8 @@ interface GlyphInfo {
|
|
|
15
18
|
codepoint: number;
|
|
16
19
|
/** The cluster index of the glyph. */
|
|
17
20
|
cluster: number;
|
|
21
|
+
/** Glyph flags, a combination of {@link GlyphFlag} values. */
|
|
22
|
+
flags: number;
|
|
18
23
|
}
|
|
19
24
|
interface GlyphPosition {
|
|
20
25
|
/** The x advance of the glyph. */
|
|
@@ -26,22 +31,6 @@ interface GlyphPosition {
|
|
|
26
31
|
/** The y offset of the glyph. */
|
|
27
32
|
yOffset: number;
|
|
28
33
|
}
|
|
29
|
-
interface JsonGlyph {
|
|
30
|
-
/** The glyph ID. */
|
|
31
|
-
g: number;
|
|
32
|
-
/** The cluster ID. */
|
|
33
|
-
cl: number;
|
|
34
|
-
/** Advance width (width to advance after this glyph is painted). */
|
|
35
|
-
ax: number;
|
|
36
|
-
/** Advance height (height to advance after this glyph is painted). */
|
|
37
|
-
ay: number;
|
|
38
|
-
/** X displacement (adjustment in X dimension when painting this glyph). */
|
|
39
|
-
dx: number;
|
|
40
|
-
/** Y displacement (adjustment in Y dimension when painting this glyph). */
|
|
41
|
-
dy: number;
|
|
42
|
-
/** Glyph flags, a combination of {@link GlyphFlag} values. */
|
|
43
|
-
fl: number;
|
|
44
|
-
}
|
|
45
34
|
interface SvgPathCommand {
|
|
46
35
|
type: string;
|
|
47
36
|
values: number[];
|
|
@@ -56,9 +45,9 @@ interface NameEntry {
|
|
|
56
45
|
language: string;
|
|
57
46
|
}
|
|
58
47
|
interface FeatureNameIds {
|
|
59
|
-
uiLabelNameId
|
|
60
|
-
uiTooltipTextNameId
|
|
61
|
-
sampleTextNameId
|
|
48
|
+
uiLabelNameId?: number;
|
|
49
|
+
uiTooltipTextNameId?: number;
|
|
50
|
+
sampleTextNameId?: number;
|
|
62
51
|
paramUiLabelNameIds: number[];
|
|
63
52
|
}
|
|
64
53
|
interface TraceEntry {
|
|
@@ -81,7 +70,7 @@ declare const GlyphFlag: {
|
|
|
81
70
|
readonly SAFE_TO_INSERT_TATWEEL: 4;
|
|
82
71
|
readonly DEFINED: 7;
|
|
83
72
|
};
|
|
84
|
-
type GlyphFlag =
|
|
73
|
+
type GlyphFlag = ValueOf<typeof GlyphFlag>;
|
|
85
74
|
//#endregion
|
|
86
75
|
//#region src/blob.d.ts
|
|
87
76
|
/**
|
|
@@ -104,7 +93,7 @@ declare const GlyphClass: {
|
|
|
104
93
|
readonly MARK: 3;
|
|
105
94
|
readonly COMPONENT: 4;
|
|
106
95
|
};
|
|
107
|
-
type GlyphClass =
|
|
96
|
+
type GlyphClass = ValueOf<typeof GlyphClass>;
|
|
108
97
|
/**
|
|
109
98
|
* An object representing a {@link https://harfbuzz.github.io/harfbuzz-hb-face.html | HarfBuzz face}.
|
|
110
99
|
* A face represents a single face in a binary font file and is the
|
|
@@ -188,9 +177,9 @@ declare class Face {
|
|
|
188
177
|
* Get the name IDs of the specified feature.
|
|
189
178
|
* @param table The table to query, either "GSUB" or "GPOS".
|
|
190
179
|
* @param featureIndex The index of the feature to query.
|
|
191
|
-
* @returns An object with name IDs, or
|
|
180
|
+
* @returns An object with name IDs, or undefined if not found.
|
|
192
181
|
*/
|
|
193
|
-
getFeatureNameIds(table: string, featureIndex: number): FeatureNameIds |
|
|
182
|
+
getFeatureNameIds(table: string, featureIndex: number): FeatureNameIds | undefined;
|
|
194
183
|
}
|
|
195
184
|
//#endregion
|
|
196
185
|
//#region src/font-funcs.d.ts
|
|
@@ -206,15 +195,15 @@ declare class FontFuncs {
|
|
|
206
195
|
/**
|
|
207
196
|
* Set the font's glyph extents function.
|
|
208
197
|
* @param func The callback receives a Font and glyph ID. It should return
|
|
209
|
-
* an object with xBearing, yBearing, width, and height, or
|
|
198
|
+
* an object with xBearing, yBearing, width, and height, or undefined on failure.
|
|
210
199
|
*/
|
|
211
|
-
setGlyphExtentsFunc(func: (font: Font, glyph: number) => GlyphExtents |
|
|
200
|
+
setGlyphExtentsFunc(func: (font: Font, glyph: number) => GlyphExtents | undefined): void;
|
|
212
201
|
/**
|
|
213
202
|
* Set the font's glyph from name function.
|
|
214
203
|
* @param func The callback receives a Font and glyph name. It should return
|
|
215
|
-
* the glyph ID, or
|
|
204
|
+
* the glyph ID, or undefined on failure.
|
|
216
205
|
*/
|
|
217
|
-
setGlyphFromNameFunc(func: (font: Font, name: string) => number |
|
|
206
|
+
setGlyphFromNameFunc(func: (font: Font, name: string) => number | undefined): void;
|
|
218
207
|
/**
|
|
219
208
|
* Set the font's glyph horizontal advance function.
|
|
220
209
|
* @param func The callback receives a Font and glyph ID. It should return
|
|
@@ -230,15 +219,15 @@ declare class FontFuncs {
|
|
|
230
219
|
/**
|
|
231
220
|
* Set the font's glyph horizontal origin function.
|
|
232
221
|
* @param func The callback receives a Font and glyph ID. It should return
|
|
233
|
-
* the [x, y] horizontal origin of the glyph, or
|
|
222
|
+
* the [x, y] horizontal origin of the glyph, or undefined on failure.
|
|
234
223
|
*/
|
|
235
|
-
setGlyphHOriginFunc(func: (font: Font, glyph: number) => [number, number] |
|
|
224
|
+
setGlyphHOriginFunc(func: (font: Font, glyph: number) => [number, number] | undefined): void;
|
|
236
225
|
/**
|
|
237
226
|
* Set the font's glyph vertical origin function.
|
|
238
227
|
* @param func The callback receives a Font and glyph ID. It should return
|
|
239
|
-
* the [x, y] vertical origin of the glyph, or
|
|
228
|
+
* the [x, y] vertical origin of the glyph, or undefined on failure.
|
|
240
229
|
*/
|
|
241
|
-
setGlyphVOriginFunc(func: (font: Font, glyph: number) => [number, number] |
|
|
230
|
+
setGlyphVOriginFunc(func: (font: Font, glyph: number) => [number, number] | undefined): void;
|
|
242
231
|
/**
|
|
243
232
|
* Set the font's glyph horizontal kerning function.
|
|
244
233
|
* @param func The callback receives a Font, first glyph ID, and second glyph ID.
|
|
@@ -248,33 +237,74 @@ declare class FontFuncs {
|
|
|
248
237
|
/**
|
|
249
238
|
* Set the font's glyph name function.
|
|
250
239
|
* @param func The callback receives a Font and glyph ID. It should return
|
|
251
|
-
* the name of the glyph, or
|
|
240
|
+
* the name of the glyph, or undefined on failure.
|
|
252
241
|
*/
|
|
253
|
-
setGlyphNameFunc(func: (font: Font, glyph: number) => string |
|
|
242
|
+
setGlyphNameFunc(func: (font: Font, glyph: number) => string | undefined): void;
|
|
254
243
|
/**
|
|
255
244
|
* Set the font's nominal glyph function.
|
|
256
245
|
* @param func The callback receives a Font and unicode code point. It should
|
|
257
|
-
* return the nominal glyph of the unicode, or
|
|
246
|
+
* return the nominal glyph of the unicode, or undefined on failure.
|
|
258
247
|
*/
|
|
259
|
-
setNominalGlyphFunc(func: (font: Font, unicode: number) => number |
|
|
248
|
+
setNominalGlyphFunc(func: (font: Font, unicode: number) => number | undefined): void;
|
|
260
249
|
/**
|
|
261
250
|
* Set the font's variation glyph function.
|
|
262
251
|
* @param func The callback receives a Font, unicode code point, and variation
|
|
263
|
-
* selector. It should return the variation glyph, or
|
|
252
|
+
* selector. It should return the variation glyph, or undefined on failure.
|
|
264
253
|
*/
|
|
265
|
-
setVariationGlyphFunc(func: (font: Font, unicode: number, variationSelector: number) => number |
|
|
254
|
+
setVariationGlyphFunc(func: (font: Font, unicode: number, variationSelector: number) => number | undefined): void;
|
|
266
255
|
/**
|
|
267
256
|
* Set the font's horizontal extents function.
|
|
268
257
|
* @param func The callback receives a Font. It should return an object with
|
|
269
|
-
* ascender, descender, and lineGap, or
|
|
258
|
+
* ascender, descender, and lineGap, or undefined on failure.
|
|
270
259
|
*/
|
|
271
|
-
setFontHExtentsFunc(func: (font: Font) => FontExtents |
|
|
260
|
+
setFontHExtentsFunc(func: (font: Font) => FontExtents | undefined): void;
|
|
272
261
|
/**
|
|
273
262
|
* Set the font's vertical extents function.
|
|
274
263
|
* @param func The callback receives a Font. It should return an object with
|
|
275
|
-
* ascender, descender, and lineGap, or
|
|
264
|
+
* ascender, descender, and lineGap, or undefined on failure.
|
|
276
265
|
*/
|
|
277
|
-
setFontVExtentsFunc(func: (font: Font) => FontExtents |
|
|
266
|
+
setFontVExtentsFunc(func: (font: Font) => FontExtents | undefined): void;
|
|
267
|
+
}
|
|
268
|
+
//#endregion
|
|
269
|
+
//#region src/variation.d.ts
|
|
270
|
+
/**
|
|
271
|
+
* A {@link https://harfbuzz.github.io/harfbuzz-hb-common.html#hb-variation-t | HarfBuzz variation}.
|
|
272
|
+
*
|
|
273
|
+
* Data type for holding variation data. Registered OpenType variation-axis
|
|
274
|
+
* tags are listed in
|
|
275
|
+
* {@link https://docs.microsoft.com/en-us/typography/opentype/spec/dvaraxisreg | OpenType Axis Tag Registry}.
|
|
276
|
+
*/
|
|
277
|
+
declare class Variation {
|
|
278
|
+
/** The tag of the variation-axis name. */
|
|
279
|
+
tag: string;
|
|
280
|
+
/** The value of the variation axis. */
|
|
281
|
+
value: number;
|
|
282
|
+
constructor(tag: string, value?: number);
|
|
283
|
+
/**
|
|
284
|
+
* Parses a string into a Variation.
|
|
285
|
+
*
|
|
286
|
+
* The format for specifying variation settings follows. All valid CSS
|
|
287
|
+
* font-variation-settings values other than `normal` and `inherited` are
|
|
288
|
+
* also accepted, though, not documented below.
|
|
289
|
+
*
|
|
290
|
+
* The format is a tag, optionally followed by an equals sign, followed by a
|
|
291
|
+
* number. For example `wght=500`, or `slnt=-7.5`.
|
|
292
|
+
*
|
|
293
|
+
* @param str The string to parse.
|
|
294
|
+
* @returns A Variation, or undefined if the string is not a valid variation.
|
|
295
|
+
*/
|
|
296
|
+
static fromString(str: string): Variation | undefined;
|
|
297
|
+
/**
|
|
298
|
+
* Converts the variation to a string in the format understood by
|
|
299
|
+
* {@link Variation.fromString}.
|
|
300
|
+
*
|
|
301
|
+
* Note that the string won't include any whitespace.
|
|
302
|
+
*
|
|
303
|
+
* @returns The variation string.
|
|
304
|
+
*/
|
|
305
|
+
toString(): string;
|
|
306
|
+
/** @internal Write this variation into the given hb_variation_t pointer. */
|
|
307
|
+
writeTo(ptr: number): void;
|
|
278
308
|
}
|
|
279
309
|
//#endregion
|
|
280
310
|
//#region src/font.d.ts
|
|
@@ -335,27 +365,27 @@ declare class Font {
|
|
|
335
365
|
/**
|
|
336
366
|
* Return glyph horizontal origin.
|
|
337
367
|
* @param glyphId ID of the requested glyph in the font.
|
|
338
|
-
* @returns [x, y] origin coordinates, or
|
|
368
|
+
* @returns [x, y] origin coordinates, or undefined if not available.
|
|
339
369
|
*/
|
|
340
|
-
glyphHOrigin(glyphId: number): [number, number] |
|
|
370
|
+
glyphHOrigin(glyphId: number): [number, number] | undefined;
|
|
341
371
|
/**
|
|
342
372
|
* Return glyph vertical origin.
|
|
343
373
|
* @param glyphId ID of the requested glyph in the font.
|
|
344
|
-
* @returns [x, y] origin coordinates, or
|
|
374
|
+
* @returns [x, y] origin coordinates, or undefined if not available.
|
|
345
375
|
*/
|
|
346
|
-
glyphVOrigin(glyphId: number): [number, number] |
|
|
376
|
+
glyphVOrigin(glyphId: number): [number, number] | undefined;
|
|
347
377
|
/**
|
|
348
378
|
* Return glyph extents.
|
|
349
379
|
* @param glyphId ID of the requested glyph in the font.
|
|
350
|
-
* @returns An object with xBearing, yBearing, width, and height, or
|
|
380
|
+
* @returns An object with xBearing, yBearing, width, and height, or undefined.
|
|
351
381
|
*/
|
|
352
|
-
glyphExtents(glyphId: number): GlyphExtents |
|
|
382
|
+
glyphExtents(glyphId: number): GlyphExtents | undefined;
|
|
353
383
|
/**
|
|
354
384
|
* Return glyph ID from name.
|
|
355
385
|
* @param name Name of the requested glyph in the font.
|
|
356
|
-
* @returns The glyph ID, or
|
|
386
|
+
* @returns The glyph ID, or undefined if not found.
|
|
357
387
|
*/
|
|
358
|
-
glyphFromName(name: string): number |
|
|
388
|
+
glyphFromName(name: string): number | undefined;
|
|
359
389
|
/**
|
|
360
390
|
* Return a glyph as a JSON path string
|
|
361
391
|
* based on format described on https://svgwg.org/specs/paths/#InterfaceSVGPathSegment
|
|
@@ -371,10 +401,15 @@ declare class Font {
|
|
|
371
401
|
*/
|
|
372
402
|
setScale(xScale: number, yScale: number): void;
|
|
373
403
|
/**
|
|
374
|
-
*
|
|
375
|
-
*
|
|
404
|
+
* Applies a list of font-variation settings to a font.
|
|
405
|
+
*
|
|
406
|
+
* Note that this overrides all existing variations set on the font.
|
|
407
|
+
* Axes not included in `variations` will be effectively set to their
|
|
408
|
+
* default values.
|
|
409
|
+
*
|
|
410
|
+
* @param variations Array of variation settings to apply.
|
|
376
411
|
*/
|
|
377
|
-
setVariations(variations:
|
|
412
|
+
setVariations(variations: Variation[]): void;
|
|
378
413
|
/** Set the font's font functions. */
|
|
379
414
|
setFuncs(fontFuncs: FontFuncs): void;
|
|
380
415
|
}
|
|
@@ -385,7 +420,7 @@ declare const BufferContentType: {
|
|
|
385
420
|
readonly UNICODE: 1;
|
|
386
421
|
readonly GLYPHS: 2;
|
|
387
422
|
};
|
|
388
|
-
type BufferContentType =
|
|
423
|
+
type BufferContentType = ValueOf<typeof BufferContentType>;
|
|
389
424
|
declare const BufferSerializeFlag: {
|
|
390
425
|
readonly DEFAULT: 0;
|
|
391
426
|
readonly NO_CLUSTERS: 1;
|
|
@@ -396,7 +431,7 @@ declare const BufferSerializeFlag: {
|
|
|
396
431
|
readonly NO_ADVANCES: 32;
|
|
397
432
|
readonly DEFINED: 63;
|
|
398
433
|
};
|
|
399
|
-
type BufferSerializeFlag =
|
|
434
|
+
type BufferSerializeFlag = ValueOf<typeof BufferSerializeFlag>;
|
|
400
435
|
declare const BufferFlag: {
|
|
401
436
|
readonly DEFAULT: 0;
|
|
402
437
|
readonly BOT: 1;
|
|
@@ -409,7 +444,7 @@ declare const BufferFlag: {
|
|
|
409
444
|
readonly PRODUCE_SAFE_TO_INSERT_TATWEEL: 128;
|
|
410
445
|
readonly DEFINED: 255;
|
|
411
446
|
};
|
|
412
|
-
type BufferFlag =
|
|
447
|
+
type BufferFlag = ValueOf<typeof BufferFlag>;
|
|
413
448
|
declare const Direction: {
|
|
414
449
|
readonly INVALID: 0;
|
|
415
450
|
readonly LTR: 4;
|
|
@@ -417,13 +452,21 @@ declare const Direction: {
|
|
|
417
452
|
readonly TTB: 6;
|
|
418
453
|
readonly BTT: 7;
|
|
419
454
|
};
|
|
420
|
-
type Direction =
|
|
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>;
|
|
421
464
|
declare const BufferSerializeFormat: {
|
|
422
465
|
readonly INVALID: 0;
|
|
423
466
|
readonly TEXT: number;
|
|
424
467
|
readonly JSON: number;
|
|
425
468
|
};
|
|
426
|
-
type BufferSerializeFormat =
|
|
469
|
+
type BufferSerializeFormat = ValueOf<typeof BufferSerializeFormat>;
|
|
427
470
|
/**
|
|
428
471
|
* An object representing a {@link https://harfbuzz.github.io/harfbuzz-hb-buffer.html | HarfBuzz buffer}.
|
|
429
472
|
* A buffer holds the input text and its properties before shaping, and the
|
|
@@ -431,23 +474,37 @@ type BufferSerializeFormat = (typeof BufferSerializeFormat)[keyof typeof BufferS
|
|
|
431
474
|
*/
|
|
432
475
|
declare class Buffer {
|
|
433
476
|
readonly ptr: number;
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
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;
|
|
437
494
|
/**
|
|
438
495
|
* Add text to the buffer.
|
|
439
496
|
* @param text Text to be added to the buffer.
|
|
440
497
|
* @param itemOffset The offset of the first character to add to the buffer.
|
|
441
|
-
* @param itemLength The number of characters to add to the buffer, or
|
|
498
|
+
* @param itemLength The number of characters to add to the buffer, or omit for the end of text.
|
|
442
499
|
*/
|
|
443
|
-
addText(text: string, itemOffset?: number, itemLength?: number
|
|
500
|
+
addText(text: string, itemOffset?: number, itemLength?: number): void;
|
|
444
501
|
/**
|
|
445
502
|
* Add code points to the buffer.
|
|
446
503
|
* @param codePoints Array of code points to be added to the buffer.
|
|
447
504
|
* @param itemOffset The offset of the first code point to add to the buffer.
|
|
448
|
-
* @param itemLength The number of code points to add to the buffer, or
|
|
505
|
+
* @param itemLength The number of code points to add to the buffer, or omit for the end of the array.
|
|
449
506
|
*/
|
|
450
|
-
addCodePoints(codePoints: number[], itemOffset?: number, itemLength?: number
|
|
507
|
+
addCodePoints(codePoints: number[], itemOffset?: number, itemLength?: number): void;
|
|
451
508
|
/**
|
|
452
509
|
* Set buffer script, language and direction.
|
|
453
510
|
*
|
|
@@ -478,9 +535,9 @@ declare class Buffer {
|
|
|
478
535
|
* Set the HarfBuzz clustering level.
|
|
479
536
|
*
|
|
480
537
|
* Affects the cluster values returned from shaping.
|
|
481
|
-
* @param level
|
|
538
|
+
* @param level A {@link ClusterLevel} value. See the HarfBuzz manual chapter on Clusters.
|
|
482
539
|
*/
|
|
483
|
-
setClusterLevel(level:
|
|
540
|
+
setClusterLevel(level: ClusterLevel): void;
|
|
484
541
|
/** Reset the buffer to its initial status. */
|
|
485
542
|
reset(): void;
|
|
486
543
|
/**
|
|
@@ -525,26 +582,108 @@ declare class Buffer {
|
|
|
525
582
|
updateGlyphPositions(positions: GlyphPosition[]): void;
|
|
526
583
|
/**
|
|
527
584
|
* Serialize the buffer contents to a string.
|
|
528
|
-
* @param
|
|
529
|
-
*
|
|
530
|
-
*
|
|
531
|
-
*
|
|
532
|
-
*
|
|
533
|
-
*
|
|
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`).
|
|
534
591
|
* @returns The serialized buffer contents.
|
|
535
592
|
*/
|
|
536
|
-
serialize(
|
|
593
|
+
serialize(options?: {
|
|
594
|
+
font?: Font;
|
|
595
|
+
start?: number;
|
|
596
|
+
end?: number;
|
|
597
|
+
format?: BufferSerializeFormat;
|
|
598
|
+
flags?: number;
|
|
599
|
+
}): string;
|
|
537
600
|
/**
|
|
538
601
|
* Return the buffer content type.
|
|
539
602
|
*
|
|
540
603
|
* @returns The buffer content type as a {@link BufferContentType} value.
|
|
541
604
|
*/
|
|
542
605
|
getContentType(): BufferContentType;
|
|
606
|
+
}
|
|
607
|
+
//#endregion
|
|
608
|
+
//#region src/feature.d.ts
|
|
609
|
+
/**
|
|
610
|
+
* A {@link https://harfbuzz.github.io/harfbuzz-hb-common.html#hb-feature-t | HarfBuzz feature}.
|
|
611
|
+
*
|
|
612
|
+
* The structure that holds information about requested feature application.
|
|
613
|
+
* The feature will be applied with the given value to all glyphs which are in
|
|
614
|
+
* clusters between {@link Feature.start} (inclusive) and {@link Feature.end}
|
|
615
|
+
* (exclusive). Setting `start` to `0` and `end` to `0xffffffff` specifies that
|
|
616
|
+
* the feature always applies to the entire buffer.
|
|
617
|
+
*/
|
|
618
|
+
declare class Feature {
|
|
619
|
+
/**
|
|
620
|
+
* Special setting for {@link Feature.start} to apply the feature from the
|
|
621
|
+
* start of the buffer.
|
|
622
|
+
*/
|
|
623
|
+
static readonly GLOBAL_START = 0;
|
|
624
|
+
/**
|
|
625
|
+
* Special setting for {@link Feature.end} to apply the feature from to the
|
|
626
|
+
* end of the buffer.
|
|
627
|
+
*/
|
|
628
|
+
static readonly GLOBAL_END = 4294967295;
|
|
629
|
+
/** The tag of the feature. */
|
|
630
|
+
tag: string;
|
|
631
|
+
/**
|
|
632
|
+
* The value of the feature. `0` disables the feature, non-zero (usually `1`)
|
|
633
|
+
* enables the feature. For features implemented as lookup type 3 (like
|
|
634
|
+
* `salt`) the value is a one-based index into the alternates.
|
|
635
|
+
*/
|
|
636
|
+
value: number;
|
|
637
|
+
/** The cluster to start applying this feature setting (inclusive). */
|
|
638
|
+
start: number;
|
|
639
|
+
/** The cluster to end applying this feature setting (exclusive). */
|
|
640
|
+
end: number;
|
|
641
|
+
constructor(tag: string, value?: number, start?: number, end?: number);
|
|
642
|
+
/**
|
|
643
|
+
* Parses a string into a Feature.
|
|
644
|
+
*
|
|
645
|
+
* The format for specifying feature strings follows. All valid CSS
|
|
646
|
+
* font-feature-settings values other than `normal` and the global values are
|
|
647
|
+
* also accepted, though not documented below. CSS string escapes are not
|
|
648
|
+
* supported.
|
|
649
|
+
*
|
|
650
|
+
* The range indices refer to the positions between Unicode characters. The
|
|
651
|
+
* position before the first character is always 0.
|
|
652
|
+
*
|
|
653
|
+
* The format is Python-esque. Here is how it all works:
|
|
654
|
+
*
|
|
655
|
+
* | Syntax | Value | Start | End | Meaning |
|
|
656
|
+
* | ------------- | ----- | ----- | --- | -------------------------------- |
|
|
657
|
+
* | `kern` | 1 | 0 | ∞ | Turn feature on |
|
|
658
|
+
* | `+kern` | 1 | 0 | ∞ | Turn feature on |
|
|
659
|
+
* | `-kern` | 0 | 0 | ∞ | Turn feature off |
|
|
660
|
+
* | `kern=0` | 0 | 0 | ∞ | Turn feature off |
|
|
661
|
+
* | `kern=1` | 1 | 0 | ∞ | Turn feature on |
|
|
662
|
+
* | `aalt=2` | 2 | 0 | ∞ | Choose 2nd alternate |
|
|
663
|
+
* | `kern[]` | 1 | 0 | ∞ | Turn feature on |
|
|
664
|
+
* | `kern[:]` | 1 | 0 | ∞ | Turn feature on |
|
|
665
|
+
* | `kern[5:]` | 1 | 5 | ∞ | Turn feature on, partial |
|
|
666
|
+
* | `kern[:5]` | 1 | 0 | 5 | Turn feature on, partial |
|
|
667
|
+
* | `kern[3:5]` | 1 | 3 | 5 | Turn feature on, range |
|
|
668
|
+
* | `kern[3]` | 1 | 3 | 3+1 | Turn feature on, single char |
|
|
669
|
+
* | `aalt[3:5]=2` | 2 | 3 | 5 | Turn 2nd alternate on for range |
|
|
670
|
+
*
|
|
671
|
+
* @param str The string to parse.
|
|
672
|
+
* @returns A Feature, or undefined if the string is not a valid feature.
|
|
673
|
+
*/
|
|
674
|
+
static fromString(str: string): Feature | undefined;
|
|
543
675
|
/**
|
|
544
|
-
*
|
|
545
|
-
*
|
|
676
|
+
* Converts the feature to a string in the format understood by
|
|
677
|
+
* {@link Feature.fromString}.
|
|
678
|
+
*
|
|
679
|
+
* Note that the feature value will be omitted if it is `1`, but the string
|
|
680
|
+
* won't include any whitespace.
|
|
681
|
+
*
|
|
682
|
+
* @returns The feature string.
|
|
546
683
|
*/
|
|
547
|
-
|
|
684
|
+
toString(): string;
|
|
685
|
+
/** @internal Write this feature into the given hb_feature_t pointer. */
|
|
686
|
+
writeTo(ptr: number): void;
|
|
548
687
|
}
|
|
549
688
|
//#endregion
|
|
550
689
|
//#region src/shape.d.ts
|
|
@@ -553,7 +692,7 @@ declare const TracePhase: {
|
|
|
553
692
|
readonly GSUB: 1;
|
|
554
693
|
readonly GPOS: 2;
|
|
555
694
|
};
|
|
556
|
-
type TracePhase =
|
|
695
|
+
type TracePhase = ValueOf<typeof TracePhase>;
|
|
557
696
|
/**
|
|
558
697
|
* Shape a buffer with a given font.
|
|
559
698
|
*
|
|
@@ -563,9 +702,9 @@ type TracePhase = (typeof TracePhase)[keyof typeof TracePhase];
|
|
|
563
702
|
* @param font The Font to shape with.
|
|
564
703
|
* @param buffer The Buffer containing text to shape, suitably prepared
|
|
565
704
|
* (text added, segment properties set).
|
|
566
|
-
* @param features
|
|
705
|
+
* @param features An array of {@link Feature} values to apply.
|
|
567
706
|
*/
|
|
568
|
-
declare function shape(font: Font, buffer: Buffer, features?:
|
|
707
|
+
declare function shape(font: Font, buffer: Buffer, features?: Feature[]): void;
|
|
569
708
|
/**
|
|
570
709
|
* Shape a buffer with a given font, returning a JSON trace of the shaping process.
|
|
571
710
|
*
|
|
@@ -574,12 +713,12 @@ declare function shape(font: Font, buffer: Buffer, features?: string): void;
|
|
|
574
713
|
*
|
|
575
714
|
* @param font The Font to shape with.
|
|
576
715
|
* @param buffer The Buffer containing text to shape, suitably prepared.
|
|
577
|
-
* @param features
|
|
716
|
+
* @param features An array of {@link Feature} values to apply.
|
|
578
717
|
* @param stop_at A lookup ID at which to terminate shaping.
|
|
579
718
|
* @param stop_phase The {@link TracePhase} at which to stop shaping.
|
|
580
719
|
* @returns An array of trace entries, each with a message, serialized glyphs, and phase info.
|
|
581
720
|
*/
|
|
582
|
-
declare function shapeWithTrace(font: Font, buffer: Buffer, features:
|
|
721
|
+
declare function shapeWithTrace(font: Font, buffer: Buffer, features: Feature[], stop_at: number, stop_phase: TracePhase): TraceEntry[];
|
|
583
722
|
/**
|
|
584
723
|
* Return the HarfBuzz version.
|
|
585
724
|
* @returns An object with major, minor, and micro version numbers.
|
|
@@ -607,4 +746,4 @@ declare function otTagToScript(tag: string): string;
|
|
|
607
746
|
*/
|
|
608
747
|
declare function otTagToLanguage(tag: string): string;
|
|
609
748
|
//#endregion
|
|
610
|
-
export { AxisInfo, Blob, Buffer, BufferContentType, BufferFlag, BufferSerializeFlag, BufferSerializeFormat, Direction, Face, FeatureNameIds, Font, FontExtents, FontFuncs, GlyphClass, GlyphExtents, GlyphFlag, GlyphInfo, GlyphPosition, HarfBuzzModule,
|
|
749
|
+
export { AxisInfo, Blob, Buffer, BufferContentType, BufferFlag, BufferSerializeFlag, BufferSerializeFormat, ClusterLevel, Direction, Face, Feature, FeatureNameIds, Font, FontExtents, FontFuncs, GlyphClass, GlyphExtents, GlyphFlag, GlyphInfo, GlyphPosition, HarfBuzzModule, NameEntry, SvgPathCommand, TraceEntry, TracePhase, Variation, otTagToLanguage, otTagToScript, shape, shapeWithTrace, version, versionString };
|
package/dist/index.mjs
CHANGED
|
@@ -37,7 +37,7 @@ function hb_untag(tag) {
|
|
|
37
37
|
}
|
|
38
38
|
function utf8_ptr_to_string(ptr, length) {
|
|
39
39
|
let end;
|
|
40
|
-
if (length
|
|
40
|
+
if (length == void 0) end = Module.HEAPU8.indexOf(0, ptr);
|
|
41
41
|
else end = ptr + length;
|
|
42
42
|
return utf8Decoder.decode(Module.HEAPU8.subarray(ptr, end));
|
|
43
43
|
}
|
|
@@ -355,7 +355,7 @@ var Face = class {
|
|
|
355
355
|
* Get the name IDs of the specified feature.
|
|
356
356
|
* @param table The table to query, either "GSUB" or "GPOS".
|
|
357
357
|
* @param featureIndex The index of the feature to query.
|
|
358
|
-
* @returns An object with name IDs, or
|
|
358
|
+
* @returns An object with name IDs, or undefined if not found.
|
|
359
359
|
*/
|
|
360
360
|
getFeatureNameIds(table, featureIndex) {
|
|
361
361
|
const sp = Module.stackSave();
|
|
@@ -366,20 +366,17 @@ var Face = class {
|
|
|
366
366
|
const numNamedParametersPtr = Module.stackAlloc(4);
|
|
367
367
|
const firstParameterIdPtr = Module.stackAlloc(4);
|
|
368
368
|
const found = exports.hb_ot_layout_feature_get_name_ids(this.ptr, tableTag, featureIndex, labelIdPtr, tooltipIdPtr, sampleIdPtr, numNamedParametersPtr, firstParameterIdPtr);
|
|
369
|
-
let names
|
|
369
|
+
let names;
|
|
370
370
|
if (found) {
|
|
371
371
|
const uiLabelNameId = Module.HEAPU32[labelIdPtr / 4];
|
|
372
372
|
const uiTooltipTextNameId = Module.HEAPU32[tooltipIdPtr / 4];
|
|
373
373
|
const sampleTextNameId = Module.HEAPU32[sampleIdPtr / 4];
|
|
374
374
|
const numNamedParameters = Module.HEAPU32[numNamedParametersPtr / 4];
|
|
375
375
|
const firstParameterId = Module.HEAPU32[firstParameterIdPtr / 4];
|
|
376
|
-
|
|
377
|
-
names =
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
sampleTextNameId: sampleTextNameId == HB_OT_NAME_ID_INVALID ? null : sampleTextNameId,
|
|
381
|
-
paramUiLabelNameIds
|
|
382
|
-
};
|
|
376
|
+
names = { paramUiLabelNameIds: Array.from({ length: numNamedParameters }, (_, i) => firstParameterId + i) };
|
|
377
|
+
if (uiLabelNameId != HB_OT_NAME_ID_INVALID) names.uiLabelNameId = uiLabelNameId;
|
|
378
|
+
if (uiTooltipTextNameId != HB_OT_NAME_ID_INVALID) names.uiTooltipTextNameId = uiTooltipTextNameId;
|
|
379
|
+
if (sampleTextNameId != HB_OT_NAME_ID_INVALID) names.sampleTextNameId = sampleTextNameId;
|
|
383
380
|
}
|
|
384
381
|
Module.stackRestore(sp);
|
|
385
382
|
return names;
|
|
@@ -395,15 +392,7 @@ var Face = class {
|
|
|
395
392
|
*/
|
|
396
393
|
var Font = class Font {
|
|
397
394
|
constructor(arg) {
|
|
398
|
-
this.drawPtrs = {
|
|
399
|
-
drawFuncsPtr: null,
|
|
400
|
-
moveToPtr: null,
|
|
401
|
-
lineToPtr: null,
|
|
402
|
-
cubicToPtr: null,
|
|
403
|
-
quadToPtr: null,
|
|
404
|
-
closePathPtr: null,
|
|
405
|
-
pathBuffer: ""
|
|
406
|
-
};
|
|
395
|
+
this.drawPtrs = { pathBuffer: "" };
|
|
407
396
|
if (typeof arg === "number") this.ptr = exports.hb_font_reference(arg);
|
|
408
397
|
else this.ptr = exports.hb_font_create(arg.ptr);
|
|
409
398
|
const ptr = this.ptr;
|
|
@@ -531,13 +520,13 @@ var Font = class Font {
|
|
|
531
520
|
/**
|
|
532
521
|
* Return glyph horizontal origin.
|
|
533
522
|
* @param glyphId ID of the requested glyph in the font.
|
|
534
|
-
* @returns [x, y] origin coordinates, or
|
|
523
|
+
* @returns [x, y] origin coordinates, or undefined if not available.
|
|
535
524
|
*/
|
|
536
525
|
glyphHOrigin(glyphId) {
|
|
537
526
|
const sp = Module.stackSave();
|
|
538
527
|
const xPtr = Module.stackAlloc(4);
|
|
539
528
|
const yPtr = Module.stackAlloc(4);
|
|
540
|
-
let origin
|
|
529
|
+
let origin;
|
|
541
530
|
if (exports.hb_font_get_glyph_h_origin(this.ptr, glyphId, xPtr, yPtr)) origin = [Module.HEAP32[xPtr / 4], Module.HEAP32[yPtr / 4]];
|
|
542
531
|
Module.stackRestore(sp);
|
|
543
532
|
return origin;
|
|
@@ -545,13 +534,13 @@ var Font = class Font {
|
|
|
545
534
|
/**
|
|
546
535
|
* Return glyph vertical origin.
|
|
547
536
|
* @param glyphId ID of the requested glyph in the font.
|
|
548
|
-
* @returns [x, y] origin coordinates, or
|
|
537
|
+
* @returns [x, y] origin coordinates, or undefined if not available.
|
|
549
538
|
*/
|
|
550
539
|
glyphVOrigin(glyphId) {
|
|
551
540
|
const sp = Module.stackSave();
|
|
552
541
|
const xPtr = Module.stackAlloc(4);
|
|
553
542
|
const yPtr = Module.stackAlloc(4);
|
|
554
|
-
let origin
|
|
543
|
+
let origin;
|
|
555
544
|
if (exports.hb_font_get_glyph_v_origin(this.ptr, glyphId, xPtr, yPtr)) origin = [Module.HEAP32[xPtr / 4], Module.HEAP32[yPtr / 4]];
|
|
556
545
|
Module.stackRestore(sp);
|
|
557
546
|
return origin;
|
|
@@ -559,12 +548,12 @@ var Font = class Font {
|
|
|
559
548
|
/**
|
|
560
549
|
* Return glyph extents.
|
|
561
550
|
* @param glyphId ID of the requested glyph in the font.
|
|
562
|
-
* @returns An object with xBearing, yBearing, width, and height, or
|
|
551
|
+
* @returns An object with xBearing, yBearing, width, and height, or undefined.
|
|
563
552
|
*/
|
|
564
553
|
glyphExtents(glyphId) {
|
|
565
554
|
const sp = Module.stackSave();
|
|
566
555
|
const extentsPtr = Module.stackAlloc(16);
|
|
567
|
-
let extents
|
|
556
|
+
let extents;
|
|
568
557
|
if (exports.hb_font_get_glyph_extents(this.ptr, glyphId, extentsPtr)) extents = {
|
|
569
558
|
xBearing: Module.HEAP32[extentsPtr / 4],
|
|
570
559
|
yBearing: Module.HEAP32[extentsPtr / 4 + 1],
|
|
@@ -577,13 +566,13 @@ var Font = class Font {
|
|
|
577
566
|
/**
|
|
578
567
|
* Return glyph ID from name.
|
|
579
568
|
* @param name Name of the requested glyph in the font.
|
|
580
|
-
* @returns The glyph ID, or
|
|
569
|
+
* @returns The glyph ID, or undefined if not found.
|
|
581
570
|
*/
|
|
582
571
|
glyphFromName(name) {
|
|
583
572
|
const sp = Module.stackSave();
|
|
584
573
|
const glyphIdPtr = Module.stackAlloc(4);
|
|
585
574
|
const namePtr = string_to_utf8_ptr(name);
|
|
586
|
-
let glyphId
|
|
575
|
+
let glyphId;
|
|
587
576
|
if (exports.hb_font_get_glyph_from_name(this.ptr, namePtr.ptr, namePtr.length, glyphIdPtr)) glyphId = Module.HEAPU32[glyphIdPtr / 4];
|
|
588
577
|
namePtr.free();
|
|
589
578
|
Module.stackRestore(sp);
|
|
@@ -614,18 +603,22 @@ var Font = class Font {
|
|
|
614
603
|
exports.hb_font_set_scale(this.ptr, xScale, yScale);
|
|
615
604
|
}
|
|
616
605
|
/**
|
|
617
|
-
*
|
|
618
|
-
*
|
|
606
|
+
* Applies a list of font-variation settings to a font.
|
|
607
|
+
*
|
|
608
|
+
* Note that this overrides all existing variations set on the font.
|
|
609
|
+
* Axes not included in `variations` will be effectively set to their
|
|
610
|
+
* default values.
|
|
611
|
+
*
|
|
612
|
+
* @param variations Array of variation settings to apply.
|
|
619
613
|
*/
|
|
620
614
|
setVariations(variations) {
|
|
621
|
-
const
|
|
622
|
-
const vars =
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
Module.HEAPF32[vars / 4 + i * 2 + 1] = value;
|
|
615
|
+
const sp = Module.stackSave();
|
|
616
|
+
const vars = Module.stackAlloc(8 * variations.length);
|
|
617
|
+
variations.forEach((variation, i) => {
|
|
618
|
+
variation.writeTo(vars + i * 8);
|
|
626
619
|
});
|
|
627
|
-
exports.hb_font_set_variations(this.ptr, vars,
|
|
628
|
-
|
|
620
|
+
exports.hb_font_set_variations(this.ptr, vars, variations.length);
|
|
621
|
+
Module.stackRestore(sp);
|
|
629
622
|
}
|
|
630
623
|
/** Set the font's font functions. */
|
|
631
624
|
setFuncs(fontFuncs) {
|
|
@@ -648,7 +641,7 @@ var FontFuncs = class {
|
|
|
648
641
|
/**
|
|
649
642
|
* Set the font's glyph extents function.
|
|
650
643
|
* @param func The callback receives a Font and glyph ID. It should return
|
|
651
|
-
* an object with xBearing, yBearing, width, and height, or
|
|
644
|
+
* an object with xBearing, yBearing, width, and height, or undefined on failure.
|
|
652
645
|
*/
|
|
653
646
|
setGlyphExtentsFunc(func) {
|
|
654
647
|
const funcPtr = Module.addFunction((fontPtr, font_data, glyph, extentsPtr, user_data) => {
|
|
@@ -667,7 +660,7 @@ var FontFuncs = class {
|
|
|
667
660
|
/**
|
|
668
661
|
* Set the font's glyph from name function.
|
|
669
662
|
* @param func The callback receives a Font and glyph name. It should return
|
|
670
|
-
* the glyph ID, or
|
|
663
|
+
* the glyph ID, or undefined on failure.
|
|
671
664
|
*/
|
|
672
665
|
setGlyphFromNameFunc(func) {
|
|
673
666
|
const funcPtr = Module.addFunction((fontPtr, font_data, namePtr, len, glyphPtr, user_data) => {
|
|
@@ -705,7 +698,7 @@ var FontFuncs = class {
|
|
|
705
698
|
/**
|
|
706
699
|
* Set the font's glyph horizontal origin function.
|
|
707
700
|
* @param func The callback receives a Font and glyph ID. It should return
|
|
708
|
-
* the [x, y] horizontal origin of the glyph, or
|
|
701
|
+
* the [x, y] horizontal origin of the glyph, or undefined on failure.
|
|
709
702
|
*/
|
|
710
703
|
setGlyphHOriginFunc(func) {
|
|
711
704
|
const funcPtr = Module.addFunction((fontPtr, font_data, glyph, xPtr, yPtr, user_data) => {
|
|
@@ -722,7 +715,7 @@ var FontFuncs = class {
|
|
|
722
715
|
/**
|
|
723
716
|
* Set the font's glyph vertical origin function.
|
|
724
717
|
* @param func The callback receives a Font and glyph ID. It should return
|
|
725
|
-
* the [x, y] vertical origin of the glyph, or
|
|
718
|
+
* the [x, y] vertical origin of the glyph, or undefined on failure.
|
|
726
719
|
*/
|
|
727
720
|
setGlyphVOriginFunc(func) {
|
|
728
721
|
const funcPtr = Module.addFunction((fontPtr, font_data, glyph, xPtr, yPtr, user_data) => {
|
|
@@ -750,7 +743,7 @@ var FontFuncs = class {
|
|
|
750
743
|
/**
|
|
751
744
|
* Set the font's glyph name function.
|
|
752
745
|
* @param func The callback receives a Font and glyph ID. It should return
|
|
753
|
-
* the name of the glyph, or
|
|
746
|
+
* the name of the glyph, or undefined on failure.
|
|
754
747
|
*/
|
|
755
748
|
setGlyphNameFunc(func) {
|
|
756
749
|
const utf8Encoder = new TextEncoder();
|
|
@@ -767,7 +760,7 @@ var FontFuncs = class {
|
|
|
767
760
|
/**
|
|
768
761
|
* Set the font's nominal glyph function.
|
|
769
762
|
* @param func The callback receives a Font and unicode code point. It should
|
|
770
|
-
* return the nominal glyph of the unicode, or
|
|
763
|
+
* return the nominal glyph of the unicode, or undefined on failure.
|
|
771
764
|
*/
|
|
772
765
|
setNominalGlyphFunc(func) {
|
|
773
766
|
const funcPtr = Module.addFunction((fontPtr, font_data, unicode, glyphPtr, user_data) => {
|
|
@@ -783,7 +776,7 @@ var FontFuncs = class {
|
|
|
783
776
|
/**
|
|
784
777
|
* Set the font's variation glyph function.
|
|
785
778
|
* @param func The callback receives a Font, unicode code point, and variation
|
|
786
|
-
* selector. It should return the variation glyph, or
|
|
779
|
+
* selector. It should return the variation glyph, or undefined on failure.
|
|
787
780
|
*/
|
|
788
781
|
setVariationGlyphFunc(func) {
|
|
789
782
|
const funcPtr = Module.addFunction((fontPtr, font_data, unicode, variationSelector, glyphPtr, user_data) => {
|
|
@@ -799,7 +792,7 @@ var FontFuncs = class {
|
|
|
799
792
|
/**
|
|
800
793
|
* Set the font's horizontal extents function.
|
|
801
794
|
* @param func The callback receives a Font. It should return an object with
|
|
802
|
-
* ascender, descender, and lineGap, or
|
|
795
|
+
* ascender, descender, and lineGap, or undefined on failure.
|
|
803
796
|
*/
|
|
804
797
|
setFontHExtentsFunc(func) {
|
|
805
798
|
const funcPtr = Module.addFunction((fontPtr, font_data, extentsPtr, user_data) => {
|
|
@@ -817,7 +810,7 @@ var FontFuncs = class {
|
|
|
817
810
|
/**
|
|
818
811
|
* Set the font's vertical extents function.
|
|
819
812
|
* @param func The callback receives a Font. It should return an object with
|
|
820
|
-
* ascender, descender, and lineGap, or
|
|
813
|
+
* ascender, descender, and lineGap, or undefined on failure.
|
|
821
814
|
*/
|
|
822
815
|
setFontVExtentsFunc(func) {
|
|
823
816
|
const funcPtr = Module.addFunction((fontPtr, font_data, extentsPtr, user_data) => {
|
|
@@ -869,6 +862,13 @@ const Direction = {
|
|
|
869
862
|
TTB: 6,
|
|
870
863
|
BTT: 7
|
|
871
864
|
};
|
|
865
|
+
const ClusterLevel = {
|
|
866
|
+
MONOTONE_GRAPHEMES: 0,
|
|
867
|
+
MONOTONE_CHARACTERS: 1,
|
|
868
|
+
CHARACTERS: 2,
|
|
869
|
+
GRAPHEMES: 3,
|
|
870
|
+
DEFAULT: 0
|
|
871
|
+
};
|
|
872
872
|
const BufferSerializeFormat = {
|
|
873
873
|
INVALID: 0,
|
|
874
874
|
TEXT: hb_tag("TEXT"),
|
|
@@ -880,34 +880,50 @@ const BufferSerializeFormat = {
|
|
|
880
880
|
* output glyphs and their information after shaping.
|
|
881
881
|
*/
|
|
882
882
|
var Buffer = class Buffer {
|
|
883
|
+
/**
|
|
884
|
+
* @param existingPtr @internal Wrap an existing buffer pointer.
|
|
885
|
+
*/
|
|
883
886
|
constructor(existingPtr) {
|
|
884
|
-
if (existingPtr
|
|
887
|
+
if (existingPtr != void 0) this.ptr = exports.hb_buffer_reference(existingPtr);
|
|
885
888
|
else this.ptr = exports.hb_buffer_create();
|
|
886
889
|
track(this, exports.hb_buffer_destroy);
|
|
887
890
|
}
|
|
888
891
|
/**
|
|
892
|
+
* Appends a character with the Unicode value of `codePoint` to the buffer,
|
|
893
|
+
* and gives it the initial cluster value of `cluster`. Clusters can be any
|
|
894
|
+
* thing the client wants, they are usually used to refer to the index of the
|
|
895
|
+
* character in the input text stream and are output in the `cluster` field
|
|
896
|
+
* of {@link GlyphInfo}.
|
|
897
|
+
*
|
|
898
|
+
* This function does not check the validity of `codePoint`, it is up to the
|
|
899
|
+
* caller to ensure it is a valid Unicode code point.
|
|
900
|
+
* @param codePoint A Unicode code point.
|
|
901
|
+
* @param cluster The cluster value of `codePoint`.
|
|
902
|
+
*/
|
|
903
|
+
add(codePoint, cluster) {
|
|
904
|
+
exports.hb_buffer_add(this.ptr, codePoint, cluster);
|
|
905
|
+
}
|
|
906
|
+
/**
|
|
889
907
|
* Add text to the buffer.
|
|
890
908
|
* @param text Text to be added to the buffer.
|
|
891
909
|
* @param itemOffset The offset of the first character to add to the buffer.
|
|
892
|
-
* @param itemLength The number of characters to add to the buffer, or
|
|
910
|
+
* @param itemLength The number of characters to add to the buffer, or omit for the end of text.
|
|
893
911
|
*/
|
|
894
|
-
addText(text, itemOffset = 0, itemLength
|
|
912
|
+
addText(text, itemOffset = 0, itemLength) {
|
|
895
913
|
const str = string_to_utf16_ptr(text);
|
|
896
|
-
|
|
897
|
-
exports.hb_buffer_add_utf16(this.ptr, str.ptr, str.length, itemOffset, itemLength);
|
|
914
|
+
exports.hb_buffer_add_utf16(this.ptr, str.ptr, str.length, itemOffset, itemLength ?? str.length);
|
|
898
915
|
str.free();
|
|
899
916
|
}
|
|
900
917
|
/**
|
|
901
918
|
* Add code points to the buffer.
|
|
902
919
|
* @param codePoints Array of code points to be added to the buffer.
|
|
903
920
|
* @param itemOffset The offset of the first code point to add to the buffer.
|
|
904
|
-
* @param itemLength The number of code points to add to the buffer, or
|
|
921
|
+
* @param itemLength The number of code points to add to the buffer, or omit for the end of the array.
|
|
905
922
|
*/
|
|
906
|
-
addCodePoints(codePoints, itemOffset = 0, itemLength
|
|
923
|
+
addCodePoints(codePoints, itemOffset = 0, itemLength) {
|
|
907
924
|
const codePointsPtr = exports.malloc(codePoints.length * 4);
|
|
908
925
|
Module.HEAPU32.subarray(codePointsPtr / 4, codePointsPtr / 4 + codePoints.length).set(codePoints);
|
|
909
|
-
|
|
910
|
-
exports.hb_buffer_add_codepoints(this.ptr, codePointsPtr, codePoints.length, itemOffset, itemLength);
|
|
926
|
+
exports.hb_buffer_add_codepoints(this.ptr, codePointsPtr, codePoints.length, itemOffset, itemLength ?? codePoints.length);
|
|
911
927
|
exports.free(codePointsPtr);
|
|
912
928
|
}
|
|
913
929
|
/**
|
|
@@ -954,7 +970,7 @@ var Buffer = class Buffer {
|
|
|
954
970
|
* Set the HarfBuzz clustering level.
|
|
955
971
|
*
|
|
956
972
|
* Affects the cluster values returned from shaping.
|
|
957
|
-
* @param level
|
|
973
|
+
* @param level A {@link ClusterLevel} value. See the HarfBuzz manual chapter on Clusters.
|
|
958
974
|
*/
|
|
959
975
|
setClusterLevel(level) {
|
|
960
976
|
exports.hb_buffer_set_cluster_level(this.ptr, level);
|
|
@@ -996,12 +1012,13 @@ var Buffer = class Buffer {
|
|
|
996
1012
|
* @returns An array of {@link GlyphInfo} objects.
|
|
997
1013
|
*/
|
|
998
1014
|
getGlyphInfos() {
|
|
999
|
-
const
|
|
1000
|
-
const infosArray = Module.HEAPU32.subarray(
|
|
1015
|
+
const infosPtr = exports.hb_buffer_get_glyph_infos(this.ptr, 0);
|
|
1016
|
+
const infosArray = Module.HEAPU32.subarray(infosPtr / 4, infosPtr / 4 + this.getLength() * 5);
|
|
1001
1017
|
const infos = [];
|
|
1002
1018
|
for (let i = 0; i < infosArray.length; i += 5) infos.push({
|
|
1003
1019
|
codepoint: infosArray[i],
|
|
1004
|
-
cluster: infosArray[i + 2]
|
|
1020
|
+
cluster: infosArray[i + 2],
|
|
1021
|
+
flags: exports.hb_glyph_info_get_glyph_flags(infosPtr + i * 4)
|
|
1005
1022
|
});
|
|
1006
1023
|
return infos;
|
|
1007
1024
|
}
|
|
@@ -1030,15 +1047,16 @@ var Buffer = class Buffer {
|
|
|
1030
1047
|
* properties from getGlyphInfos and getGlyphPositions combined.
|
|
1031
1048
|
*/
|
|
1032
1049
|
getGlyphInfosAndPositions() {
|
|
1033
|
-
const
|
|
1034
|
-
const infosArray = Module.HEAPU32.subarray(
|
|
1050
|
+
const infosPtr = exports.hb_buffer_get_glyph_infos(this.ptr, 0);
|
|
1051
|
+
const infosArray = Module.HEAPU32.subarray(infosPtr / 4, infosPtr / 4 + this.getLength() * 5);
|
|
1035
1052
|
const positionsPtr32 = exports.hb_buffer_get_glyph_positions(this.ptr, 0) / 4;
|
|
1036
|
-
const positionsArray = positionsPtr32 ? Module.HEAP32.subarray(positionsPtr32, positionsPtr32 + this.getLength() * 5) :
|
|
1053
|
+
const positionsArray = positionsPtr32 ? Module.HEAP32.subarray(positionsPtr32, positionsPtr32 + this.getLength() * 5) : void 0;
|
|
1037
1054
|
const out = [];
|
|
1038
1055
|
for (let i = 0; i < infosArray.length; i += 5) {
|
|
1039
1056
|
const info = {
|
|
1040
1057
|
codepoint: infosArray[i],
|
|
1041
|
-
cluster: infosArray[i + 2]
|
|
1058
|
+
cluster: infosArray[i + 2],
|
|
1059
|
+
flags: exports.hb_glyph_info_get_glyph_flags(infosPtr + i * 4)
|
|
1042
1060
|
};
|
|
1043
1061
|
for (const [name, idx] of [
|
|
1044
1062
|
["mask", 1],
|
|
@@ -1080,15 +1098,16 @@ var Buffer = class Buffer {
|
|
|
1080
1098
|
}
|
|
1081
1099
|
/**
|
|
1082
1100
|
* Serialize the buffer contents to a string.
|
|
1083
|
-
* @param
|
|
1084
|
-
*
|
|
1085
|
-
*
|
|
1086
|
-
*
|
|
1087
|
-
*
|
|
1088
|
-
*
|
|
1101
|
+
* @param options Serialization options:
|
|
1102
|
+
* - `font`: the font to use for serialization;
|
|
1103
|
+
* - `start`: the starting index of the glyphs (default `0`);
|
|
1104
|
+
* - `end`: the ending index of the glyphs (default end of buffer);
|
|
1105
|
+
* - `format`: a {@link BufferSerializeFormat} value (default `TEXT`);
|
|
1106
|
+
* - `flags`: a combination of {@link BufferSerializeFlag} values (default `0`).
|
|
1089
1107
|
* @returns The serialized buffer contents.
|
|
1090
1108
|
*/
|
|
1091
|
-
serialize(
|
|
1109
|
+
serialize(options = {}) {
|
|
1110
|
+
let { font, start = 0, end, format = BufferSerializeFormat.TEXT, flags = 0 } = options;
|
|
1092
1111
|
const sp = Module.stackSave();
|
|
1093
1112
|
const endPos = end ?? this.getLength();
|
|
1094
1113
|
const bufLen = 32 * 1024;
|
|
@@ -1113,13 +1132,161 @@ var Buffer = class Buffer {
|
|
|
1113
1132
|
getContentType() {
|
|
1114
1133
|
return exports.hb_buffer_get_content_type(this.ptr);
|
|
1115
1134
|
}
|
|
1135
|
+
};
|
|
1136
|
+
//#endregion
|
|
1137
|
+
//#region src/feature.ts
|
|
1138
|
+
/**
|
|
1139
|
+
* A {@link https://harfbuzz.github.io/harfbuzz-hb-common.html#hb-feature-t | HarfBuzz feature}.
|
|
1140
|
+
*
|
|
1141
|
+
* The structure that holds information about requested feature application.
|
|
1142
|
+
* The feature will be applied with the given value to all glyphs which are in
|
|
1143
|
+
* clusters between {@link Feature.start} (inclusive) and {@link Feature.end}
|
|
1144
|
+
* (exclusive). Setting `start` to `0` and `end` to `0xffffffff` specifies that
|
|
1145
|
+
* the feature always applies to the entire buffer.
|
|
1146
|
+
*/
|
|
1147
|
+
var Feature = class Feature {
|
|
1148
|
+
static {
|
|
1149
|
+
this.GLOBAL_START = 0;
|
|
1150
|
+
}
|
|
1151
|
+
static {
|
|
1152
|
+
this.GLOBAL_END = 4294967295;
|
|
1153
|
+
}
|
|
1154
|
+
constructor(tag, value = 1, start = Feature.GLOBAL_START, end = Feature.GLOBAL_END) {
|
|
1155
|
+
this.tag = tag;
|
|
1156
|
+
this.value = value;
|
|
1157
|
+
this.start = start;
|
|
1158
|
+
this.end = end;
|
|
1159
|
+
}
|
|
1160
|
+
/**
|
|
1161
|
+
* Parses a string into a Feature.
|
|
1162
|
+
*
|
|
1163
|
+
* The format for specifying feature strings follows. All valid CSS
|
|
1164
|
+
* font-feature-settings values other than `normal` and the global values are
|
|
1165
|
+
* also accepted, though not documented below. CSS string escapes are not
|
|
1166
|
+
* supported.
|
|
1167
|
+
*
|
|
1168
|
+
* The range indices refer to the positions between Unicode characters. The
|
|
1169
|
+
* position before the first character is always 0.
|
|
1170
|
+
*
|
|
1171
|
+
* The format is Python-esque. Here is how it all works:
|
|
1172
|
+
*
|
|
1173
|
+
* | Syntax | Value | Start | End | Meaning |
|
|
1174
|
+
* | ------------- | ----- | ----- | --- | -------------------------------- |
|
|
1175
|
+
* | `kern` | 1 | 0 | ∞ | Turn feature on |
|
|
1176
|
+
* | `+kern` | 1 | 0 | ∞ | Turn feature on |
|
|
1177
|
+
* | `-kern` | 0 | 0 | ∞ | Turn feature off |
|
|
1178
|
+
* | `kern=0` | 0 | 0 | ∞ | Turn feature off |
|
|
1179
|
+
* | `kern=1` | 1 | 0 | ∞ | Turn feature on |
|
|
1180
|
+
* | `aalt=2` | 2 | 0 | ∞ | Choose 2nd alternate |
|
|
1181
|
+
* | `kern[]` | 1 | 0 | ∞ | Turn feature on |
|
|
1182
|
+
* | `kern[:]` | 1 | 0 | ∞ | Turn feature on |
|
|
1183
|
+
* | `kern[5:]` | 1 | 5 | ∞ | Turn feature on, partial |
|
|
1184
|
+
* | `kern[:5]` | 1 | 0 | 5 | Turn feature on, partial |
|
|
1185
|
+
* | `kern[3:5]` | 1 | 3 | 5 | Turn feature on, range |
|
|
1186
|
+
* | `kern[3]` | 1 | 3 | 3+1 | Turn feature on, single char |
|
|
1187
|
+
* | `aalt[3:5]=2` | 2 | 3 | 5 | Turn 2nd alternate on for range |
|
|
1188
|
+
*
|
|
1189
|
+
* @param str The string to parse.
|
|
1190
|
+
* @returns A Feature, or undefined if the string is not a valid feature.
|
|
1191
|
+
*/
|
|
1192
|
+
static fromString(str) {
|
|
1193
|
+
const sp = Module.stackSave();
|
|
1194
|
+
const featurePtr = Module.stackAlloc(16);
|
|
1195
|
+
const strPtr = string_to_ascii_ptr(str);
|
|
1196
|
+
let feature;
|
|
1197
|
+
if (exports.hb_feature_from_string(strPtr.ptr, -1, featurePtr)) feature = new Feature(hb_untag(Module.HEAPU32[featurePtr / 4]), Module.HEAPU32[featurePtr / 4 + 1], Module.HEAPU32[featurePtr / 4 + 2], Module.HEAPU32[featurePtr / 4 + 3]);
|
|
1198
|
+
strPtr.free();
|
|
1199
|
+
Module.stackRestore(sp);
|
|
1200
|
+
return feature;
|
|
1201
|
+
}
|
|
1116
1202
|
/**
|
|
1117
|
-
*
|
|
1118
|
-
*
|
|
1203
|
+
* Converts the feature to a string in the format understood by
|
|
1204
|
+
* {@link Feature.fromString}.
|
|
1205
|
+
*
|
|
1206
|
+
* Note that the feature value will be omitted if it is `1`, but the string
|
|
1207
|
+
* won't include any whitespace.
|
|
1208
|
+
*
|
|
1209
|
+
* @returns The feature string.
|
|
1210
|
+
*/
|
|
1211
|
+
toString() {
|
|
1212
|
+
const sp = Module.stackSave();
|
|
1213
|
+
const featurePtr = Module.stackAlloc(16);
|
|
1214
|
+
this.writeTo(featurePtr);
|
|
1215
|
+
const bufLen = 128;
|
|
1216
|
+
const bufPtr = Module.stackAlloc(bufLen);
|
|
1217
|
+
exports.hb_feature_to_string(featurePtr, bufPtr, bufLen);
|
|
1218
|
+
const result = utf8_ptr_to_string(bufPtr);
|
|
1219
|
+
Module.stackRestore(sp);
|
|
1220
|
+
return result;
|
|
1221
|
+
}
|
|
1222
|
+
/** @internal Write this feature into the given hb_feature_t pointer. */
|
|
1223
|
+
writeTo(ptr) {
|
|
1224
|
+
Module.HEAPU32[ptr / 4] = hb_tag(this.tag);
|
|
1225
|
+
Module.HEAPU32[ptr / 4 + 1] = this.value;
|
|
1226
|
+
Module.HEAPU32[ptr / 4 + 2] = this.start;
|
|
1227
|
+
Module.HEAPU32[ptr / 4 + 3] = this.end;
|
|
1228
|
+
}
|
|
1229
|
+
};
|
|
1230
|
+
//#endregion
|
|
1231
|
+
//#region src/variation.ts
|
|
1232
|
+
/**
|
|
1233
|
+
* A {@link https://harfbuzz.github.io/harfbuzz-hb-common.html#hb-variation-t | HarfBuzz variation}.
|
|
1234
|
+
*
|
|
1235
|
+
* Data type for holding variation data. Registered OpenType variation-axis
|
|
1236
|
+
* tags are listed in
|
|
1237
|
+
* {@link https://docs.microsoft.com/en-us/typography/opentype/spec/dvaraxisreg | OpenType Axis Tag Registry}.
|
|
1238
|
+
*/
|
|
1239
|
+
var Variation = class Variation {
|
|
1240
|
+
constructor(tag, value = 0) {
|
|
1241
|
+
this.tag = tag;
|
|
1242
|
+
this.value = value;
|
|
1243
|
+
}
|
|
1244
|
+
/**
|
|
1245
|
+
* Parses a string into a Variation.
|
|
1246
|
+
*
|
|
1247
|
+
* The format for specifying variation settings follows. All valid CSS
|
|
1248
|
+
* font-variation-settings values other than `normal` and `inherited` are
|
|
1249
|
+
* also accepted, though, not documented below.
|
|
1250
|
+
*
|
|
1251
|
+
* The format is a tag, optionally followed by an equals sign, followed by a
|
|
1252
|
+
* number. For example `wght=500`, or `slnt=-7.5`.
|
|
1253
|
+
*
|
|
1254
|
+
* @param str The string to parse.
|
|
1255
|
+
* @returns A Variation, or undefined if the string is not a valid variation.
|
|
1256
|
+
*/
|
|
1257
|
+
static fromString(str) {
|
|
1258
|
+
const sp = Module.stackSave();
|
|
1259
|
+
const variationPtr = Module.stackAlloc(8);
|
|
1260
|
+
const strPtr = string_to_ascii_ptr(str);
|
|
1261
|
+
let variation;
|
|
1262
|
+
if (exports.hb_variation_from_string(strPtr.ptr, -1, variationPtr)) variation = new Variation(hb_untag(Module.HEAPU32[variationPtr / 4]), Module.HEAPF32[variationPtr / 4 + 1]);
|
|
1263
|
+
strPtr.free();
|
|
1264
|
+
Module.stackRestore(sp);
|
|
1265
|
+
return variation;
|
|
1266
|
+
}
|
|
1267
|
+
/**
|
|
1268
|
+
* Converts the variation to a string in the format understood by
|
|
1269
|
+
* {@link Variation.fromString}.
|
|
1270
|
+
*
|
|
1271
|
+
* Note that the string won't include any whitespace.
|
|
1272
|
+
*
|
|
1273
|
+
* @returns The variation string.
|
|
1119
1274
|
*/
|
|
1120
|
-
|
|
1121
|
-
const
|
|
1122
|
-
|
|
1275
|
+
toString() {
|
|
1276
|
+
const sp = Module.stackSave();
|
|
1277
|
+
const variationPtr = Module.stackAlloc(8);
|
|
1278
|
+
this.writeTo(variationPtr);
|
|
1279
|
+
const bufLen = 128;
|
|
1280
|
+
const bufPtr = Module.stackAlloc(bufLen);
|
|
1281
|
+
exports.hb_variation_to_string(variationPtr, bufPtr, bufLen);
|
|
1282
|
+
const result = utf8_ptr_to_string(bufPtr);
|
|
1283
|
+
Module.stackRestore(sp);
|
|
1284
|
+
return result;
|
|
1285
|
+
}
|
|
1286
|
+
/** @internal Write this variation into the given hb_variation_t pointer. */
|
|
1287
|
+
writeTo(ptr) {
|
|
1288
|
+
Module.HEAPU32[ptr / 4] = hb_tag(this.tag);
|
|
1289
|
+
Module.HEAPF32[ptr / 4 + 1] = this.value;
|
|
1123
1290
|
}
|
|
1124
1291
|
};
|
|
1125
1292
|
//#endregion
|
|
@@ -1138,22 +1305,20 @@ const TracePhase = {
|
|
|
1138
1305
|
* @param font The Font to shape with.
|
|
1139
1306
|
* @param buffer The Buffer containing text to shape, suitably prepared
|
|
1140
1307
|
* (text added, segment properties set).
|
|
1141
|
-
* @param features
|
|
1308
|
+
* @param features An array of {@link Feature} values to apply.
|
|
1142
1309
|
*/
|
|
1143
1310
|
function shape(font, buffer, features) {
|
|
1311
|
+
const featuresLen = features?.length ?? 0;
|
|
1312
|
+
const sp = Module.stackSave();
|
|
1144
1313
|
let featuresPtr = 0;
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
featureList.forEach((feature) => {
|
|
1150
|
-
const str = string_to_ascii_ptr(feature);
|
|
1151
|
-
if (exports.hb_feature_from_string(str.ptr, -1, featuresPtr + featuresLen * 16)) featuresLen++;
|
|
1152
|
-
str.free();
|
|
1314
|
+
if (featuresLen) {
|
|
1315
|
+
featuresPtr = Module.stackAlloc(16 * featuresLen);
|
|
1316
|
+
features.forEach((feature, i) => {
|
|
1317
|
+
feature.writeTo(featuresPtr + i * 16);
|
|
1153
1318
|
});
|
|
1154
1319
|
}
|
|
1155
1320
|
exports.hb_shape(font.ptr, buffer.ptr, featuresPtr, featuresLen);
|
|
1156
|
-
|
|
1321
|
+
Module.stackRestore(sp);
|
|
1157
1322
|
}
|
|
1158
1323
|
/**
|
|
1159
1324
|
* Shape a buffer with a given font, returning a JSON trace of the shaping process.
|
|
@@ -1163,7 +1328,7 @@ function shape(font, buffer, features) {
|
|
|
1163
1328
|
*
|
|
1164
1329
|
* @param font The Font to shape with.
|
|
1165
1330
|
* @param buffer The Buffer containing text to shape, suitably prepared.
|
|
1166
|
-
* @param features
|
|
1331
|
+
* @param features An array of {@link Feature} values to apply.
|
|
1167
1332
|
* @param stop_at A lookup ID at which to terminate shaping.
|
|
1168
1333
|
* @param stop_phase The {@link TracePhase} at which to stop shaping.
|
|
1169
1334
|
* @returns An array of trace entries, each with a message, serialized glyphs, and phase info.
|
|
@@ -1178,7 +1343,11 @@ function shapeWithTrace(font, buffer, features, stop_at, stop_phase) {
|
|
|
1178
1343
|
if (currentPhase != stop_phase) stopping = false;
|
|
1179
1344
|
if (stop_phase != TracePhase.DONT_STOP && currentPhase == stop_phase && message.startsWith("end lookup " + stop_at)) stopping = true;
|
|
1180
1345
|
if (stopping) return false;
|
|
1181
|
-
const traceBuf = buffer.serialize(
|
|
1346
|
+
const traceBuf = buffer.serialize({
|
|
1347
|
+
font,
|
|
1348
|
+
format: BufferSerializeFormat.JSON,
|
|
1349
|
+
flags: BufferSerializeFlag.NO_GLYPH_NAMES
|
|
1350
|
+
});
|
|
1182
1351
|
trace.push({
|
|
1183
1352
|
m: message,
|
|
1184
1353
|
t: JSON.parse(traceBuf),
|
|
@@ -1234,4 +1403,4 @@ function otTagToLanguage(tag) {
|
|
|
1234
1403
|
//#region src/index.ts
|
|
1235
1404
|
init(await createHarfBuzz());
|
|
1236
1405
|
//#endregion
|
|
1237
|
-
export { Blob, Buffer, BufferContentType, BufferFlag, BufferSerializeFlag, BufferSerializeFormat, Direction, Face, Font, FontFuncs, GlyphClass, GlyphFlag, TracePhase, otTagToLanguage, otTagToScript, shape, shapeWithTrace, version, versionString };
|
|
1406
|
+
export { Blob, Buffer, BufferContentType, BufferFlag, BufferSerializeFlag, BufferSerializeFormat, ClusterLevel, Direction, Face, Feature, Font, FontFuncs, GlyphClass, GlyphFlag, TracePhase, Variation, otTagToLanguage, otTagToScript, shape, shapeWithTrace, version, versionString };
|