harfbuzzjs 0.4.6 → 0.4.8
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/build.sh +3 -2
- package/hb-subset.wasm +0 -0
- package/hb.js +2 -21
- package/hb.symbols +1 -0
- package/hb.wasm +0 -0
- package/hbjs.js +53 -60
- package/package.json +1 -1
- package/test/index.js +136 -135
package/build.sh
CHANGED
|
@@ -18,8 +18,9 @@ em++ \
|
|
|
18
18
|
-s MODULARIZE \
|
|
19
19
|
-s EXPORT_NAME=createHarfBuzz \
|
|
20
20
|
-s EXPORTED_FUNCTIONS=@hb.symbols \
|
|
21
|
-
-s EXPORTED_RUNTIME_METHODS='["addFunction", "wasmMemory", "wasmExports"]' \
|
|
22
|
-
-s INITIAL_MEMORY=
|
|
21
|
+
-s EXPORTED_RUNTIME_METHODS='["addFunction", "removeFunction", "wasmMemory", "wasmExports"]' \
|
|
22
|
+
-s INITIAL_MEMORY=256KB \
|
|
23
|
+
-s ALLOW_MEMORY_GROWTH \
|
|
23
24
|
-s ALLOW_TABLE_GROWTH \
|
|
24
25
|
-lexports.js \
|
|
25
26
|
-o hb.js \
|
package/hb-subset.wasm
CHANGED
|
Binary file
|
package/hb.js
CHANGED
|
@@ -1,21 +1,2 @@
|
|
|
1
|
-
var createHarfBuzz = (() => {
|
|
2
|
-
|
|
3
|
-
if (typeof __filename != 'undefined') _scriptName = _scriptName || __filename;
|
|
4
|
-
return (
|
|
5
|
-
async function(moduleArg = {}) {
|
|
6
|
-
var moduleRtn;
|
|
7
|
-
|
|
8
|
-
var Module=moduleArg;var readyPromiseResolve,readyPromiseReject;var readyPromise=new Promise((resolve,reject)=>{readyPromiseResolve=resolve;readyPromiseReject=reject});var ENVIRONMENT_IS_WEB=typeof window=="object";var ENVIRONMENT_IS_WORKER=typeof WorkerGlobalScope!="undefined";var ENVIRONMENT_IS_NODE=typeof process=="object"&&typeof process.versions=="object"&&typeof process.versions.node=="string"&&process.type!="renderer";if(ENVIRONMENT_IS_NODE){}var moduleOverrides={...Module};var arguments_=[];var thisProgram="./this.program";var quit_=(status,toThrow)=>{throw toThrow};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");var nodePath=require("path");scriptDirectory=__dirname+"/";readBinary=filename=>{filename=isFileURI(filename)?new URL(filename):filename;var ret=fs.readFileSync(filename);return ret};readAsync=async(filename,binary=true)=>{filename=isFileURI(filename)?new URL(filename):filename;var ret=fs.readFileSync(filename,binary?undefined:"utf8");return ret};if(!Module["thisProgram"]&&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){if(ENVIRONMENT_IS_WORKER){scriptDirectory=self.location.href}else if(typeof document!="undefined"&&document.currentScript){scriptDirectory=document.currentScript.src}if(_scriptName){scriptDirectory=_scriptName}if(scriptDirectory.startsWith("blob:")){scriptDirectory=""}else{scriptDirectory=scriptDirectory.slice(0,scriptDirectory.replace(/[?#].*/,"").lastIndexOf("/")+1)}{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=Module["print"]||console.log.bind(console);var err=Module["printErr"]||console.error.bind(console);Object.assign(Module,moduleOverrides);moduleOverrides=null;if(Module["arguments"])arguments_=Module["arguments"];if(Module["thisProgram"])thisProgram=Module["thisProgram"];var wasmBinary=Module["wasmBinary"];var wasmMemory;var ABORT=false;var EXITSTATUS;var HEAP8,HEAPU8,HEAP16,HEAPU16,HEAP32,HEAPU32,HEAPF32,HEAP64,HEAPU64,HEAPF64;var runtimeInitialized=false;var isFileURI=filename=>filename.startsWith("file://");function updateMemoryViews(){var b=wasmMemory.buffer;Module["HEAP8"]=HEAP8=new Int8Array(b);Module["HEAP16"]=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);Module["HEAPF64"]=HEAPF64=new Float64Array(b);Module["HEAP64"]=HEAP64=new BigInt64Array(b);Module["HEAPU64"]=HEAPU64=new BigUint64Array(b)}function preRun(){if(Module["preRun"]){if(typeof Module["preRun"]=="function")Module["preRun"]=[Module["preRun"]];while(Module["preRun"].length){addOnPreRun(Module["preRun"].shift())}}callRuntimeCallbacks(onPreRuns)}function initRuntime(){runtimeInitialized=true;wasmExports["__wasm_call_ctors"]()}function postRun(){if(Module["postRun"]){if(typeof Module["postRun"]=="function")Module["postRun"]=[Module["postRun"]];while(Module["postRun"].length){addOnPostRun(Module["postRun"].shift())}}callRuntimeCallbacks(onPostRuns)}var runDependencies=0;var dependenciesFulfilled=null;function addRunDependency(id){runDependencies++;Module["monitorRunDependencies"]?.(runDependencies)}function removeRunDependency(id){runDependencies--;Module["monitorRunDependencies"]?.(runDependencies);if(runDependencies==0){if(dependenciesFulfilled){var callback=dependenciesFulfilled;dependenciesFulfilled=null;callback()}}}function abort(what){Module["onAbort"]?.(what);what="Aborted("+what+")";err(what);ABORT=true;what+=". Build with -sASSERTIONS for more info.";var e=new WebAssembly.RuntimeError(what);readyPromiseReject(e);throw e}var wasmBinaryFile;function findWasmBinary(){return locateFile("hb.wasm")}function getBinarySync(file){if(file==wasmBinaryFile&&wasmBinary){return new Uint8Array(wasmBinary)}if(readBinary){return readBinary(file)}throw"both async and sync fetching of the wasm failed"}async function getWasmBinary(binaryFile){if(!wasmBinary){try{var response=await readAsync(binaryFile);return new Uint8Array(response)}catch{}}return getBinarySync(binaryFile)}async function instantiateArrayBuffer(binaryFile,imports){try{var binary=await getWasmBinary(binaryFile);var instance=await WebAssembly.instantiate(binary,imports);return instance}catch(reason){err(`failed to asynchronously prepare wasm: ${reason}`);abort(reason)}}async function instantiateAsync(binary,binaryFile,imports){if(!binary&&typeof WebAssembly.instantiateStreaming=="function"&&!isFileURI(binaryFile)&&!ENVIRONMENT_IS_NODE){try{var response=fetch(binaryFile,{credentials:"same-origin"});var instantiationResult=await WebAssembly.instantiateStreaming(response,imports);return instantiationResult}catch(reason){err(`wasm streaming compile failed: ${reason}`);err("falling back to ArrayBuffer instantiation")}}return instantiateArrayBuffer(binaryFile,imports)}function getWasmImports(){return{env:wasmImports,wasi_snapshot_preview1:wasmImports}}async function createWasm(){function receiveInstance(instance,module){wasmExports=instance.exports;Module["wasmExports"]=wasmExports;wasmMemory=wasmExports["memory"];Module["wasmMemory"]=wasmMemory;updateMemoryViews();wasmTable=wasmExports["__indirect_function_table"];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)=>{receiveInstance(mod,inst);resolve(mod.exports)})})}wasmBinaryFile??=findWasmBinary();try{var result=await instantiateAsync(wasmBinary,wasmBinaryFile,info);var exports=receiveInstantiationResult(result);return exports}catch(e){readyPromiseReject(e);return Promise.reject(e)}}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.unshift(cb);var onPreRuns=[];var addOnPreRun=cb=>onPreRuns.unshift(cb);var noExitRuntime=Module["noExitRuntime"]||true;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 abortOnCannotGrowMemory=requestedSize=>{abort("OOM")};var _emscripten_resize_heap=requestedSize=>{var oldSize=HEAPU8.length;requestedSize>>>=0;abortOnCannotGrowMemory(requestedSize)};var uleb128Encode=(n,target)=>{if(n<128){target.push(n)}else{target.push(n%128|128,n>>7)}};var sigToWasmTypes=sig=>{var typeNames={i:"i32",j:"i64",f:"f32",d:"f64",e:"externref",p:"i32"};var type={parameters:[],results:sig[0]=="v"?[]:[typeNames[sig[0]]]};for(var i=1;i<sig.length;++i){type.parameters.push(typeNames[sig[i]])}return type};var generateFuncType=(sig,target)=>{var sigRet=sig.slice(0,1);var sigParam=sig.slice(1);var typeCodes={i:127,p:127,j:126,f:125,d:124,e:111};target.push(96);uleb128Encode(sigParam.length,target);for(var paramType of sigParam){target.push(typeCodes[paramType])}if(sigRet=="v"){target.push(0)}else{target.push(1,typeCodes[sigRet])}};var convertJsFunctionToWasm=(func,sig)=>{if(typeof WebAssembly.Function=="function"){return new WebAssembly.Function(sigToWasmTypes(sig),func)}var typeSectionBody=[1];generateFuncType(sig,typeSectionBody);var bytes=[0,97,115,109,1,0,0,0,1];uleb128Encode(typeSectionBody.length,bytes);bytes.push(...typeSectionBody);bytes.push(2,7,1,1,101,1,102,0,0,7,5,1,1,102,0,0);var module=new WebAssembly.Module(new Uint8Array(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()}try{wasmTable.grow(1)}catch(err){if(!(err instanceof RangeError)){throw err}throw"Unable to grow wasm table. Set ALLOW_TABLE_GROWTH."}return wasmTable.length-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 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();var ___wasm_call_ctors=wasmExports["__wasm_call_ctors"];var _hb_blob_create=Module["_hb_blob_create"]=wasmExports["hb_blob_create"];var _hb_blob_destroy=Module["_hb_blob_destroy"]=wasmExports["hb_blob_destroy"];var _hb_blob_get_length=Module["_hb_blob_get_length"]=wasmExports["hb_blob_get_length"];var _hb_blob_get_data=Module["_hb_blob_get_data"]=wasmExports["hb_blob_get_data"];var _hb_buffer_serialize_glyphs=Module["_hb_buffer_serialize_glyphs"]=wasmExports["hb_buffer_serialize_glyphs"];var _hb_buffer_create=Module["_hb_buffer_create"]=wasmExports["hb_buffer_create"];var _hb_buffer_destroy=Module["_hb_buffer_destroy"]=wasmExports["hb_buffer_destroy"];var _hb_buffer_get_content_type=Module["_hb_buffer_get_content_type"]=wasmExports["hb_buffer_get_content_type"];var _hb_buffer_set_direction=Module["_hb_buffer_set_direction"]=wasmExports["hb_buffer_set_direction"];var _hb_buffer_set_script=Module["_hb_buffer_set_script"]=wasmExports["hb_buffer_set_script"];var _hb_buffer_set_language=Module["_hb_buffer_set_language"]=wasmExports["hb_buffer_set_language"];var _hb_buffer_set_flags=Module["_hb_buffer_set_flags"]=wasmExports["hb_buffer_set_flags"];var _hb_buffer_set_cluster_level=Module["_hb_buffer_set_cluster_level"]=wasmExports["hb_buffer_set_cluster_level"];var _hb_buffer_get_length=Module["_hb_buffer_get_length"]=wasmExports["hb_buffer_get_length"];var _hb_buffer_get_glyph_infos=Module["_hb_buffer_get_glyph_infos"]=wasmExports["hb_buffer_get_glyph_infos"];var _hb_buffer_get_glyph_positions=Module["_hb_buffer_get_glyph_positions"]=wasmExports["hb_buffer_get_glyph_positions"];var _hb_glyph_info_get_glyph_flags=Module["_hb_glyph_info_get_glyph_flags"]=wasmExports["hb_glyph_info_get_glyph_flags"];var _hb_buffer_guess_segment_properties=Module["_hb_buffer_guess_segment_properties"]=wasmExports["hb_buffer_guess_segment_properties"];var _hb_buffer_add_utf8=Module["_hb_buffer_add_utf8"]=wasmExports["hb_buffer_add_utf8"];var _hb_buffer_add_utf16=Module["_hb_buffer_add_utf16"]=wasmExports["hb_buffer_add_utf16"];var _hb_buffer_set_message_func=Module["_hb_buffer_set_message_func"]=wasmExports["hb_buffer_set_message_func"];var _hb_language_from_string=Module["_hb_language_from_string"]=wasmExports["hb_language_from_string"];var _hb_script_from_string=Module["_hb_script_from_string"]=wasmExports["hb_script_from_string"];var _hb_version=Module["_hb_version"]=wasmExports["hb_version"];var _hb_version_string=Module["_hb_version_string"]=wasmExports["hb_version_string"];var _hb_feature_from_string=Module["_hb_feature_from_string"]=wasmExports["hb_feature_from_string"];var _malloc=Module["_malloc"]=wasmExports["malloc"];var _free=Module["_free"]=wasmExports["free"];var _hb_draw_funcs_set_move_to_func=Module["_hb_draw_funcs_set_move_to_func"]=wasmExports["hb_draw_funcs_set_move_to_func"];var _hb_draw_funcs_set_line_to_func=Module["_hb_draw_funcs_set_line_to_func"]=wasmExports["hb_draw_funcs_set_line_to_func"];var _hb_draw_funcs_set_quadratic_to_func=Module["_hb_draw_funcs_set_quadratic_to_func"]=wasmExports["hb_draw_funcs_set_quadratic_to_func"];var _hb_draw_funcs_set_cubic_to_func=Module["_hb_draw_funcs_set_cubic_to_func"]=wasmExports["hb_draw_funcs_set_cubic_to_func"];var _hb_draw_funcs_set_close_path_func=Module["_hb_draw_funcs_set_close_path_func"]=wasmExports["hb_draw_funcs_set_close_path_func"];var _hb_draw_funcs_create=Module["_hb_draw_funcs_create"]=wasmExports["hb_draw_funcs_create"];var _hb_face_create=Module["_hb_face_create"]=wasmExports["hb_face_create"];var _hb_face_destroy=Module["_hb_face_destroy"]=wasmExports["hb_face_destroy"];var _hb_face_reference_table=Module["_hb_face_reference_table"]=wasmExports["hb_face_reference_table"];var _hb_face_get_upem=Module["_hb_face_get_upem"]=wasmExports["hb_face_get_upem"];var _hb_face_collect_unicodes=Module["_hb_face_collect_unicodes"]=wasmExports["hb_face_collect_unicodes"];var _hb_font_draw_glyph=Module["_hb_font_draw_glyph"]=wasmExports["hb_font_draw_glyph"];var _hb_font_glyph_to_string=Module["_hb_font_glyph_to_string"]=wasmExports["hb_font_glyph_to_string"];var _hb_font_create=Module["_hb_font_create"]=wasmExports["hb_font_create"];var _hb_font_destroy=Module["_hb_font_destroy"]=wasmExports["hb_font_destroy"];var _hb_font_set_scale=Module["_hb_font_set_scale"]=wasmExports["hb_font_set_scale"];var _hb_font_set_variations=Module["_hb_font_set_variations"]=wasmExports["hb_font_set_variations"];var _hb_set_create=Module["_hb_set_create"]=wasmExports["hb_set_create"];var _hb_set_destroy=Module["_hb_set_destroy"]=wasmExports["hb_set_destroy"];var _hb_ot_var_get_axis_infos=Module["_hb_ot_var_get_axis_infos"]=wasmExports["hb_ot_var_get_axis_infos"];var _hb_set_get_population=Module["_hb_set_get_population"]=wasmExports["hb_set_get_population"];var _hb_set_next_many=Module["_hb_set_next_many"]=wasmExports["hb_set_next_many"];var _hb_shape=Module["_hb_shape"]=wasmExports["hb_shape"];var __emscripten_timeout=wasmExports["_emscripten_timeout"];Module["wasmMemory"]=wasmMemory;Module["wasmExports"]=wasmExports;Module["addFunction"]=addFunction;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()}}if(Module["preInit"]){if(typeof Module["preInit"]=="function")Module["preInit"]=[Module["preInit"]];while(Module["preInit"].length>0){Module["preInit"].pop()()}}run();moduleRtn=readyPromise;
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
return moduleRtn;
|
|
12
|
-
}
|
|
13
|
-
);
|
|
14
|
-
})();
|
|
15
|
-
if (typeof exports === 'object' && typeof module === 'object') {
|
|
16
|
-
module.exports = createHarfBuzz;
|
|
17
|
-
// This default export looks redundant, but it allows TS to import this
|
|
18
|
-
// commonjs style module.
|
|
19
|
-
module.exports.default = createHarfBuzz;
|
|
20
|
-
} else if (typeof define === 'function' && define['amd'])
|
|
21
|
-
define([], () => createHarfBuzz);
|
|
1
|
+
var createHarfBuzz=(()=>{var _scriptName=typeof document!="undefined"?document.currentScript?.src:undefined;return async function(moduleArg={}){var moduleRtn;var Module=moduleArg;var ENVIRONMENT_IS_WEB=typeof window=="object";var ENVIRONMENT_IS_WORKER=typeof WorkerGlobalScope!="undefined";var ENVIRONMENT_IS_NODE=typeof process=="object"&&process.versions?.node&&process.type!="renderer";var arguments_=[];var thisProgram="./this.program";var quit_=(status,toThrow)=>{throw toThrow};if(typeof __filename!="undefined"){_scriptName=__filename}else if(ENVIRONMENT_IS_WORKER){_scriptName=self.location.href}var scriptDirectory="";function locateFile(path){if(Module["locateFile"]){return Module["locateFile"](path,scriptDirectory)}return scriptDirectory+path}var readAsync,readBinary;if(ENVIRONMENT_IS_NODE){var fs=require("fs");scriptDirectory=__dirname+"/";readBinary=filename=>{filename=isFileURI(filename)?new URL(filename):filename;var ret=fs.readFileSync(filename);return ret};readAsync=async(filename,binary=true)=>{filename=isFileURI(filename)?new URL(filename):filename;var ret=fs.readFileSync(filename,binary?undefined:"utf8");return ret};if(process.argv.length>1){thisProgram=process.argv[1].replace(/\\/g,"/")}arguments_=process.argv.slice(2);quit_=(status,toThrow)=>{process.exitCode=status;throw toThrow}}else if(ENVIRONMENT_IS_WEB||ENVIRONMENT_IS_WORKER){try{scriptDirectory=new URL(".",_scriptName).href}catch{}{if(ENVIRONMENT_IS_WORKER){readBinary=url=>{var xhr=new XMLHttpRequest;xhr.open("GET",url,false);xhr.responseType="arraybuffer";xhr.send(null);return new Uint8Array(xhr.response)}}readAsync=async url=>{if(isFileURI(url)){return new Promise((resolve,reject)=>{var xhr=new XMLHttpRequest;xhr.open("GET",url,true);xhr.responseType="arraybuffer";xhr.onload=()=>{if(xhr.status==200||xhr.status==0&&xhr.response){resolve(xhr.response);return}reject(xhr.status)};xhr.onerror=reject;xhr.send(null)})}var response=await fetch(url,{credentials:"same-origin"});if(response.ok){return response.arrayBuffer()}throw new Error(response.status+" : "+response.url)}}}else{}var out=console.log.bind(console);var err=console.error.bind(console);var wasmBinary;var ABORT=false;var EXITSTATUS;var isFileURI=filename=>filename.startsWith("file://");var readyPromiseResolve,readyPromiseReject;var wasmMemory;var HEAP8,HEAPU8,HEAP16,HEAPU16,HEAP32,HEAPU32,HEAPF32,HEAPF64;var HEAP64,HEAPU64;var runtimeInitialized=false;function updateMemoryViews(){var b=wasmMemory.buffer;HEAP8=new Int8Array(b);HEAP16=new Int16Array(b);HEAPU8=new Uint8Array(b);HEAPU16=new Uint16Array(b);HEAP32=new Int32Array(b);HEAPU32=new Uint32Array(b);HEAPF32=new Float32Array(b);HEAPF64=new Float64Array(b);HEAP64=new BigInt64Array(b);HEAPU64=new BigUint64Array(b)}function preRun(){if(Module["preRun"]){if(typeof Module["preRun"]=="function")Module["preRun"]=[Module["preRun"]];while(Module["preRun"].length){addOnPreRun(Module["preRun"].shift())}}callRuntimeCallbacks(onPreRuns)}function initRuntime(){runtimeInitialized=true;wasmExports["__wasm_call_ctors"]()}function postRun(){if(Module["postRun"]){if(typeof Module["postRun"]=="function")Module["postRun"]=[Module["postRun"]];while(Module["postRun"].length){addOnPostRun(Module["postRun"].shift())}}callRuntimeCallbacks(onPostRuns)}var runDependencies=0;var dependenciesFulfilled=null;function addRunDependency(id){runDependencies++;Module["monitorRunDependencies"]?.(runDependencies)}function removeRunDependency(id){runDependencies--;Module["monitorRunDependencies"]?.(runDependencies);if(runDependencies==0){if(dependenciesFulfilled){var callback=dependenciesFulfilled;dependenciesFulfilled=null;callback()}}}function abort(what){Module["onAbort"]?.(what);what="Aborted("+what+")";err(what);ABORT=true;what+=". Build with -sASSERTIONS for more info.";var e=new WebAssembly.RuntimeError(what);readyPromiseReject?.(e);throw e}var wasmBinaryFile;function findWasmBinary(){return locateFile("hb.wasm")}function getBinarySync(file){if(file==wasmBinaryFile&&wasmBinary){return new Uint8Array(wasmBinary)}if(readBinary){return readBinary(file)}throw"both async and sync fetching of the wasm failed"}async function getWasmBinary(binaryFile){if(!wasmBinary){try{var response=await readAsync(binaryFile);return new Uint8Array(response)}catch{}}return getBinarySync(binaryFile)}async function instantiateArrayBuffer(binaryFile,imports){try{var binary=await getWasmBinary(binaryFile);var instance=await WebAssembly.instantiate(binary,imports);return instance}catch(reason){err(`failed to asynchronously prepare wasm: ${reason}`);abort(reason)}}async function instantiateAsync(binary,binaryFile,imports){if(!binary&&typeof WebAssembly.instantiateStreaming=="function"&&!isFileURI(binaryFile)&&!ENVIRONMENT_IS_NODE){try{var response=fetch(binaryFile,{credentials:"same-origin"});var instantiationResult=await WebAssembly.instantiateStreaming(response,imports);return instantiationResult}catch(reason){err(`wasm streaming compile failed: ${reason}`);err("falling back to ArrayBuffer instantiation")}}return instantiateArrayBuffer(binaryFile,imports)}function getWasmImports(){return{env:wasmImports,wasi_snapshot_preview1:wasmImports}}async function createWasm(){function receiveInstance(instance,module){wasmExports=instance.exports;Module["wasmExports"]=wasmExports;wasmMemory=wasmExports["memory"];Module["wasmMemory"]=wasmMemory;updateMemoryViews();wasmTable=wasmExports["__indirect_function_table"];assignWasmExports(wasmExports);removeRunDependency("wasm-instantiate");return wasmExports}addRunDependency("wasm-instantiate");function receiveInstantiationResult(result){return receiveInstance(result["instance"])}var info=getWasmImports();if(Module["instantiateWasm"]){return new Promise((resolve,reject)=>{Module["instantiateWasm"](info,(mod,inst)=>{resolve(receiveInstance(mod,inst))})})}wasmBinaryFile??=findWasmBinary();var result=await instantiateAsync(wasmBinary,wasmBinaryFile,info);var exports=receiveInstantiationResult(result);return exports}class ExitStatus{name="ExitStatus";constructor(status){this.message=`Program terminated with exit(${status})`;this.status=status}}var callRuntimeCallbacks=callbacks=>{while(callbacks.length>0){callbacks.shift()(Module)}};var onPostRuns=[];var addOnPostRun=cb=>onPostRuns.push(cb);var onPreRuns=[];var addOnPreRun=cb=>onPreRuns.push(cb);var noExitRuntime=true;var __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)};{if(Module["noExitRuntime"])noExitRuntime=Module["noExitRuntime"];if(Module["print"])out=Module["print"];if(Module["printErr"])err=Module["printErr"];if(Module["wasmBinary"])wasmBinary=Module["wasmBinary"];if(Module["arguments"])arguments_=Module["arguments"];if(Module["thisProgram"])thisProgram=Module["thisProgram"]}Module["wasmMemory"]=wasmMemory;Module["wasmExports"]=wasmExports;Module["addFunction"]=addFunction;Module["removeFunction"]=removeFunction;var _hb_blob_create,_hb_blob_destroy,_hb_blob_get_length,_hb_blob_get_data,_hb_buffer_serialize_glyphs,_hb_buffer_create,_hb_buffer_destroy,_hb_buffer_get_content_type,_hb_buffer_set_direction,_hb_buffer_set_script,_hb_buffer_set_language,_hb_buffer_set_flags,_hb_buffer_set_cluster_level,_hb_buffer_get_length,_hb_buffer_get_glyph_infos,_hb_buffer_get_glyph_positions,_hb_glyph_info_get_glyph_flags,_hb_buffer_guess_segment_properties,_hb_buffer_add_utf8,_hb_buffer_add_utf16,_hb_buffer_set_message_func,_hb_language_from_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_draw_glyph,_hb_font_glyph_to_string,_hb_font_create,_hb_font_set_variations,_hb_font_destroy,_hb_font_set_scale,_hb_set_create,_hb_set_destroy,_hb_ot_var_get_axis_infos,_hb_set_get_population,_hb_set_next_many,_hb_shape,__emscripten_timeout;function assignWasmExports(wasmExports){Module["_hb_blob_create"]=_hb_blob_create=wasmExports["hb_blob_create"];Module["_hb_blob_destroy"]=_hb_blob_destroy=wasmExports["hb_blob_destroy"];Module["_hb_blob_get_length"]=_hb_blob_get_length=wasmExports["hb_blob_get_length"];Module["_hb_blob_get_data"]=_hb_blob_get_data=wasmExports["hb_blob_get_data"];Module["_hb_buffer_serialize_glyphs"]=_hb_buffer_serialize_glyphs=wasmExports["hb_buffer_serialize_glyphs"];Module["_hb_buffer_create"]=_hb_buffer_create=wasmExports["hb_buffer_create"];Module["_hb_buffer_destroy"]=_hb_buffer_destroy=wasmExports["hb_buffer_destroy"];Module["_hb_buffer_get_content_type"]=_hb_buffer_get_content_type=wasmExports["hb_buffer_get_content_type"];Module["_hb_buffer_set_direction"]=_hb_buffer_set_direction=wasmExports["hb_buffer_set_direction"];Module["_hb_buffer_set_script"]=_hb_buffer_set_script=wasmExports["hb_buffer_set_script"];Module["_hb_buffer_set_language"]=_hb_buffer_set_language=wasmExports["hb_buffer_set_language"];Module["_hb_buffer_set_flags"]=_hb_buffer_set_flags=wasmExports["hb_buffer_set_flags"];Module["_hb_buffer_set_cluster_level"]=_hb_buffer_set_cluster_level=wasmExports["hb_buffer_set_cluster_level"];Module["_hb_buffer_get_length"]=_hb_buffer_get_length=wasmExports["hb_buffer_get_length"];Module["_hb_buffer_get_glyph_infos"]=_hb_buffer_get_glyph_infos=wasmExports["hb_buffer_get_glyph_infos"];Module["_hb_buffer_get_glyph_positions"]=_hb_buffer_get_glyph_positions=wasmExports["hb_buffer_get_glyph_positions"];Module["_hb_glyph_info_get_glyph_flags"]=_hb_glyph_info_get_glyph_flags=wasmExports["hb_glyph_info_get_glyph_flags"];Module["_hb_buffer_guess_segment_properties"]=_hb_buffer_guess_segment_properties=wasmExports["hb_buffer_guess_segment_properties"];Module["_hb_buffer_add_utf8"]=_hb_buffer_add_utf8=wasmExports["hb_buffer_add_utf8"];Module["_hb_buffer_add_utf16"]=_hb_buffer_add_utf16=wasmExports["hb_buffer_add_utf16"];Module["_hb_buffer_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_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_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_destroy"]=_hb_font_destroy=wasmExports["hb_font_destroy"];Module["_hb_font_set_scale"]=_hb_font_set_scale=wasmExports["hb_font_set_scale"];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_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"]}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
|
+
;return moduleRtn}})();if(typeof exports==="object"&&typeof module==="object"){module.exports=createHarfBuzz;module.exports.default=createHarfBuzz}else if(typeof define==="function"&&define["amd"])define([],()=>createHarfBuzz);
|
package/hb.symbols
CHANGED
package/hb.wasm
CHANGED
|
Binary file
|
package/hbjs.js
CHANGED
|
@@ -2,12 +2,9 @@ function hbjs(Module) {
|
|
|
2
2
|
'use strict';
|
|
3
3
|
|
|
4
4
|
var exports = Module.wasmExports;
|
|
5
|
-
var heapu8 = Module.HEAPU8;
|
|
6
|
-
var heapu32 = Module.HEAPU32;
|
|
7
|
-
var heapi32 = Module.HEAP32;
|
|
8
|
-
var heapf32 = Module.HEAPF32;
|
|
9
5
|
var utf8Decoder = new TextDecoder("utf8");
|
|
10
6
|
let addFunction = Module.addFunction;
|
|
7
|
+
let removeFunction = Module.removeFunction;
|
|
11
8
|
|
|
12
9
|
var freeFuncPtr = addFunction(function (ptr) { exports.free(ptr); }, 'vi');
|
|
13
10
|
|
|
@@ -55,7 +52,7 @@ function hbjs(Module) {
|
|
|
55
52
|
**/
|
|
56
53
|
function createBlob(blob) {
|
|
57
54
|
var blobPtr = exports.malloc(blob.byteLength);
|
|
58
|
-
|
|
55
|
+
Module.HEAPU8.set(new Uint8Array(blob), blobPtr);
|
|
59
56
|
var ptr = exports.hb_blob_create(blobPtr, blob.byteLength, HB_MEMORY_MODE_WRITABLE, blobPtr, freeFuncPtr);
|
|
60
57
|
return {
|
|
61
58
|
ptr: ptr,
|
|
@@ -68,37 +65,16 @@ function hbjs(Module) {
|
|
|
68
65
|
|
|
69
66
|
/**
|
|
70
67
|
* Return the typed array of HarfBuzz set contents.
|
|
71
|
-
* @template {typeof Uint8Array | typeof Uint32Array | typeof Int32Array | typeof Float32Array} T
|
|
72
68
|
* @param {number} setPtr Pointer of set
|
|
73
|
-
* @
|
|
74
|
-
* @returns {InstanceType<T>} Typed array instance
|
|
69
|
+
* @returns {Uint32Array} Typed array instance
|
|
75
70
|
*/
|
|
76
|
-
function typedArrayFromSet(setPtr
|
|
77
|
-
let heap = heapu8;
|
|
78
|
-
if (arrayClass === Uint32Array) {
|
|
79
|
-
heap = heapu32;
|
|
80
|
-
} else if (arrayClass === Int32Array) {
|
|
81
|
-
heap = heapi32;
|
|
82
|
-
} else if (arrayClass === Float32Array) {
|
|
83
|
-
heap = heapf32;
|
|
84
|
-
}
|
|
85
|
-
const bytesPerElment = arrayClass.BYTES_PER_ELEMENT;
|
|
71
|
+
function typedArrayFromSet(setPtr) {
|
|
86
72
|
const setCount = exports.hb_set_get_population(setPtr);
|
|
87
|
-
const arrayPtr = exports.malloc(
|
|
88
|
-
|
|
89
|
-
);
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
arrayOffset,
|
|
93
|
-
arrayOffset + setCount,
|
|
94
|
-
);
|
|
95
|
-
heap.set(array, arrayOffset);
|
|
96
|
-
exports.hb_set_next_many(
|
|
97
|
-
setPtr,
|
|
98
|
-
HB_SET_VALUE_INVALID,
|
|
99
|
-
arrayPtr,
|
|
100
|
-
setCount,
|
|
101
|
-
);
|
|
73
|
+
const arrayPtr = exports.malloc(setCount << 2);
|
|
74
|
+
const arrayOffset = arrayPtr >> 2;
|
|
75
|
+
const array = Module.HEAPU32.subarray(arrayOffset, arrayOffset + setCount);
|
|
76
|
+
Module.HEAPU32.set(array, arrayOffset);
|
|
77
|
+
exports.hb_set_next_many(setPtr, HB_SET_VALUE_INVALID, arrayPtr, setCount);
|
|
102
78
|
return array;
|
|
103
79
|
}
|
|
104
80
|
|
|
@@ -123,7 +99,7 @@ function hbjs(Module) {
|
|
|
123
99
|
var length = exports.hb_blob_get_length(blob);
|
|
124
100
|
if (!length) { return; }
|
|
125
101
|
var blobptr = exports.hb_blob_get_data(blob, null);
|
|
126
|
-
var table_string =
|
|
102
|
+
var table_string = Module.HEAPU8.subarray(blobptr, blobptr+length);
|
|
127
103
|
return table_string;
|
|
128
104
|
},
|
|
129
105
|
/**
|
|
@@ -132,14 +108,14 @@ function hbjs(Module) {
|
|
|
132
108
|
getAxisInfos: function() {
|
|
133
109
|
var axis = exports.malloc(64 * 32);
|
|
134
110
|
var c = exports.malloc(4);
|
|
135
|
-
|
|
111
|
+
Module.HEAPU32[c / 4] = 64;
|
|
136
112
|
exports.hb_ot_var_get_axis_infos(ptr, 0, c, axis);
|
|
137
113
|
var result = {};
|
|
138
|
-
Array.from({ length:
|
|
139
|
-
result[_hb_untag(
|
|
140
|
-
min:
|
|
141
|
-
default:
|
|
142
|
-
max:
|
|
114
|
+
Array.from({ length: Module.HEAPU32[c / 4] }).forEach(function (_, i) {
|
|
115
|
+
result[_hb_untag(Module.HEAPU32[axis / 4 + i * 8 + 1])] = {
|
|
116
|
+
min: Module.HEAPF32[axis / 4 + i * 8 + 4],
|
|
117
|
+
default: Module.HEAPF32[axis / 4 + i * 8 + 5],
|
|
118
|
+
max: Module.HEAPF32[axis / 4 + i * 8 + 6]
|
|
143
119
|
};
|
|
144
120
|
});
|
|
145
121
|
exports.free(c);
|
|
@@ -152,7 +128,7 @@ function hbjs(Module) {
|
|
|
152
128
|
collectUnicodes: function() {
|
|
153
129
|
var unicodeSetPtr = exports.hb_set_create();
|
|
154
130
|
exports.hb_face_collect_unicodes(ptr, unicodeSetPtr);
|
|
155
|
-
var result = typedArrayFromSet(unicodeSetPtr
|
|
131
|
+
var result = typedArrayFromSet(unicodeSetPtr);
|
|
156
132
|
exports.hb_set_destroy(unicodeSetPtr);
|
|
157
133
|
return result;
|
|
158
134
|
},
|
|
@@ -177,6 +153,11 @@ function hbjs(Module) {
|
|
|
177
153
|
function createFont(face) {
|
|
178
154
|
var ptr = exports.hb_font_create(face.ptr);
|
|
179
155
|
var drawFuncsPtr = null;
|
|
156
|
+
var moveToPtr = null;
|
|
157
|
+
var lineToPtr = null;
|
|
158
|
+
var cubicToPtr = null;
|
|
159
|
+
var quadToPtr = null;
|
|
160
|
+
var closePathPtr = null;
|
|
180
161
|
|
|
181
162
|
/**
|
|
182
163
|
* Return a glyph as an SVG path string.
|
|
@@ -200,11 +181,11 @@ function hbjs(Module) {
|
|
|
200
181
|
pathBuffer += 'Z';
|
|
201
182
|
}
|
|
202
183
|
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
184
|
+
moveToPtr = addFunction(moveTo, 'viiiffi');
|
|
185
|
+
lineToPtr = addFunction(lineTo, 'viiiffi');
|
|
186
|
+
cubicToPtr = addFunction(cubicTo, 'viiiffffffi');
|
|
187
|
+
quadToPtr = addFunction(quadTo, 'viiiffffi');
|
|
188
|
+
closePathPtr = addFunction(closePath, 'viiii');
|
|
208
189
|
drawFuncsPtr = exports.hb_draw_funcs_create();
|
|
209
190
|
exports.hb_draw_funcs_set_move_to_func(drawFuncsPtr, moveToPtr, 0, 0);
|
|
210
191
|
exports.hb_draw_funcs_set_line_to_func(drawFuncsPtr, lineToPtr, 0, 0);
|
|
@@ -229,7 +210,7 @@ function hbjs(Module) {
|
|
|
229
210
|
nameBuffer,
|
|
230
211
|
nameBufferSize
|
|
231
212
|
);
|
|
232
|
-
var array =
|
|
213
|
+
var array = Module.HEAPU8.subarray(nameBuffer, nameBuffer + nameBufferSize);
|
|
233
214
|
return utf8Decoder.decode(array.slice(0, array.indexOf(0)));
|
|
234
215
|
}
|
|
235
216
|
|
|
@@ -266,8 +247,8 @@ function hbjs(Module) {
|
|
|
266
247
|
var entries = Object.entries(variations);
|
|
267
248
|
var vars = exports.malloc(8 * entries.length);
|
|
268
249
|
entries.forEach(function (entry, i) {
|
|
269
|
-
|
|
270
|
-
|
|
250
|
+
Module.HEAPU32[vars / 4 + i * 2 + 0] = hb_tag(entry[0]);
|
|
251
|
+
Module.HEAPF32[vars / 4 + i * 2 + 1] = entry[1];
|
|
271
252
|
});
|
|
272
253
|
exports.hb_font_set_variations(ptr, vars, entries.length);
|
|
273
254
|
exports.free(vars);
|
|
@@ -275,7 +256,18 @@ function hbjs(Module) {
|
|
|
275
256
|
/**
|
|
276
257
|
* Free the object.
|
|
277
258
|
*/
|
|
278
|
-
destroy: function () {
|
|
259
|
+
destroy: function () {
|
|
260
|
+
exports.hb_font_destroy(ptr);
|
|
261
|
+
if (drawFuncsPtr) {
|
|
262
|
+
exports.hb_draw_funcs_destroy(drawFuncsPtr);
|
|
263
|
+
drawFuncsPtr = null;
|
|
264
|
+
removeFunction(moveToPtr);
|
|
265
|
+
removeFunction(lineToPtr);
|
|
266
|
+
removeFunction(cubicToPtr);
|
|
267
|
+
removeFunction(quadToPtr);
|
|
268
|
+
removeFunction(closePathPtr);
|
|
269
|
+
}
|
|
270
|
+
}
|
|
279
271
|
};
|
|
280
272
|
}
|
|
281
273
|
|
|
@@ -288,9 +280,9 @@ function hbjs(Module) {
|
|
|
288
280
|
for (let i = 0; i < text.length; ++i) {
|
|
289
281
|
const char = text.charCodeAt(i);
|
|
290
282
|
if (char > 127) throw new Error('Expected ASCII text');
|
|
291
|
-
|
|
283
|
+
Module.HEAPU8[ptr + i] = char;
|
|
292
284
|
}
|
|
293
|
-
|
|
285
|
+
Module.HEAPU8[ptr + text.length] = 0;
|
|
294
286
|
return {
|
|
295
287
|
ptr: ptr,
|
|
296
288
|
length: text.length,
|
|
@@ -412,8 +404,8 @@ function hbjs(Module) {
|
|
|
412
404
|
var infosPtr = exports.hb_buffer_get_glyph_infos(ptr, 0);
|
|
413
405
|
var infosPtr32 = infosPtr / 4;
|
|
414
406
|
var positionsPtr32 = exports.hb_buffer_get_glyph_positions(ptr, 0) / 4;
|
|
415
|
-
var infos =
|
|
416
|
-
var positions =
|
|
407
|
+
var infos = Module.HEAPU32.subarray(infosPtr32, infosPtr32 + 5 * length);
|
|
408
|
+
var positions = Module.HEAP32.subarray(positionsPtr32, positionsPtr32 + 5 * length);
|
|
417
409
|
for (var i = 0; i < length; ++i) {
|
|
418
410
|
result.push({
|
|
419
411
|
g: infos[i * 5 + 0],
|
|
@@ -490,7 +482,7 @@ function hbjs(Module) {
|
|
|
490
482
|
var traceBufPtr = exports.malloc(traceBufLen);
|
|
491
483
|
|
|
492
484
|
var traceFunc = function (bufferPtr, fontPtr, messagePtr, user_data) {
|
|
493
|
-
var message = utf8Decoder.decode(
|
|
485
|
+
var message = utf8Decoder.decode(Module.HEAPU8.subarray(messagePtr, Module.HEAPU8.indexOf(0, messagePtr)));
|
|
494
486
|
if (message.startsWith("start table GSUB"))
|
|
495
487
|
currentPhase = GSUB_PHASE;
|
|
496
488
|
else if (message.startsWith("start table GPOS"))
|
|
@@ -518,7 +510,7 @@ function hbjs(Module) {
|
|
|
518
510
|
|
|
519
511
|
trace.push({
|
|
520
512
|
m: message,
|
|
521
|
-
t: JSON.parse(utf8Decoder.decode(
|
|
513
|
+
t: JSON.parse(utf8Decoder.decode(Module.HEAPU8.subarray(traceBufPtr, Module.HEAPU8.indexOf(0, traceBufPtr)))),
|
|
522
514
|
glyphs: exports.hb_buffer_get_content_type(bufferPtr) == HB_BUFFER_CONTENT_TYPE_GLYPHS,
|
|
523
515
|
});
|
|
524
516
|
|
|
@@ -529,6 +521,7 @@ function hbjs(Module) {
|
|
|
529
521
|
exports.hb_buffer_set_message_func(buffer.ptr, traceFuncPtr, 0, 0);
|
|
530
522
|
shape(font, buffer, features, 0);
|
|
531
523
|
exports.free(traceBufPtr);
|
|
524
|
+
removeFunction(traceFuncPtr);
|
|
532
525
|
|
|
533
526
|
return trace;
|
|
534
527
|
}
|
|
@@ -537,9 +530,9 @@ function hbjs(Module) {
|
|
|
537
530
|
var versionPtr = exports.malloc(12);
|
|
538
531
|
exports.hb_version(versionPtr, versionPtr + 4, versionPtr + 8);
|
|
539
532
|
var version = {
|
|
540
|
-
major:
|
|
541
|
-
minor:
|
|
542
|
-
micro:
|
|
533
|
+
major: Module.HEAPU32[versionPtr / 4],
|
|
534
|
+
minor: Module.HEAPU32[(versionPtr + 4) / 4],
|
|
535
|
+
micro: Module.HEAPU32[(versionPtr + 8) / 4],
|
|
543
536
|
};
|
|
544
537
|
exports.free(versionPtr);
|
|
545
538
|
return version;
|
|
@@ -547,7 +540,7 @@ function hbjs(Module) {
|
|
|
547
540
|
|
|
548
541
|
function version_string() {
|
|
549
542
|
var versionPtr = exports.hb_version_string();
|
|
550
|
-
var version = utf8Decoder.decode(
|
|
543
|
+
var version = utf8Decoder.decode(Module.HEAPU8.subarray(versionPtr, Module.HEAPU8.indexOf(0, versionPtr)));
|
|
551
544
|
return version;
|
|
552
545
|
}
|
|
553
546
|
|
package/package.json
CHANGED
package/test/index.js
CHANGED
|
@@ -2,183 +2,182 @@ const fs = require('fs');
|
|
|
2
2
|
const path = require('path');
|
|
3
3
|
const { expect } = require('chai');
|
|
4
4
|
let hb;
|
|
5
|
+
let blob, face, font, buffer;
|
|
5
6
|
|
|
6
7
|
before(async function () {
|
|
7
8
|
hb = await require('..');
|
|
8
9
|
});
|
|
9
10
|
|
|
10
11
|
afterEach(function () {
|
|
11
|
-
if (
|
|
12
|
-
if (
|
|
13
|
-
if (
|
|
14
|
-
if (
|
|
15
|
-
|
|
12
|
+
if (blob) blob.destroy();
|
|
13
|
+
if (face) face.destroy();
|
|
14
|
+
if (font) font.destroy();
|
|
15
|
+
if (buffer) buffer.destroy();
|
|
16
|
+
blob = face = font = buffer = undefined;
|
|
16
17
|
});
|
|
17
18
|
|
|
18
19
|
describe('Face', function () {
|
|
19
20
|
it('collectUnicodes reflects codepoints supported by the font', function () {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
const codepoints = [...
|
|
21
|
+
blob = hb.createBlob(fs.readFileSync(path.join(__dirname, 'fonts/noto/NotoSans-Regular.ttf')));
|
|
22
|
+
face = hb.createFace(blob);
|
|
23
|
+
const codepoints = [...face.collectUnicodes()];
|
|
23
24
|
expect(codepoints).to.include('a'.codePointAt(0));
|
|
24
25
|
expect(codepoints).not.to.include('ا'.codePointAt(0));
|
|
25
|
-
this.face.destroy();
|
|
26
|
-
this.blob.destroy();
|
|
27
26
|
});
|
|
28
27
|
|
|
29
28
|
it('exposes upem', function () {
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
expect(
|
|
29
|
+
blob = hb.createBlob(fs.readFileSync(path.join(__dirname, 'fonts/noto/NotoSans-Regular.ttf')));
|
|
30
|
+
face = hb.createFace(blob);
|
|
31
|
+
expect(face.upem).to.equal(1000);
|
|
33
32
|
});
|
|
34
33
|
|
|
35
34
|
it('getAxisInfos returns details of a variable font', function () {
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
expect(
|
|
35
|
+
blob = hb.createBlob(fs.readFileSync(path.join(__dirname, 'fonts/noto/NotoSansArabic-Variable.ttf')));
|
|
36
|
+
face = hb.createFace(blob);
|
|
37
|
+
expect(face.getAxisInfos()).to.deep.equal({
|
|
39
38
|
wght: { min: 100, default: 400, max: 900 },
|
|
40
39
|
wdth: { min: 62.5, default: 100, max: 100 }
|
|
41
40
|
});
|
|
42
41
|
});
|
|
43
42
|
|
|
44
43
|
it('getAxisInfos returns an empty object for a non-variable font', function () {
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
expect(Object.keys(
|
|
44
|
+
blob = hb.createBlob(fs.readFileSync(path.join(__dirname, 'fonts/noto/NotoSans-Regular.ttf')));
|
|
45
|
+
face = hb.createFace(blob);
|
|
46
|
+
expect(Object.keys(face.getAxisInfos())).to.have.lengthOf(0);
|
|
48
47
|
});
|
|
49
48
|
});
|
|
50
49
|
|
|
51
50
|
describe('Font', function () {
|
|
52
51
|
it('glyphName returns names for glyph ids', function () {
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
expect(
|
|
52
|
+
blob = hb.createBlob(fs.readFileSync(path.join(__dirname, 'fonts/noto/NotoSans-Regular.ttf')));
|
|
53
|
+
face = hb.createFace(blob);
|
|
54
|
+
font = hb.createFont(face);
|
|
55
|
+
expect(font.glyphName(20)).to.equal('one');
|
|
57
56
|
});
|
|
58
57
|
|
|
59
58
|
it('setScale affects advances', function () {
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
hb.shape(
|
|
68
|
-
const glyphs =
|
|
59
|
+
blob = hb.createBlob(fs.readFileSync(path.join(__dirname, 'fonts/noto/NotoSans-Regular.ttf')));
|
|
60
|
+
face = hb.createFace(blob);
|
|
61
|
+
font = hb.createFont(face);
|
|
62
|
+
buffer = hb.createBuffer();
|
|
63
|
+
buffer.addText('a');
|
|
64
|
+
buffer.guessSegmentProperties();
|
|
65
|
+
font.setScale(1000 * 2, 1000 * 2);
|
|
66
|
+
hb.shape(font, buffer)
|
|
67
|
+
const glyphs = buffer.json();
|
|
69
68
|
expect(glyphs[0].ax).to.equal(561 * 2);
|
|
70
69
|
});
|
|
71
70
|
|
|
72
71
|
it('setVariations affects advances', function () {
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
hb.shape(
|
|
81
|
-
const glyphs =
|
|
72
|
+
blob = hb.createBlob(fs.readFileSync(path.join(__dirname, 'fonts/noto/NotoSansArabic-Variable.ttf')));
|
|
73
|
+
face = hb.createFace(blob);
|
|
74
|
+
font = hb.createFont(face);
|
|
75
|
+
font.setVariations({ 'wght': 789 });
|
|
76
|
+
buffer = hb.createBuffer();
|
|
77
|
+
buffer.addText('آلو');
|
|
78
|
+
buffer.guessSegmentProperties();
|
|
79
|
+
hb.shape(font, buffer)
|
|
80
|
+
const glyphs = buffer.json();
|
|
82
81
|
expect(glyphs[0].ax).to.equal(526);
|
|
83
82
|
});
|
|
84
83
|
|
|
85
84
|
it('glyphToPath converts quadratic glyph to path', function () {
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
85
|
+
blob = hb.createBlob(fs.readFileSync(path.join(__dirname, 'fonts/noto/NotoSans-Regular.ttf')));
|
|
86
|
+
face = hb.createFace(blob);
|
|
87
|
+
font = hb.createFont(face);
|
|
89
88
|
const expected21 = 'M520,0L48,0L48,73L235,262Q289,316 326,358Q363,400 382,440.5Q401,481 401,529Q401,\
|
|
90
89
|
588 366,618.5Q331,649 275,649Q223,649 183.5,631Q144,613 103,581L56,640Q98,675 152.5,699.5Q207,724 275,\
|
|
91
90
|
724Q375,724 433,673.5Q491,623 491,534Q491,478 468,429Q445,380 404,332.5Q363,285 308,231L159,84L159,80L520,80L520,0Z';
|
|
92
|
-
expect(
|
|
91
|
+
expect(font.glyphToPath(21)).to.equal(expected21);
|
|
93
92
|
const expected22 = 'M493,547Q493,475 453,432.5Q413,390 345,376L345,372Q431,362 473,318Q515,274 515,203Q515,\
|
|
94
93
|
141 486,92.5Q457,44 396.5,17Q336,-10 241,-10Q185,-10 137,-1.5Q89,7 45,29L45,111Q90,89 142,76.5Q194,64 242,64Q338,\
|
|
95
94
|
64 380.5,101.5Q423,139 423,205Q423,272 370.5,301.5Q318,331 223,331L154,331L154,406L224,406Q312,406 357.5,443Q403,\
|
|
96
95
|
480 403,541Q403,593 368,621.5Q333,650 273,650Q215,650 174,633Q133,616 93,590L49,650Q87,680 143.5,702Q200,724 272,\
|
|
97
96
|
724Q384,724 438.5,674Q493,624 493,547Z';
|
|
98
|
-
expect(
|
|
97
|
+
expect(font.glyphToPath(22)).to.equal(expected22);
|
|
99
98
|
});
|
|
100
99
|
|
|
101
100
|
it('glyphToPath converts cubic glyph to path', function () {
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
101
|
+
blob = hb.createBlob(fs.readFileSync(path.join(__dirname, 'fonts/noto/NotoSans-Regular.otf')));
|
|
102
|
+
face = hb.createFace(blob);
|
|
103
|
+
font = hb.createFont(face);
|
|
105
104
|
const expected21 = 'M520,0L520,80L159,80L159,84L308,231C418,338 491,422 491,534C491,652 408,724 275,724C184,724 112,\
|
|
106
105
|
687 56,640L103,581C158,624 205,649 275,649C350,649 401,607 401,529C401,432 342,370 235,262L48,73L48,0L520,0Z';
|
|
107
|
-
expect(
|
|
106
|
+
expect(font.glyphToPath(21)).to.equal(expected21);
|
|
108
107
|
const expected22 = 'M493,547C493,649 421,724 272,724C176,724 100,690 49,650L93,590C146,625 196,650 273,650C353,\
|
|
109
108
|
650 403,610 403,541C403,460 341,406 224,406L154,406L154,331L223,331C349,331 423,294 423,205C423,117 370,64 242,64C178,\
|
|
110
109
|
64 105,81 45,111L45,29C104,0 166,-10 241,-10C430,-10 515,78 515,203C515,297 459,358 345,372L345,376C435,394 493,451 493,547Z';
|
|
111
|
-
expect(
|
|
110
|
+
expect(font.glyphToPath(22)).to.equal(expected22);
|
|
112
111
|
});
|
|
113
112
|
});
|
|
114
113
|
|
|
115
114
|
describe('Buffer', function () {
|
|
116
115
|
it('setDirection controls direction of glyphs', function () {
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
hb.shape(
|
|
124
|
-
const glyphs =
|
|
116
|
+
blob = hb.createBlob(fs.readFileSync(path.join(__dirname, 'fonts/noto/NotoSans-Regular.ttf')));
|
|
117
|
+
face = hb.createFace(blob);
|
|
118
|
+
font = hb.createFont(face);
|
|
119
|
+
buffer = hb.createBuffer();
|
|
120
|
+
buffer.addText('rtl');
|
|
121
|
+
buffer.setDirection('rtl');
|
|
122
|
+
hb.shape(font, buffer)
|
|
123
|
+
const glyphs = buffer.json();
|
|
125
124
|
expect(glyphs[0].g).to.equal(79); // l
|
|
126
125
|
expect(glyphs[1].g).to.equal(87); // t
|
|
127
126
|
expect(glyphs[2].g).to.equal(85); // r
|
|
128
127
|
});
|
|
129
128
|
|
|
130
129
|
it('setClusterLevel affects cluster merging', function () {
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
hb.shape(
|
|
139
|
-
const glyphs =
|
|
130
|
+
blob = hb.createBlob(fs.readFileSync(path.join(__dirname, 'fonts/noto/NotoSans-Regular.ttf')));
|
|
131
|
+
face = hb.createFace(blob);
|
|
132
|
+
font = hb.createFont(face);
|
|
133
|
+
buffer = hb.createBuffer();
|
|
134
|
+
buffer.setClusterLevel(1);
|
|
135
|
+
buffer.addText('x́');
|
|
136
|
+
buffer.guessSegmentProperties();
|
|
137
|
+
hb.shape(font, buffer)
|
|
138
|
+
const glyphs = buffer.json();
|
|
140
139
|
expect(glyphs[0].cl).to.equal(0);
|
|
141
140
|
expect(glyphs[1].cl).to.equal(1);
|
|
142
141
|
});
|
|
143
142
|
|
|
144
143
|
it('setFlags with PRESERVE_DEFAULT_IGNORABLES affects glyph ids', function () {
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
hb.shape(
|
|
153
|
-
const glyphs =
|
|
144
|
+
blob = hb.createBlob(fs.readFileSync(path.join(__dirname, 'fonts/noto/NotoSans-Regular.ttf')));
|
|
145
|
+
face = hb.createFace(blob);
|
|
146
|
+
font = hb.createFont(face);
|
|
147
|
+
buffer = hb.createBuffer();
|
|
148
|
+
buffer.addText('\u200dhi');
|
|
149
|
+
buffer.setFlags(['PRESERVE_DEFAULT_IGNORABLES']);
|
|
150
|
+
buffer.guessSegmentProperties();
|
|
151
|
+
hb.shape(font, buffer)
|
|
152
|
+
const glyphs = buffer.json();
|
|
154
153
|
expect(glyphs[0].g).not.to.equal(3 /* space */);
|
|
155
154
|
});
|
|
156
155
|
});
|
|
157
156
|
|
|
158
157
|
describe('shape', function () {
|
|
159
158
|
it('shape Latin string', function () {
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
hb.shape(
|
|
167
|
-
const glyphs =
|
|
159
|
+
blob = hb.createBlob(fs.readFileSync(path.join(__dirname, 'fonts/noto/NotoSans-Regular.ttf')));
|
|
160
|
+
face = hb.createFace(blob);
|
|
161
|
+
font = hb.createFont(face);
|
|
162
|
+
buffer = hb.createBuffer();
|
|
163
|
+
buffer.addText('abc');
|
|
164
|
+
buffer.guessSegmentProperties();
|
|
165
|
+
hb.shape(font, buffer)
|
|
166
|
+
const glyphs = buffer.json();
|
|
168
167
|
expect(glyphs[0]).to.deep.equal({ cl: 0, g: 68, ax: 561, ay: 0, dx: 0, dy: 0, flags: 0 } /* a */);
|
|
169
168
|
expect(glyphs[1]).to.deep.equal({ cl: 1, g: 69, ax: 615, ay: 0, dx: 0, dy: 0, flags: 0 } /* b */);
|
|
170
169
|
expect(glyphs[2]).to.deep.equal({ cl: 2, g: 70, ax: 480, ay: 0, dx: 0, dy: 0, flags: 0 } /* c */);
|
|
171
170
|
});
|
|
172
171
|
|
|
173
172
|
it('shape Arabic string', function () {
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
hb.shape(
|
|
181
|
-
const glyphs =
|
|
173
|
+
blob = hb.createBlob(fs.readFileSync(path.join(__dirname, 'fonts/noto/NotoSansArabic-Variable.ttf')));
|
|
174
|
+
face = hb.createFace(blob);
|
|
175
|
+
font = hb.createFont(face);
|
|
176
|
+
buffer = hb.createBuffer();
|
|
177
|
+
buffer.addText('أبجد');
|
|
178
|
+
buffer.guessSegmentProperties();
|
|
179
|
+
hb.shape(font, buffer)
|
|
180
|
+
const glyphs = buffer.json();
|
|
182
181
|
expect(glyphs[0]).to.deep.equal({ cl: 3, g: 213, ax: 532, ay: 0, dx: 0, dy: 0, flags: 1 } /* د */);
|
|
183
182
|
expect(glyphs[1]).to.deep.equal({ cl: 2, g: 529, ax: 637, ay: 0, dx: 0, dy: 0, flags: 1 } /* ج */);
|
|
184
183
|
expect(glyphs[2]).to.deep.equal({ cl: 1, g: 101, ax: 269, ay: 0, dx: 0, dy: 0, flags: 0 } /* ب */);
|
|
@@ -186,13 +185,13 @@ describe('shape', function () {
|
|
|
186
185
|
});
|
|
187
186
|
|
|
188
187
|
it('shape with tracing', function () {
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
const result = hb.shapeWithTrace(
|
|
188
|
+
blob = hb.createBlob(fs.readFileSync(path.join(__dirname, 'fonts/noto/NotoSans-Regular.ttf')));
|
|
189
|
+
face = hb.createFace(blob);
|
|
190
|
+
font = hb.createFont(face);
|
|
191
|
+
buffer = hb.createBuffer();
|
|
192
|
+
buffer.addText('abc');
|
|
193
|
+
buffer.guessSegmentProperties();
|
|
194
|
+
const result = hb.shapeWithTrace(font, buffer, "", 0, 0)
|
|
196
195
|
expect(result).to.have.lengthOf(42);
|
|
197
196
|
expect(result[0]).to.deep.equal({
|
|
198
197
|
"m": "start table GSUB script tag 'latn'",
|
|
@@ -215,13 +214,13 @@ describe('shape', function () {
|
|
|
215
214
|
});
|
|
216
215
|
|
|
217
216
|
it('shape with tracing and features', function () {
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
const result = hb.shapeWithTrace(
|
|
217
|
+
blob = hb.createBlob(fs.readFileSync(path.join(__dirname, 'fonts/noto/NotoSans-Regular.ttf')));
|
|
218
|
+
face = hb.createFace(blob);
|
|
219
|
+
font = hb.createFont(face);
|
|
220
|
+
buffer = hb.createBuffer();
|
|
221
|
+
buffer.addText('fi AV');
|
|
222
|
+
buffer.guessSegmentProperties();
|
|
223
|
+
const result = hb.shapeWithTrace(font, buffer, "-liga,-kern", 0, 0)
|
|
225
224
|
expect(result).to.have.lengthOf(29);
|
|
226
225
|
expect(result[0]).to.deep.equal({
|
|
227
226
|
"m": "start table GSUB script tag 'latn'",
|
|
@@ -248,45 +247,47 @@ describe('shape', function () {
|
|
|
248
247
|
});
|
|
249
248
|
|
|
250
249
|
it('shape with 3-letter languae tag', function () {
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
hb.shape(
|
|
258
|
-
var glyphs =
|
|
250
|
+
blob = hb.createBlob(fs.readFileSync(path.join(__dirname, 'fonts/noto/NotoSansDevanagari-Regular.otf')));
|
|
251
|
+
face = hb.createFace(blob);
|
|
252
|
+
font = hb.createFont(face);
|
|
253
|
+
buffer = hb.createBuffer();
|
|
254
|
+
buffer.addText('५ल');
|
|
255
|
+
buffer.guessSegmentProperties();
|
|
256
|
+
hb.shape(font, buffer)
|
|
257
|
+
var glyphs = buffer.json();
|
|
259
258
|
expect(glyphs).to.have.lengthOf(2);
|
|
260
259
|
expect(glyphs[0].g).to.equal(118);
|
|
260
|
+
buffer.destroy();
|
|
261
261
|
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
hb.shape(
|
|
267
|
-
var glyphs =
|
|
262
|
+
buffer = hb.createBuffer();
|
|
263
|
+
buffer.addText('५ल');
|
|
264
|
+
buffer.setLanguage('dty');
|
|
265
|
+
buffer.guessSegmentProperties();
|
|
266
|
+
hb.shape(font, buffer)
|
|
267
|
+
var glyphs = buffer.json();
|
|
268
268
|
expect(glyphs).to.have.lengthOf(2);
|
|
269
269
|
expect(glyphs[0].g).to.equal(123);
|
|
270
270
|
});
|
|
271
271
|
|
|
272
272
|
it('shape with OpenType language tag', function () {
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
hb.shape(
|
|
280
|
-
var glyphs =
|
|
273
|
+
blob = hb.createBlob(fs.readFileSync(path.join(__dirname, 'fonts/noto/NotoSansDevanagari-Regular.otf')));
|
|
274
|
+
face = hb.createFace(blob);
|
|
275
|
+
font = hb.createFont(face);
|
|
276
|
+
buffer = hb.createBuffer();
|
|
277
|
+
buffer.addText('५ल');
|
|
278
|
+
buffer.guessSegmentProperties();
|
|
279
|
+
hb.shape(font, buffer)
|
|
280
|
+
var glyphs = buffer.json();
|
|
281
281
|
expect(glyphs).to.have.lengthOf(2);
|
|
282
282
|
expect(glyphs[0].g).to.equal(118);
|
|
283
|
+
buffer.destroy();
|
|
283
284
|
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
hb.shape(
|
|
289
|
-
var glyphs =
|
|
285
|
+
buffer = hb.createBuffer();
|
|
286
|
+
buffer.addText('५ल');
|
|
287
|
+
buffer.setLanguage('x-hbot-4e455020'); // 'NEP '
|
|
288
|
+
buffer.guessSegmentProperties();
|
|
289
|
+
hb.shape(font, buffer)
|
|
290
|
+
var glyphs = buffer.json();
|
|
290
291
|
expect(glyphs).to.have.lengthOf(2);
|
|
291
292
|
expect(glyphs[0].g).to.equal(123);
|
|
292
293
|
});
|