UNPKG

modern-font

Version:
1 lines 84.5 kB
(function(o,Be){typeof exports=="object"&&typeof module<"u"?Be(exports):typeof define=="function"&&define.amd?define(["exports"],Be):(o=typeof globalThis<"u"?globalThis:o||self,Be(o.modernFont={}))})(this,(function(o){"use strict";const Be="modern-font";function $e(s,e){if(!s)throw new Error(`[${Be}] ${e}`)}function hr(s){if("buffer"in s){const e=s.buffer;return s.byteOffset>0||s.byteLength<s.buffer.byteLength?e.slice(s.byteOffset,s.byteOffset+s.byteLength):e}else return s}function Ae(s){return"buffer"in s?new DataView(s.buffer,s.byteOffset,s.byteLength):new DataView(s)}function cr(s){let e="";for(let t=0,i=s.length,r;t<i;t++)r=s.charCodeAt(t),r!==0&&(e+=String.fromCharCode(r));return e}function et(s){s=cr(s);const e=[];for(let t=0,i=s.length,r;t<i;t++)r=s.charCodeAt(t),e.push(r>>8),e.push(r&255);return e}function ur(s){let e="";for(let t=0,i=s.length;t<i;t++)s[t]<127?e+=String.fromCharCode(s[t]):e+=`%${(256+s[t]).toString(16).slice(1)}`;return unescape(e)}function pr(s){let e="";for(let t=0,i=s.length;t<i;t+=2)e+=String.fromCharCode((s[t]<<8)+s[t+1]);return e}var dr=Object.defineProperty,J=(s,e,t,i)=>{for(var r=void 0,n=s.length-1,a;n>=0;n--)(a=s[n])&&(r=a(e,t,r)||r);return r&&dr(e,t,r),r};const He={int8:1,int16:2,int32:4,uint8:1,uint16:2,uint32:4,float32:4,float64:8,fixed:4,longDateTime:8,char:1};function ee(){return function(s,e){Object.defineProperty(s.constructor.prototype,e,{get(){if(typeof e=="string"){if(e.startsWith("read"))return(...t)=>this.read(e.substring(4).toLowerCase(),...t);if(e.startsWith("write"))return(...t)=>this.write(e.substring(5).toLowerCase(),...t)}},configurable:!0,enumerable:!0})}}class K extends DataView{constructor(e,t,i,r){super(hr(e),t,i),this.littleEndian=r}cursor=0;readColumn(e){if(e.size){const t=Array.from({length:e.size},(i,r)=>this.read(e.type,e.offset+r));switch(e.type){case"char":return t.join("");default:return t}}else return this.read(e.type,e.offset)}writeColumn(e,t){e.size?Array.from({length:e.size},(i,r)=>{this.write(e.type,t[r],e.offset+r)}):this.write(e.type,t,e.offset)}read(e,t=this.cursor,i=this.littleEndian){switch(e){case"char":return this.readChar(t);case"fixed":return this.readFixed(t,i);case"longDateTime":return this.readLongDateTime(t,i)}const r=`get${e.replace(/^\S/,u=>u.toUpperCase())}`,n=this,h=n[r]?.bind(n)?.(t,i);return this.cursor+=He[e],h}readUint24(e=this.cursor){const[t,i,r]=this.readBytes(e,3);return(t<<16)+(i<<8)+r}readBytes(e,t){t==null&&(t=e,e=this.cursor);const i=[];for(let r=0;r<t;++r)i.push(this.getUint8(e+r));return this.cursor=e+t,i}readString(e,t){const i=this.readBytes(e,t);let r="";for(let n=0,a=i.length;n<a;n++)r+=String.fromCharCode(i[n]);return r}readFixed(e,t){const i=this.readInt32(e,t)/65536;return Math.ceil(i*1e5)/1e5}readLongDateTime(e=this.cursor,t){const i=this.readUint32(e+4,t),r=new Date;return r.setTime(i*1e3+-20775456e5),r}readChar(e){return this.readString(e,1)}write(e,t,i=this.cursor,r=this.littleEndian){switch(e){case"char":return this.writeChar(t,i);case"fixed":return this.writeFixed(t,i);case"longDateTime":return this.writeLongDateTime(t,i)}const n=`set${e.replace(/^\S/,d=>d.toUpperCase())}`,a=this,u=a[n]?.bind(a)?.(i,t,r);return this.cursor+=He[e.toLowerCase()],u}writeString(e="",t=this.cursor){const i=e.replace(/[^\x00-\xFF]/g,"11").length;this.seek(t);for(let r=0,n=e.length,a;r<n;++r)a=e.charCodeAt(r)||0,a>127?this.writeUint16(a):this.writeUint8(a);return this.cursor+=i,this}writeChar(e,t){return this.writeString(e,t)}writeFixed(e,t){return this.writeInt32(Math.round(e*65536),t),this}writeLongDateTime(e,t=this.cursor){typeof e>"u"?e=-20775456e5:typeof e.getTime=="function"?e=e.getTime():/^\d+$/.test(e)?e=+e:e=Date.parse(e);const r=Math.round((e- -20775456e5)/1e3);return this.writeUint32(0,t),this.writeUint32(r,t+4),this}writeBytes(e,t=this.cursor){let i;if(Array.isArray(e)){i=e.length;for(let r=0;r<i;++r)this.setUint8(t+r,e[r])}else{const r=Ae(e);i=r.byteLength;for(let n=0;n<i;++n)this.setUint8(t+n,r.getUint8(n))}return this.cursor=t+i,this}seek(e){return this.cursor=e,this}}J([ee()],K.prototype,"readInt8"),J([ee()],K.prototype,"readInt16"),J([ee()],K.prototype,"readInt32"),J([ee()],K.prototype,"readUint8"),J([ee()],K.prototype,"readUint16"),J([ee()],K.prototype,"readUint32"),J([ee()],K.prototype,"readFloat32"),J([ee()],K.prototype,"readFloat64"),J([ee()],K.prototype,"writeInt8"),J([ee()],K.prototype,"writeInt16"),J([ee()],K.prototype,"writeInt32"),J([ee()],K.prototype,"writeUint8"),J([ee()],K.prototype,"writeUint16"),J([ee()],K.prototype,"writeUint32"),J([ee()],K.prototype,"writeFloat32"),J([ee()],K.prototype,"writeFloat64");const kt=new WeakMap;function l(s){const e=typeof s=="object"?s:{type:s},{size:t=1,type:i}=e;return(r,n)=>{if(typeof n!="string")return;let a=kt.get(r);a||(a={columns:[],byteLength:0},kt.set(r,a));const h={...e,name:n,byteLength:t*He[i],offset:e.offset??a.columns.reduce((u,d)=>u+d.byteLength,0)};a.columns.push(h),a.byteLength=a.columns.reduce((u,d)=>u+He[d.type]*(d.size??1),0),Object.defineProperty(r.constructor.prototype,n,{get(){return this.view.readColumn(h)},set(u){this.view.writeColumn(h,u)},configurable:!0,enumerable:!0})}}class he{view;constructor(e,t,i,r){this.view=new K(e,t,i,r)}}class tt extends he{get buffer(){return this.view.buffer}toBuffer(){return this.view.buffer.slice(this.view.byteOffset,this.view.byteOffset+this.view.byteLength)}toBlob(){return new Blob([new Uint8Array(this.view.buffer,this.view.byteOffset,this.view.byteLength)],{type:this.mimeType})}toFontFace(e){return new FontFace(e,this.view.buffer)}}var mr=Object.defineProperty,ae=(s,e,t,i)=>{for(var r=void 0,n=s.length-1,a;n>=0;n--)(a=s[n])&&(r=a(e,t,r)||r);return r&&mr(e,t,r),r};const te=class ar extends tt{format="EmbeddedOpenType";mimeType="application/vnd.ms-fontobject";static from(e){const t=e.sfnt,r=t.name.names,n=et(r.fontFamily||""),a=n.length,h=et(r.fontStyle||""),u=h.length,d=et(r.version||""),g=d.length,c=et(r.fullName||""),m=c.length,p=86+a+4+u+4+g+4+m+2+e.view.byteLength,y=new ar(new ArrayBuffer(p),0,p,!0);y.EOTSize=y.view.byteLength,y.FontDataSize=e.view.byteLength,y.Version=131073,y.Flags=0,y.Charset=1,y.MagicNumber=20556,y.Padding1=0,y.CheckSumAdjustment=t.head.checkSumAdjustment;const v=t.os2;return v&&(y.FontPANOSE=v.fontPANOSE,y.Italic=v.fsSelection,y.Weight=v.usWeightClass,y.fsType=v.fsType,y.UnicodeRange=v.ulUnicodeRange,y.CodePageRange=v.ulCodePageRange),y.view.writeUint16(a),y.view.writeBytes(n),y.view.writeUint16(0),y.view.writeUint16(u),y.view.writeBytes(h),y.view.writeUint16(0),y.view.writeUint16(g),y.view.writeBytes(d),y.view.writeUint16(0),y.view.writeUint16(m),y.view.writeBytes(c),y.view.writeUint16(0),y.view.writeUint16(0),y.view.writeBytes(e.view),y}};ae([l("uint32")],te.prototype,"EOTSize"),ae([l("uint32")],te.prototype,"FontDataSize"),ae([l("uint32")],te.prototype,"Version"),ae([l("uint32")],te.prototype,"Flags"),ae([l({type:"uint8",size:10})],te.prototype,"FontPANOSE"),ae([l("uint8")],te.prototype,"Charset"),ae([l("uint8")],te.prototype,"Italic"),ae([l("uint32")],te.prototype,"Weight"),ae([l("uint16")],te.prototype,"fsType"),ae([l("uint16")],te.prototype,"MagicNumber"),ae([l({type:"uint8",size:16})],te.prototype,"UnicodeRange"),ae([l({type:"uint8",size:8})],te.prototype,"CodePageRange"),ae([l("uint32")],te.prototype,"CheckSumAdjustment"),ae([l({type:"uint8",size:16})],te.prototype,"Reserved"),ae([l("uint16")],te.prototype,"Padding1");let gr=te;var yr=Object.defineProperty,rt=(s,e,t,i)=>{for(var r=void 0,n=s.length-1,a;n>=0;n--)(a=s[n])&&(r=a(e,t,r)||r);return r&&yr(e,t,r),r};class Ge extends he{constructor(e,t){super(e,t,16)}}rt([l({type:"char",size:4})],Ge.prototype,"tag"),rt([l("uint32")],Ge.prototype,"checkSum"),rt([l("uint32")],Ge.prototype,"offset"),rt([l("uint32")],Ge.prototype,"length");const ut=["","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","space","exclam","quotedbl","numbersign","dollar","percent","ampersand","quoteright","parenleft","parenright","asterisk","plus","comma","hyphen","period","slash","zero","one","two","three","four","five","six","seven","eight","nine","colon","semicolon","less","equal","greater","question","at","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z","bracketleft","backslash","bracketright","asciicircum","underscore","quoteleft","a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z","braceleft","bar","braceright","asciitilde","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","exclamdown","cent","sterling","fraction","yen","florin","section","currency","quotesingle","quotedblleft","guillemotleft","guilsinglleft","guilsinglright","fi","fl","","endash","dagger","daggerdbl","periodcentered","","paragraph","bullet","quotesinglbase","quotedblbase","quotedblright","guillemotright","ellipsis","perthousand","","questiondown","","grave","acute","circumflex","tilde","macron","breve","dotaccent","dieresis","","ring","cedilla","","hungarumlaut","ogonek","caron","emdash","","","","","","","","","","","","","","","","","AE","","ordfeminine","","","","","Lslash","Oslash","OE","ordmasculine","","","","","","ae","","","","dotlessi","","","lslash","oslash","oe","germandbls"],vr=["","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","space","exclamsmall","Hungarumlautsmall","","dollaroldstyle","dollarsuperior","ampersandsmall","Acutesmall","parenleftsuperior","parenrightsuperior","twodotenleader","onedotenleader","comma","hyphen","period","fraction","zerooldstyle","oneoldstyle","twooldstyle","threeoldstyle","fouroldstyle","fiveoldstyle","sixoldstyle","sevenoldstyle","eightoldstyle","nineoldstyle","colon","semicolon","commasuperior","threequartersemdash","periodsuperior","questionsmall","","asuperior","bsuperior","centsuperior","dsuperior","esuperior","","","isuperior","","","lsuperior","msuperior","nsuperior","osuperior","","","rsuperior","ssuperior","tsuperior","","ff","fi","fl","ffi","ffl","parenleftinferior","","parenrightinferior","Circumflexsmall","hyphensuperior","Gravesmall","Asmall","Bsmall","Csmall","Dsmall","Esmall","Fsmall","Gsmall","Hsmall","Ismall","Jsmall","Ksmall","Lsmall","Msmall","Nsmall","Osmall","Psmall","Qsmall","Rsmall","Ssmall","Tsmall","Usmall","Vsmall","Wsmall","Xsmall","Ysmall","Zsmall","colonmonetary","onefitted","rupiah","Tildesmall","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","exclamdownsmall","centoldstyle","Lslashsmall","","","Scaronsmall","Zcaronsmall","Dieresissmall","Brevesmall","Caronsmall","","Dotaccentsmall","","","Macronsmall","","","figuredash","hypheninferior","","","Ogoneksmall","Ringsmall","Cedillasmall","","","","onequarter","onehalf","threequarters","questiondownsmall","oneeighth","threeeighths","fiveeighths","seveneighths","onethird","twothirds","","","zerosuperior","onesuperior","twosuperior","threesuperior","foursuperior","fivesuperior","sixsuperior","sevensuperior","eightsuperior","ninesuperior","zeroinferior","oneinferior","twoinferior","threeinferior","fourinferior","fiveinferior","sixinferior","seveninferior","eightinferior","nineinferior","centinferior","dollarinferior","periodinferior","commainferior","Agravesmall","Aacutesmall","Acircumflexsmall","Atildesmall","Adieresissmall","Aringsmall","AEsmall","Ccedillasmall","Egravesmall","Eacutesmall","Ecircumflexsmall","Edieresissmall","Igravesmall","Iacutesmall","Icircumflexsmall","Idieresissmall","Ethsmall","Ntildesmall","Ogravesmall","Oacutesmall","Ocircumflexsmall","Otildesmall","Odieresissmall","OEsmall","Oslashsmall","Ugravesmall","Uacutesmall","Ucircumflexsmall","Udieresissmall","Yacutesmall","Thornsmall","Ydieresissmall"];class pt{index;name;isComposite=!1;components=[];pathCommands=[];constructor(e){const t={...e};if(this.index=t.index??0,t.name===".notdef"?t.unicode=void 0:t.name===".null"&&(t.unicode=0),t.unicode===0&&t.name!==".null")throw new Error('The unicode value "0" is reserved for the glyph name ".null" and cannot be used by any other glyph.');this.name=t.name??null,t.unicode&&(this.unicode=t.unicode),t.unicodes?this.unicodes=t.unicodes:t.unicode&&(this.unicodes=[t.unicode])}getPathCommands(e=0,t=0,i=72,r={},n){const a=1/(n?.unitsPerEm??1e3)*i,{xScale:h=a,yScale:u=a}=r,d=this.pathCommands,g=[];for(let c=0,m=d.length;c<m;c+=1){const p=d[c];p.type==="M"?g.push({type:"M",x:e+p.x*h,y:t+-p.y*u}):p.type==="L"?g.push({type:"L",x:e+p.x*h,y:t+-p.y*u}):p.type==="Q"?g.push({type:"Q",x1:e+p.x1*h,y1:t+-p.y1*u,x:e+p.x*h,y:t+-p.y*u}):p.type==="C"?g.push({type:"C",x1:e+p.x1*h,y1:t+-p.y1*u,x2:e+p.x2*h,y2:t+-p.y2*u,x:e+p.x*h,y:t+-p.y*u}):p.type==="Z"&&g.push({type:"Z"})}return g}}class wr extends pt{parse(e,t,i){const r=this,{nominalWidthX:n,defaultWidthX:a,gsubrsBias:h,subrsBias:u}=e,d=e.topDict.paintType,g=this.index;let c,m,p,y;const v=[],f=[];let A=0,U=!1,S=!1,M=a,w=0,b=0;function E(x,I){v.push({type:"L",x,y:I})}function O(x,I,V,P,X,j){v.push({type:"C",x1:x,y1:I,x2:V,y2:P,x:X,y:j})}function _(x,I){S&&d!==2&&q(),S=!0,v.push({type:"M",x,y:I})}function q(){v.push({type:"Z"})}function H(x){v.push(...x)}function N(){f.length%2!==0&&!U&&(M=f.shift()+n),A+=f.length>>1,f.length=0,U=!0}function pe(x){let I,V,P,X,j,de,L,W,D,G,T,R,B=0;for(;B<x.length;){let Y=x[B++];switch(Y){case 1:N();break;case 3:N();break;case 4:f.length>1&&!U&&(M=f.shift()+n,U=!0),b+=f.pop(),_(w,b);break;case 5:for(;f.length>0;)w+=f.shift(),b+=f.shift(),E(w,b);break;case 6:for(;f.length>0&&(w+=f.shift(),E(w,b),f.length!==0);)b+=f.shift(),E(w,b);break;case 7:for(;f.length>0&&(b+=f.shift(),E(w,b),f.length!==0);)w+=f.shift(),E(w,b);break;case 8:for(;f.length>0;)c=w+f.shift(),m=b+f.shift(),p=c+f.shift(),y=m+f.shift(),w=p+f.shift(),b=y+f.shift(),O(c,m,p,y,w,b);break;case 10:j=f.pop()+u,de=e.subrs[j],de&&pe(de);break;case 11:return;case 12:switch(Y=x[B],B+=1,Y){case 35:c=w+f.shift(),m=b+f.shift(),p=c+f.shift(),y=m+f.shift(),L=p+f.shift(),W=y+f.shift(),D=L+f.shift(),G=W+f.shift(),T=D+f.shift(),R=G+f.shift(),w=T+f.shift(),b=R+f.shift(),f.shift(),O(c,m,p,y,L,W),O(D,G,T,R,w,b);break;case 34:c=w+f.shift(),m=b,p=c+f.shift(),y=m+f.shift(),L=p+f.shift(),W=y,D=L+f.shift(),G=y,T=D+f.shift(),R=b,w=T+f.shift(),O(c,m,p,y,L,W),O(D,G,T,R,w,b);break;case 36:c=w+f.shift(),m=b+f.shift(),p=c+f.shift(),y=m+f.shift(),L=p+f.shift(),W=y,D=L+f.shift(),G=y,T=D+f.shift(),R=G+f.shift(),w=T+f.shift(),O(c,m,p,y,L,W),O(D,G,T,R,w,b);break;case 37:c=w+f.shift(),m=b+f.shift(),p=c+f.shift(),y=m+f.shift(),L=p+f.shift(),W=y+f.shift(),D=L+f.shift(),G=W+f.shift(),T=D+f.shift(),R=G+f.shift(),Math.abs(T-w)>Math.abs(R-b)?w=T+f.shift():b=R+f.shift(),O(c,m,p,y,L,W),O(D,G,T,R,w,b);break;default:console.warn(`Glyph ${g}: unknown operator ${1200+Y}`),f.length=0}break;case 14:if(f.length>=4){const Ee=ut[f.pop()],Le=ut[f.pop()],be=f.pop(),Oe=f.pop();if(Ee&&Le){r.isComposite=!0,r.components=[];const Ue=e.charset.indexOf(Ee),je=e.charset.indexOf(Le);r.components.push({glyphIndex:je,dx:0,dy:0}),r.components.push({glyphIndex:Ue,dx:Oe,dy:be}),H(i.get(je).pathCommands);const Et=JSON.parse(JSON.stringify(i.get(Ue).pathCommands));for(let Lt=0;Lt<Et.length;Lt+=1){const Se=Et[Lt];Se.type!=="Z"&&(Se.x+=Oe,Se.y+=be),(Se.type==="Q"||Se.type==="C")&&(Se.x1+=Oe,Se.y1+=be),Se.type==="C"&&(Se.x2+=Oe,Se.y2+=be)}H(Et)}}else f.length>0&&!U&&(M=f.shift()+n,U=!0);S&&d!==2&&(q(),S=!1);break;case 18:N();break;case 19:case 20:N(),B+=A+7>>3;break;case 21:f.length>2&&!U&&(M=f.shift()+n,U=!0),b+=f.pop(),w+=f.pop(),_(w,b);break;case 22:f.length>1&&!U&&(M=f.shift()+n,U=!0),w+=f.pop(),_(w,b);break;case 23:N();break;case 24:for(;f.length>2;)c=w+f.shift(),m=b+f.shift(),p=c+f.shift(),y=m+f.shift(),w=p+f.shift(),b=y+f.shift(),O(c,m,p,y,w,b);w+=f.shift(),b+=f.shift(),E(w,b);break;case 25:for(;f.length>6;)w+=f.shift(),b+=f.shift(),E(w,b);c=w+f.shift(),m=b+f.shift(),p=c+f.shift(),y=m+f.shift(),w=p+f.shift(),b=y+f.shift(),O(c,m,p,y,w,b);break;case 26:for(f.length%2&&(w+=f.shift());f.length>0;)c=w,m=b+f.shift(),p=c+f.shift(),y=m+f.shift(),w=p,b=y+f.shift(),O(c,m,p,y,w,b);break;case 27:for(f.length%2&&(b+=f.shift());f.length>0;)c=w+f.shift(),m=b,p=c+f.shift(),y=m+f.shift(),w=p+f.shift(),b=y,O(c,m,p,y,w,b);break;case 28:I=x[B],V=x[B+1],f.push((I<<24|V<<16)>>16),B+=2;break;case 29:j=f.pop()+h,de=e.gsubrs[j],de&&pe(de);break;case 30:for(;f.length>0&&(c=w,m=b+f.shift(),p=c+f.shift(),y=m+f.shift(),w=p+f.shift(),b=y+(f.length===1?f.shift():0),O(c,m,p,y,w,b),f.length!==0);)c=w+f.shift(),m=b,p=c+f.shift(),y=m+f.shift(),b=y+f.shift(),w=p+(f.length===1?f.shift():0),O(c,m,p,y,w,b);break;case 31:for(;f.length>0&&(c=w+f.shift(),m=b,p=c+f.shift(),y=m+f.shift(),b=y+f.shift(),w=p+(f.length===1?f.shift():0),O(c,m,p,y,w,b),f.length!==0);)c=w,m=b+f.shift(),p=c+f.shift(),y=m+f.shift(),w=p+f.shift(),b=y+(f.length===1?f.shift():0),O(c,m,p,y,w,b);break;default:Y<32?console.warn(`Glyph ${g}: unknown operator ${Y}`):Y<247?f.push(Y-139):Y<251?(I=x[B],B+=1,f.push((Y-247)*256+I+108)):Y<255?(I=x[B],B+=1,f.push(-(Y-251)*256-I-108)):(I=x[B],V=x[B+1],P=x[B+2],X=x[B+3],B+=4,f.push((I<<24|V<<16|P<<8|X)/65536))}}}pe(t),this.pathCommands=v,U&&(this.advanceWidth=M)}}class dt{constructor(e){this._sfnt=e}_items=[];get(e){const t=this._items[e];let i;if(t)i=t;else{i=this._get(e);const r=this._sfnt.hmtx.metrics[e];r&&(i.advanceWidth=i.advanceWidth||r.advanceWidth,i.leftSideBearing=i.leftSideBearing||r.leftSideBearing);const n=this._sfnt.cmap.glyphIndexToUnicodesMap.get(e);n&&(i.unicode??=n[0],i.unicodes??=n),this._items[e]=i}return i}}class br extends dt{get length(){return this._sfnt.cff.charStringsIndex.offsets.length-1}_get(e){const t=this._sfnt.cff,i=new wr({index:e});return i.parse(t,t.charStringsIndex.get(e),this),i.name=t.charset[e],i}}var Or=Object.defineProperty,Vt=(s,e,t,i)=>{for(var r=void 0,n=s.length-1,a;n>=0;n--)(a=s[n])&&(r=a(e,t,r)||r);return r&&Or(e,t,r),r};class it extends he{_offsets;get offsets(){return this._offsets??=this.readOffsets()}_objects;get objects(){return this._objects??=this.readObjects()}constructor(e,t,i,r){super(e,t,i,r),this._init()}_init(){const e=this.view,t=this.count,i=this.offsetSize;this.objectOffset=(t+1)*i+2,this.endOffset=e.byteOffset+this.objectOffset+this.offsets[t]}readOffsets(){const e=this.view,t=this.count,i=this.offsetSize;e.seek(3);const r=[];for(let n=0,a=t+1;n<a;n++){const h=this.view;let u=0;for(let d=0;d<i;d++)u<<=8,u+=h.readUint8();r.push(u)}return r}readObjects(){const e=[];for(let t=0,i=this.count;t<i;t++)e.push(this.get(t));return e}get(e){const t=this.offsets,i=this.objectOffset,r=i+t[e],a=i+t[e+1]-r;return this._isString?this.view.readString(r,a):this.view.readBytes(r,a)}}Vt([l("uint16")],it.prototype,"count"),Vt([l("uint8")],it.prototype,"offsetSize");class nt extends it{_isString=!1}class jt extends it{_isString=!0}const Sr=[".notdef","space","exclam","quotedbl","numbersign","dollar","percent","ampersand","quoteright","parenleft","parenright","asterisk","plus","comma","hyphen","period","slash","zero","one","two","three","four","five","six","seven","eight","nine","colon","semicolon","less","equal","greater","question","at","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z","bracketleft","backslash","bracketright","asciicircum","underscore","quoteleft","a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z","braceleft","bar","braceright","asciitilde","exclamdown","cent","sterling","fraction","yen","florin","section","currency","quotesingle","quotedblleft","guillemotleft","guilsinglleft","guilsinglright","fi","fl","endash","dagger","daggerdbl","periodcentered","paragraph","bullet","quotesinglbase","quotedblbase","quotedblright","guillemotright","ellipsis","perthousand","questiondown","grave","acute","circumflex","tilde","macron","breve","dotaccent","dieresis","ring","cedilla","hungarumlaut","ogonek","caron","emdash","AE","ordfeminine","Lslash","Oslash","OE","ordmasculine","ae","dotlessi","lslash","oslash","oe","germandbls","onesuperior","logicalnot","mu","trademark","Eth","onehalf","plusminus","Thorn","onequarter","divide","brokenbar","degree","thorn","threequarters","twosuperior","registered","minus","eth","multiply","threesuperior","copyright","Aacute","Acircumflex","Adieresis","Agrave","Aring","Atilde","Ccedilla","Eacute","Ecircumflex","Edieresis","Egrave","Iacute","Icircumflex","Idieresis","Igrave","Ntilde","Oacute","Ocircumflex","Odieresis","Ograve","Otilde","Scaron","Uacute","Ucircumflex","Udieresis","Ugrave","Yacute","Ydieresis","Zcaron","aacute","acircumflex","adieresis","agrave","aring","atilde","ccedilla","eacute","ecircumflex","edieresis","egrave","iacute","icircumflex","idieresis","igrave","ntilde","oacute","ocircumflex","odieresis","ograve","otilde","scaron","uacute","ucircumflex","udieresis","ugrave","yacute","ydieresis","zcaron","exclamsmall","Hungarumlautsmall","dollaroldstyle","dollarsuperior","ampersandsmall","Acutesmall","parenleftsuperior","parenrightsuperior","266 ff","onedotenleader","zerooldstyle","oneoldstyle","twooldstyle","threeoldstyle","fouroldstyle","fiveoldstyle","sixoldstyle","sevenoldstyle","eightoldstyle","nineoldstyle","commasuperior","threequartersemdash","periodsuperior","questionsmall","asuperior","bsuperior","centsuperior","dsuperior","esuperior","isuperior","lsuperior","msuperior","nsuperior","osuperior","rsuperior","ssuperior","tsuperior","ff","ffi","ffl","parenleftinferior","parenrightinferior","Circumflexsmall","hyphensuperior","Gravesmall","Asmall","Bsmall","Csmall","Dsmall","Esmall","Fsmall","Gsmall","Hsmall","Ismall","Jsmall","Ksmall","Lsmall","Msmall","Nsmall","Osmall","Psmall","Qsmall","Rsmall","Ssmall","Tsmall","Usmall","Vsmall","Wsmall","Xsmall","Ysmall","Zsmall","colonmonetary","onefitted","rupiah","Tildesmall","exclamdownsmall","centoldstyle","Lslashsmall","Scaronsmall","Zcaronsmall","Dieresissmall","Brevesmall","Caronsmall","Dotaccentsmall","Macronsmall","figuredash","hypheninferior","Ogoneksmall","Ringsmall","Cedillasmall","questiondownsmall","oneeighth","threeeighths","fiveeighths","seveneighths","onethird","twothirds","zerosuperior","foursuperior","fivesuperior","sixsuperior","sevensuperior","eightsuperior","ninesuperior","zeroinferior","oneinferior","twoinferior","threeinferior","fourinferior","fiveinferior","sixinferior","seveninferior","eightinferior","nineinferior","centinferior","dollarinferior","periodinferior","commainferior","Agravesmall","Aacutesmall","Acircumflexsmall","Atildesmall","Adieresissmall","Aringsmall","AEsmall","Ccedillasmall","Egravesmall","Eacutesmall","Ecircumflexsmall","Edieresissmall","Igravesmall","Iacutesmall","Icircumflexsmall","Idieresissmall","Ethsmall","Ntildesmall","Ogravesmall","Oacutesmall","Ocircumflexsmall","Otildesmall","Odieresissmall","OEsmall","Oslashsmall","Ugravesmall","Uacutesmall","Ucircumflexsmall","Udieresissmall","Yacutesmall","Thornsmall","Ydieresissmall","001.000","001.001","001.002","001.003","Black","Bold","Book","Light","Medium","Regular","Roman","Semibold"],_r=[".notdef","space","exclam","quotedbl","numbersign","dollar","percent","ampersand","quoteright","parenleft","parenright","asterisk","plus","comma","hyphen","period","slash","zero","one","two","three","four","five","six","seven","eight","nine","colon","semicolon","less","equal","greater","question","at","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z","bracketleft","backslash","bracketright","asciicircum","underscore","quoteleft","a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z","braceleft","bar","braceright","asciitilde","exclamdown","cent","sterling","fraction","yen","florin","section","currency","quotesingle","quotedblleft","guillemotleft","guilsinglleft","guilsinglright","fi","fl","endash","dagger","daggerdbl","periodcentered","paragraph","bullet","quotesinglbase","quotedblbase","quotedblright","guillemotright","ellipsis","perthousand","questiondown","grave","acute","circumflex","tilde","macron","breve","dotaccent","dieresis","ring","cedilla","hungarumlaut","ogonek","caron","emdash","AE","ordfeminine","Lslash","Oslash","OE","ordmasculine","ae","dotlessi","lslash","oslash","oe","germandbls","onesuperior","logicalnot","mu","trademark","Eth","onehalf","plusminus","Thorn","onequarter","divide","brokenbar","degree","thorn","threequarters","twosuperior","registered","minus","eth","multiply","threesuperior","copyright","Aacute","Acircumflex","Adieresis","Agrave","Aring","Atilde","Ccedilla","Eacute","Ecircumflex","Edieresis","Egrave","Iacute","Icircumflex","Idieresis","Igrave","Ntilde","Oacute","Ocircumflex","Odieresis","Ograve","Otilde","Scaron","Uacute","Ucircumflex","Udieresis","Ugrave","Yacute","Ydieresis","Zcaron","aacute","acircumflex","adieresis","agrave","aring","atilde","ccedilla","eacute","ecircumflex","edieresis","egrave","iacute","icircumflex","idieresis","igrave","ntilde","oacute","ocircumflex","odieresis","ograve","otilde","scaron","uacute","ucircumflex","udieresis","ugrave","yacute","ydieresis","zcaron"],Cr=[".notdef","space","exclamsmall","Hungarumlautsmall","dollaroldstyle","dollarsuperior","ampersandsmall","Acutesmall","parenleftsuperior","parenrightsuperior","twodotenleader","onedotenleader","comma","hyphen","period","fraction","zerooldstyle","oneoldstyle","twooldstyle","threeoldstyle","fouroldstyle","fiveoldstyle","sixoldstyle","sevenoldstyle","eightoldstyle","nineoldstyle","colon","semicolon","commasuperior","threequartersemdash","periodsuperior","questionsmall","asuperior","bsuperior","centsuperior","dsuperior","esuperior","isuperior","lsuperior","msuperior","nsuperior","osuperior","rsuperior","ssuperior","tsuperior","ff","fi","fl","ffi","ffl","parenleftinferior","parenrightinferior","Circumflexsmall","hyphensuperior","Gravesmall","Asmall","Bsmall","Csmall","Dsmall","Esmall","Fsmall","Gsmall","Hsmall","Ismall","Jsmall","Ksmall","Lsmall","Msmall","Nsmall","Osmall","Psmall","Qsmall","Rsmall","Ssmall","Tsmall","Usmall","Vsmall","Wsmall","Xsmall","Ysmall","Zsmall","colonmonetary","onefitted","rupiah","Tildesmall","exclamdownsmall","centoldstyle","Lslashsmall","Scaronsmall","Zcaronsmall","Dieresissmall","Brevesmall","Caronsmall","Dotaccentsmall","Macronsmall","figuredash","hypheninferior","Ogoneksmall","Ringsmall","Cedillasmall","onequarter","onehalf","threequarters","questiondownsmall","oneeighth","threeeighths","fiveeighths","seveneighths","onethird","twothirds","zerosuperior","onesuperior","twosuperior","threesuperior","foursuperior","fivesuperior","sixsuperior","sevensuperior","eightsuperior","ninesuperior","zeroinferior","oneinferior","twoinferior","threeinferior","fourinferior","fiveinferior","sixinferior","seveninferior","eightinferior","nineinferior","centinferior","dollarinferior","periodinferior","commainferior","Agravesmall","Aacutesmall","Acircumflexsmall","Atildesmall","Adieresissmall","Aringsmall","AEsmall","Ccedillasmall","Egravesmall","Eacutesmall","Ecircumflexsmall","Edieresissmall","Igravesmall","Iacutesmall","Icircumflexsmall","Idieresissmall","Ethsmall","Ntildesmall","Ogravesmall","Oacutesmall","Ocircumflexsmall","Otildesmall","Odieresissmall","OEsmall","Oslashsmall","Ugravesmall","Uacutesmall","Ucircumflexsmall","Udieresissmall","Yacutesmall","Thornsmall","Ydieresissmall"],Ur=[".notdef","space","dollaroldstyle","dollarsuperior","parenleftsuperior","parenrightsuperior","twodotenleader","onedotenleader","comma","hyphen","period","fraction","zerooldstyle","oneoldstyle","twooldstyle","threeoldstyle","fouroldstyle","fiveoldstyle","sixoldstyle","sevenoldstyle","eightoldstyle","nineoldstyle","colon","semicolon","commasuperior","threequartersemdash","periodsuperior","asuperior","bsuperior","centsuperior","dsuperior","esuperior","isuperior","lsuperior","msuperior","nsuperior","osuperior","rsuperior","ssuperior","tsuperior","ff","fi","fl","ffi","ffl","parenleftinferior","parenrightinferior","hyphensuperior","colonmonetary","onefitted","rupiah","centoldstyle","figuredash","hypheninferior","onequarter","onehalf","threequarters","oneeighth","threeeighths","fiveeighths","seveneighths","onethird","twothirds","zerosuperior","onesuperior","twosuperior","threesuperior","foursuperior","fivesuperior","sixsuperior","sevensuperior","eightsuperior","ninesuperior","zeroinferior","oneinferior","twoinferior","threeinferior","fourinferior","fiveinferior","sixinferior","seveninferior","eightinferior","nineinferior","centinferior","dollarinferior","periodinferior","commainferior"];function st(s,e){return e<=390?Sr[e]:s[e-391]}function k(s,e="number",t){return(i,r)=>{if(typeof r!="string")return;const n={type:e,operator:s,default:t??e==="number"?0:void 0};Object.defineProperty(i.constructor.prototype,r,{get(){return this._getProp(n)},set(a){this._setProp(n,a)},configurable:!0,enumerable:!0})}}class Bt extends he{_dict;get dict(){return this._dict??=this._readDict()}_stringIndex;setStringIndex(e){return this._stringIndex=e,this}_readFloatOperand(){const e=this.view;let t="";const i=15,r=["0","1","2","3","4","5","6","7","8","9",".","E","E-",null,"-"];for(;;){const n=e.readUint8(),a=n>>4,h=n&15;if(a===i||(t+=r[a],h===i))break;t+=r[h]}return Number.parseFloat(t)}_readOperand(e){const t=this.view;let i,r,n,a;if(e===28)return i=t.readUint8(),r=t.readUint8(),i<<8|r;if(e===29)return i=t.readUint8(),r=t.readUint8(),n=t.readUint8(),a=t.readUint8(),i<<24|r<<16|n<<8|a;if(e===30)return this._readFloatOperand();if(e>=32&&e<=246)return e-139;if(e>=247&&e<=250)return i=t.readUint8(),(e-247)*256+i+108;if(e>=251&&e<=254)return i=t.readUint8(),-(e-251)*256-i-108;throw new Error(`invalid b0 ${e}, at: ${t.cursor}`)}_readDict(){const e=this.view;e.seek(0);let t=[];const i=e.cursor+e.byteLength,r={};for(;e.cursor<i;){let n=e.readUint8();n<=21?(n===12&&(n=1200+e.readUint8()),r[n]=t,t=[]):t.push(this._readOperand(n))}return r}_getProp(e){const t=this.dict[e.operator]??e.default;switch(e.type){case"number":return t[0];case"string":return st(this._stringIndex?.objects??[],t[0]);case"number[]":return t}return t}_setProp(e,t){}}var Tr=Object.defineProperty,mt=(s,e,t,i)=>{for(var r=void 0,n=s.length-1,a;n>=0;n--)(a=s[n])&&(r=a(e,t,r)||r);return r&&Tr(e,t,r),r};class at extends Bt{}mt([k(19)],at.prototype,"subrs"),mt([k(20)],at.prototype,"defaultWidthX"),mt([k(21)],at.prototype,"nominalWidthX");var xr=Object.defineProperty,z=(s,e,t,i)=>{for(var r=void 0,n=s.length-1,a;n>=0;n--)(a=s[n])&&(r=a(e,t,r)||r);return r&&xr(e,t,r),r};class $ extends Bt{}z([k(0,"string")],$.prototype,"version"),z([k(1,"string")],$.prototype,"notice"),z([k(1200,"string")],$.prototype,"copyright"),z([k(2,"string")],$.prototype,"fullName"),z([k(3,"string")],$.prototype,"familyName"),z([k(4,"string")],$.prototype,"weight"),z([k(1201)],$.prototype,"isFixedPitch"),z([k(1202)],$.prototype,"italicAngle"),z([k(1203,"number",-100)],$.prototype,"underlinePosition"),z([k(1204,"number",50)],$.prototype,"underlineThickness"),z([k(1205)],$.prototype,"paintType"),z([k(1206,"number",2)],$.prototype,"charstringType"),z([k(1207,"number[]",[.001,0,0,.001,0,0])],$.prototype,"fontMatrix"),z([k(13)],$.prototype,"uniqueId"),z([k(5,"number[]",[0,0,0,0])],$.prototype,"fontBBox"),z([k(1208)],$.prototype,"strokeWidth"),z([k(14)],$.prototype,"xuid"),z([k(15)],$.prototype,"charset"),z([k(16)],$.prototype,"encoding"),z([k(17)],$.prototype,"charStrings"),z([k(18,"number[]",[0,0])],$.prototype,"private");function Q(s,e=s){return t=>{ye.tableDefinitions.set(s,{tag:s,prop:e,class:t}),Object.defineProperty(ye.prototype,e,{get(){return this.get(s)},set(i){return this.set(s,i)},configurable:!0,enumerable:!0})}}class ye{static tableDefinitions=new Map;tables=new Map;tableViews=new Map;get hasGlyf(){return this.tableViews.has("glyf")}get names(){return this.name.names}get unitsPerEm(){return this.head.unitsPerEm}get ascender(){return this.hhea.ascent}get descender(){return this.hhea.descent}get createdTimestamp(){return this.head.created}get modifiedTimestamp(){return this.head.modified}get numGlyphs(){return this.maxp.numGlyphs}get unicodes(){return this.cmap.glyphIndexToUnicodesMap}get glyphs(){return this.hasGlyf?this.glyf.glyphs:this.cff.glyphs}charToGlyphIndex(e){let t=this.cmap.unicodeToGlyphIndexMap.get(e.codePointAt(0));if(t===void 0&&!this.hasGlyf){const{encoding:i,charset:r}=this.cff;t=r.indexOf(i[e.codePointAt(0)])}return t??0}charToGlyph(e){return this.glyphs.get(this.charToGlyphIndex(e))}textToGlyphIndexes(e){const t=[];for(const i of e)t.push(this.charToGlyphIndex(i));return t}textToGlyphs(e){const t=this.glyphs,i=this.textToGlyphIndexes(e),r=i.length,n=Array.from({length:r}),a=t.get(0);for(let h=0;h<r;h+=1)n[h]=t.get(i[h])||a;return n}getPathCommands(e,t,i,r,n){const a=[];return this.forEachGlyph(e,t,i,r,n,(h,u,d,g,c)=>{a.push(...h.getPathCommands(u,d,g,c,this))}),a}getAdvanceWidth(e,t,i){return this.forEachGlyph(e,0,0,t,i,()=>{})}forEachGlyph(e,t=0,i=0,r=72,n={},a){const h=1/this.unitsPerEm*r,u=this.textToGlyphs(e);for(let d=0;d<u.length;d+=1){const g=u[d];a.call(this,g,t,i,r,n),g.advanceWidth&&(t+=g.advanceWidth*h),n.letterSpacing?t+=n.letterSpacing*r:n.tracking&&(t+=n.tracking/1e3*r)}return t}constructor(e){(e instanceof Map?e:new Map(Object.entries(e))).forEach((i,r)=>{this.tableViews.set(r,new DataView(i.buffer.slice(i.byteOffset,i.byteOffset+i.byteLength)))})}clone(){return new ye(this.tableViews)}delete(e){const t=ye.tableDefinitions.get(e);return t?(this.tableViews.delete(e),this.tables.delete(t.prop),this):this}set(e,t){const i=ye.tableDefinitions.get(e);return i&&this.tables.set(i.prop,t),this.tableViews.set(e,t.view),this}get(e){const t=ye.tableDefinitions.get(e);if(!t)return;let i=this.tables.get(t.prop);if(!i){const r=t.class;if(r){const n=this.tableViews.get(e);if(!n)return;i=new r(n.buffer,n.byteOffset,n.byteLength).setSFNT(this),this.tables.set(t.prop,i)}}return i}}class re extends he{setSFNT(e){return this._sfnt=e,this}getSFNT(){return this._sfnt}}var Ir=Object.defineProperty,Ar=Object.getOwnPropertyDescriptor,Ne=(s,e,t,i)=>{for(var r=i>1?void 0:i?Ar(e,t):e,n=s.length-1,a;n>=0;n--)(a=s[n])&&(r=(i?a(e,t,r):a(r))||r);return i&&r&&Ir(e,t,r),r};o.Cff=class extends re{_glyphs;get glyphs(){return this._glyphs??=new br(this._sfnt)}get gsubrs(){return this.globalSubrIndex.objects}get gsubrsBias(){return this._calcSubroutineBias(this.globalSubrIndex.objects)}privateDict;subrsIndex;get defaultWidthX(){return this.privateDict?.defaultWidthX??0}get nominalWidthX(){return this.privateDict?.nominalWidthX??0}get subrs(){return this.subrsIndex?.objects??[]}get subrsBias(){return this._calcSubroutineBias(this.subrs)}constructor(e,t,i,r){super(e,t,i,r),this._init()}_init(){const e=this.view,{buffer:t,byteOffset:i}=e,r=i+4;this.nameIndex=new jt(t,r),this.topDictIndex=new nt(t,this.nameIndex.endOffset),this.stringIndex=new jt(t,this.topDictIndex.endOffset),this.globalSubrIndex=new nt(t,this.stringIndex.endOffset),this.topDict=new $(new Uint8Array(this.topDictIndex.objects[0]).buffer).setStringIndex(this.stringIndex);const n=this.topDict.private[0],a=this.topDict.private[1];n&&(this.privateDict=new at(t,i+a,n).setStringIndex(this.stringIndex),this.privateDict.subrs&&(this.subrsIndex=new nt(t,i+a+this.privateDict.subrs))),this.charStringsIndex=new nt(t,i+this.topDict.charStrings);const h=this.charStringsIndex.offsets.length-1;this.topDict.charset===0?this.charset=_r:this.topDict.charset===1?this.charset=Cr:this.topDict.charset===2?this.charset=Ur:this.charset=this._readCharset(i+this.topDict.charset,h,this.stringIndex.objects),this.topDict.encoding===0?this.encoding=ut:this.topDict.encoding===1?this.encoding=vr:this.encoding=this._readEncoding(i+this.topDict.encoding)}_readCharset(e,t,i){const r=this.view;r.seek(e);let n,a,h;t-=1;const u=[".notdef"],d=r.readUint8();if(d===0)for(n=0;n<t;n+=1)a=r.readUint16(),u.push(st(i,a));else if(d===1)for(;u.length<=t;)for(a=r.readUint16(),h=r.readUint8(),n=0;n<=h;n+=1)u.push(st(i,a)),a+=1;else if(d===2)for(;u.length<=t;)for(a=r.readUint16(),h=r.readUint16(),n=0;n<=h;n+=1)u.push(st(i,a)),a+=1;else throw new Error(`Unknown charset format ${d}`);return u}_readEncoding(e){const t=this.view;t.seek(e);let i,r;const n={},a=t.readUint8();if(a===0){const h=t.readUint8();for(i=0;i<h;i+=1)r=t.readUint8(),n[r]=i}else if(a===1){const h=t.readUint8();for(r=1,i=0;i<h;i+=1){const u=t.readUint8(),d=t.readUint8();for(let g=u;g<=u+d;g+=1)n[g]=r,r+=1}}else console.warn(`unknown encoding format:${a}`);return n}_calcSubroutineBias(e){let t;return e.length<1240?t=107:e.length<33900?t=1131:t=32768,t}},Ne([l("uint8")],o.Cff.prototype,"majorVersion",2),Ne([l("uint8")],o.Cff.prototype,"minorVersion",2),Ne([l("uint8")],o.Cff.prototype,"headerSize",2),Ne([l("uint8")],o.Cff.prototype,"offsetSize",2),o.Cff=Ne([Q("CFF ","cff")],o.Cff);var Mr=Object.defineProperty,ot=(s,e,t,i)=>{for(var r=void 0,n=s.length-1,a;n>=0;n--)(a=s[n])&&(r=a(e,t,r)||r);return r&&Mr(e,t,r),r};const Re=class or extends he{constructor(e=new ArrayBuffer(262),t){super(e,t,262)}static from(e){const t=new or;return t.format=0,t.length=t.view.byteLength,t.language=0,e.forEach((i,r)=>{r<256&&i<256&&t.view.writeUint8(i,6+r)}),t}getUnicodeToGlyphIndexMap(){const e=new Map;return this.glyphIndexArray.forEach((t,i)=>{e.set(i,t)}),e}};ot([l("uint16")],Re.prototype,"format"),ot([l("uint16")],Re.prototype,"length"),ot([l("uint16")],Re.prototype,"language"),ot([l({type:"uint8",size:256})],Re.prototype,"glyphIndexArray");let gt=Re;var Pr=Object.defineProperty,yt=(s,e,t,i)=>{for(var r=void 0,n=s.length-1,a;n>=0;n--)(a=s[n])&&(r=a(e,t,r)||r);return r&&Pr(e,t,r),r};class ze extends he{get subHeaderKeys(){return this.view.seek(6),Array.from({length:256},()=>this.view.readUint16()/8)}get maxSubHeaderKey(){return this.subHeaderKeys.reduce((e,t)=>Math.max(e,t),0)}get subHeaders(){const e=this.maxSubHeaderKey;return this.view.seek(6+256*2),Array.from({length:e},(t,i)=>({firstCode:this.view.readUint16(),entryCount:this.view.readUint16(),idDelta:this.view.readUint16(),idRangeOffset:(this.view.readUint16()-(e-i)*8-2)/2}))}get glyphIndexArray(){const e=this.maxSubHeaderKey,t=6+256*2+e*8;this.view.seek(t);const i=(this.view.byteLength-t)/2;return Array.from({length:i},()=>this.view.readUint16())}getUnicodeToGlyphIndexMap(e){const t=new Map,i=this.subHeaderKeys,r=this.maxSubHeaderKey,n=this.subHeaders,a=this.glyphIndexArray,h=i.findIndex(d=>d===r);let u=0;for(let d=0;d<256;d++)if(i[d]===0)d>=h||d<n[0].firstCode||d>=n[0].firstCode+n[0].entryCount||n[0].idRangeOffset+(d-n[0].firstCode)>=a.length?u=0:(u=a[n[0].idRangeOffset+(d-n[0].firstCode)],u!==0&&(u=u+n[0].idDelta)),u!==0&&u<e&&t.set(d,u);else{const g=i[d];for(let c=0,m=n[g].entryCount;c<m;c++)if(n[g].idRangeOffset+c>=a.length?u=0:(u=a[n[g].idRangeOffset+c],u!==0&&(u=u+n[g].idDelta)),u!==0&&u<e){const p=(d<<8|c+n[g].firstCode)%65535;t.set(p,u)}}return t}}yt([l("uint16")],ze.prototype,"format"),yt([l("uint16")],ze.prototype,"length"),yt([l("uint16")],ze.prototype,"language");function $t(s){return s>32767?s-65536:s<-32767?s+65536:s}function vt(s,e){let t;const i=[];let r={};return s.forEach((n,a)=>{e&&a>e||((!t||a!==t.unicode+1||n!==t.glyphIndex+1)&&(t?(r.end=t.unicode,i.push(r),r={start:a,startId:n,delta:$t(n-a)}):(r.start=Number(a),r.startId=n,r.delta=$t(n-a))),t={unicode:a,glyphIndex:n})}),t&&(r.end=t.unicode,i.push(r)),i}var Dr=Object.defineProperty,Me=(s,e,t,i)=>{for(var r=void 0,n=s.length-1,a;n>=0;n--)(a=s[n])&&(r=a(e,t,r)||r);return r&&Dr(e,t,r),r};const Te=class lr extends he{get endCode(){const e=this.segCountX2;return this.view.seek(14),Array.from({length:e/2},()=>this.view.readUint16())}set endCode(e){this.view.seek(14),e.forEach(t=>this.view.writeUint16(t))}get reservedPad(){return this.view.readUint16(14+this.segCountX2)}set reservedPad(e){this.view.writeUint16(e,14+this.segCountX2)}get startCode(){const e=this.segCountX2;return this.view.seek(14+e+2),Array.from({length:e/2},()=>this.view.readUint16())}set startCode(e){this.view.seek(14+this.segCountX2+2),e.forEach(t=>this.view.writeUint16(t))}get idDelta(){const e=this.segCountX2;return this.view.seek(14+e+2+e),Array.from({length:e/2},()=>this.view.readUint16())}set idDelta(e){const t=this.segCountX2;this.view.seek(14+t+2+t),e.forEach(i=>this.view.writeUint16(i))}get idRangeOffsetCursor(){const e=this.segCountX2;return 14+e+2+e*2}get idRangeOffset(){const e=this.segCountX2;return this.view.seek(this.idRangeOffsetCursor),Array.from({length:e/2},()=>this.view.readUint16())}set idRangeOffset(e){this.view.seek(this.idRangeOffsetCursor),e.forEach(t=>this.view.writeUint16(t))}get glyphIndexArrayCursor(){const e=this.segCountX2;return 14+e+2+e*3}get glyphIndexArray(){const e=this.glyphIndexArrayCursor;this.view.seek(e);const t=(this.view.byteLength-e)/2;return Array.from({length:t},()=>this.view.readUint16())}static from(e){const t=vt(e,65535),i=t.length+1,r=Math.floor(Math.log(i)/Math.LN2),n=2*2**r,a=new lr(new ArrayBuffer(24+t.length*8));return a.format=4,a.length=a.view.byteLength,a.language=0,a.segCountX2=i*2,a.searchRange=n,a.entrySelector=r,a.rangeShift=2*i-n,a.endCode=[...t.map(h=>h.end),65535],a.reservedPad=0,a.startCode=[...t.map(h=>h.start),65535],a.idDelta=[...t.map(h=>h.delta),1],a.idRangeOffset=Array.from({length:i},()=>0),a}getUnicodeToGlyphIndexMap(){const e=new Map,t=this.segCountX2/2,i=(this.glyphIndexArrayCursor-this.idRangeOffsetCursor)/2,r=this.startCode,n=this.endCode,a=this.idRangeOffset,h=this.idDelta,u=this.glyphIndexArray;for(let d=0;d<t;++d)for(let g=r[d],c=n[d];g<=c;++g)if(a[d]===0)e.set(g,(g+h[d])%65536);else{const m=d+a[d]/2+(g-r[d])-i,p=u[m];p!==0?e.set(g,(p+h[d])%65536):e.set(g,0)}return e.delete(65535),e}};Me([l("uint16")],Te.prototype,"format"),Me([l("uint16")],Te.prototype,"length"),Me([l("uint16")],Te.prototype,"language"),Me([l("uint16")],Te.prototype,"segCountX2"),Me([l("uint16")],Te.prototype,"searchRange"),Me([l("uint16")],Te.prototype,"entrySelector"),Me([l("uint16")],Te.prototype,"rangeShift");let wt=Te;var Fr=Object.defineProperty,qe=(s,e,t,i)=>{for(var r=void 0,n=s.length-1,a;n>=0;n--)(a=s[n])&&(r=a(e,t,r)||r);return r&&Fr(e,t,r),r};class Pe extends he{get glyphIndexArray(){return this.view.seek(12),Array.from({length:this.entryCount},()=>this.view.readUint16())}getUnicodeToGlyphIndexMap(){const e=this.glyphIndexArray,t=new Map;return e.forEach((i,r)=>{t.set(r,i)}),t}}qe([l("uint16")],Pe.prototype,"format"),qe([l("uint16")],Pe.prototype,"length"),qe([l("uint16")],Pe.prototype,"language"),qe([l("uint16")],Pe.prototype,"firstCode"),qe([l("uint16")],Pe.prototype,"entryCount");var Er=Object.defineProperty,We=(s,e,t,i)=>{for(var r=void 0,n=s.length-1,a;n>=0;n--)(a=s[n])&&(r=a(e,t,r)||r);return r&&Er(e,t,r),r};const ke=class fr extends he{get groups(){const e=this.nGroups;return this.view.seek(16),Array.from({length:e},()=>({startCharCode:this.view.readUint32(),endCharCode:this.view.readUint32(),startGlyphCode:this.view.readUint32()}))}static from(e){const t=vt(e),i=new fr(new ArrayBuffer(16+t.length*12));return i.format=12,i.reserved=0,i.length=i.view.byteLength,i.language=0,i.nGroups=t.length,t.forEach(r=>{i.view.writeUint32(r.start),i.view.writeUint32(r.end),i.view.writeUint32(r.startId)}),i}getUnicodeToGlyphIndexMap(){const e=new Map,t=this.groups;for(let i=0,r=t.length;i<r;i++){const n=t[i];let a=n.startGlyphCode,h=n.startCharCode;const u=n.endCharCode;for(;h<=u;)e.set(h++,a++)}return e}};We([l("uint16")],ke.prototype,"format"),We([l("uint16")],ke.prototype,"reserved"),We([l("uint32")],ke.prototype,"length"),We([l("uint32")],ke.prototype,"language"),We([l("uint32")],ke.prototype,"nGroups");let bt=ke;var Lr=Object.defineProperty,Ot=(s,e,t,i)=>{for(var r=void 0,n=s.length-1,a;n>=0;n--)(a=s[n])&&(r=a(e,t,r)||r);return r&&Lr(e,t,r),r};class Xe extends he{getVarSelectorRecords(){const e=this.numVarSelectorRecords;return this.view.seek(10),Array.from({length:e},()=>{const t={varSelector:this.view.readUint24(),defaultUVSOffset:this.view.readUint32(),unicodeValueRanges:[],nonDefaultUVSOffset:this.view.readUint32(),uVSMappings:[]};if(t.defaultUVSOffset){this.view.seek(t.defaultUVSOffset);const i=this.view.readUint32();t.unicodeValueRanges=Array.from({length:i},()=>({startUnicodeValue:this.view.readUint24(),additionalCount:this.view.readUint8()}))}if(t.nonDefaultUVSOffset){this.view.seek(t.nonDefaultUVSOffset);const i=this.view.readUint32();t.uVSMappings=Array.from({length:i},()=>({unicodeValue:this.view.readUint24(),glyphID:this.view.readUint16()}))}return t})}getUnicodeToGlyphIndexMap(){const e=new Map,t=this.getVarSelectorRecords();for(let i=0,r=t.length;i<r;i++){const{uVSMappings:n}=t[i];n.forEach(a=>{e.set(a.unicodeValue,a.glyphID)})}return e}}Ot([l("uint16")],Xe.prototype,"format"),Ot([l("uint32")],Xe.prototype,"length"),Ot([l("uint32")],Xe.prototype,"numVarSelectorRecords");var Gr=Object.defineProperty,kr=Object.getOwnPropertyDescriptor,St=(s,e,t,i)=>{for(var r=i>1?void 0:i?kr(e,t):e,n=s.length-1,a;n>=0;n--)(a=s[n])&&(r=(i?a(e,t,r):a(r))||r);return i&&r&&Gr(e,t,r),r};o.Cmap=class extends re{static from(e){const t=Array.from(e.keys()).some(c=>c>65535),i=wt.from(e),r=gt.from(e),n=t?bt.from(e):void 0,a=4+(n?32:24),h=a+i.view.byteLength,u=h+r.view.byteLength,d=[{platformID:0,platformSpecificID:3,offset:a},{platformID:1,platformSpecificID:0,offset:h},{platformID:3,platformSpecificID:1,offset:a},n&&{platformID:3,platformSpecificID:10,offset:u}].filter(Boolean),g=new o.Cmap(new ArrayBuffer(4+8*d.length+i.view.byteLength+r.view.byteLength+(n?.view.byteLength??0)));return g.numberSubtables=d.length,g.view.seek(4),d.forEach(c=>{g.view.writeUint16(c.platformID),g.view.writeUint16(c.platformSpecificID),g.view.writeUint32(c.offset)}),g.view.writeBytes(i.view,a),g.view.writeBytes(r.view,h),n&&g.view.writeBytes(n.view,u),g}_unicodeToGlyphIndexMap;get unicodeToGlyphIndexMap(){return this._unicodeToGlyphIndexMap??=this.readunicodeToGlyphIndexMap()}_glyphIndexToUnicodesMap;get glyphIndexToUnicodesMap(){if(!this._glyphIndexToUnicodesMap){const e=new Map,t=this.unicodeToGlyphIndexMap,i=Array.from(t.keys());for(let r=0,n=i.length;r<n;r++){const a=i[r],h=t.get(a);e.has(h)?e.get(h).push(a):e.set(h,[a])}this._glyphIndexToUnicodesMap=e}return this._glyphIndexToUnicodesMap}readSubtables(){const e=this.numberSubtables;return this.view.seek(4),Array.from({length:e},()=>({platformID:this.view.readUint16(),platformSpecificID:this.view.readUint16(),offset:this.view.readUint32()})).map(t=>{this.view.seek(t.offset);const i=this.view.readUint16();let r;switch(i){case 0:r=new gt(this.view.buffer,t.offset);break;case 2:r=new ze(this.view.buffer,t.offset,this.view.readUint16());break;case 4:r=new wt(this.view.buffer,t.offset,this.view.readUint16());break;case 6:r=new Pe(this.view.buffer,t.offset,this.view.readUint16());break;case 12:r=new bt(this.view.buffer,t.offset,this.view.readUint32(t.offset+4));break;case 14:default:r=new Xe(this.view.buffer,t.offset,this.view.readUint32());break}return{...t,format:i,view:r}})}readunicodeToGlyphIndexMap(){const e=this.readSubtables(),t=e.find(h=>h.format===0)?.view,i=e.find(h=>h.platformID===3&&h.platformSpecificID===3&&h.format===2)?.view,r=e.find(h=>h.platformID===3&&h.platformSpecificID===1&&h.format===4)?.view,n=e.find(h=>h.platformID===3&&h.platformSpecificID===10&&h.format===12)?.view,a=e.find(h=>h.platformID===0&&h.platformSpecificID===5&&h.format===14)?.view;return new Map([...t?.getUnicodeToGlyphIndexMap()??[],...i?.getUnicodeToGlyphIndexMap(this._sfnt.maxp.numGlyphs)??[],...r?.getUnicodeToGlyphIndexMap()??[],...n?.getUnicodeToGlyphIndexMap()??[],...a?.getUnicodeToGlyphIndexMap()??[]])}},St([l("uint16")],o.Cmap.prototype,"version",2),St([l("uint16")],o.Cmap.prototype,"numberSubtables",2),o.Cmap=St([Q("cmap")],o.Cmap);class Vr extends pt{_parseContours(e){const t=[];let i=[];for(let r=0;r<e.length;r+=1){const n=e[r];i.push(n),n.lastPointOfContour&&(t.push(i),i=[])}return $e(i.length===0,"There are still points left in the current contour."),t}_transformPoints(e,t){const i=[];for(let r=0;r<e.length;r+=1){const n=e[r],a={x:t.xScale*n.x+t.scale10*n.y+t.dx,y:t.scale01*n.x+t.yScale*n.y+t.dy,onCurve:n.onCurve,lastPointOfContour:n.lastPointOfContour};i.push(a)}return i}_parseGlyphCoordinate(e,t,i,r,n){let a;return(t&r)>0?(a=e.view.readUint8(),(t&n)===0&&(a=-a),a=i+a):(t&n)>0?a=i:a=i+e.view.readInt16(),a}parse(e,t,i){e.view.seek(t);const r=this.numberOfContours=e.view.readInt16();if(this.xMin=e.view.readInt16(),this.yMin=e.view.readInt16(),this.xMax=e.view.readInt16(),this.yMax=e.view.readInt16(),r>0){const h=this.endPointIndices=[];for(let v=0;v<r;v++)h.push(e.view.readUint16());const u=this.instructionLength=e.view.readUint16();$e(u<5e3,`Bad instructionLength:${u}`);const d=this.instructions=[];for(let v=0;v<u;++v)d.push(e.view.readUint8());const g=e.view.byteOffset,c=h[h.length-1]+1;$e(c<2e4,`Bad numberOfCoordinates:${g}`);const m=[];let p,y=0;for(;y<c;)if(p=e.view.readUint8(),m.push(p),y++,p&8&&y<c){const v=e.view.readUint8();for(let f=0;f<v;f++)m.push(p),y++}if($e(m.length===c,`Bad flags length: ${m.length}, numberOfCoordinates: ${c}`),h.length>0){const v=[];let f;if(c>0){for(let S=0;S<c;S+=1)p=m[S],f={},f.onCurve=!!(p&1),f.lastPointOfContour=h.includes(S),v.push(f);let A=0;for(let S=0;S<c;S+=1)p=m[S],f=v[S],f.x=this._parseGlyphCoordinate(e,p,A,2,16),A=f.x;let U=0;for(let S=0;S<c;S+=1)p=m[S],f=v[S],f.y=this._parseGlyphCoordinate(e,p,U,4,32),U=f.y}this.points=v}else this.points=[]}else if(r===0)this.points=[];else{this.isComposite=!0,this.points=[],this.components=[];let h,u=!0;for(;u;){h=e.view.readUint16();const d={glyphIndex:e.view.readUint16(),xScale:1,scale01:0,scale10:0,yScale:1,dx:0,dy:0};(h&1)>0?(h&2)>0?(d.dx=e.view.readInt16(),d.dy=e.view.readInt16()):d.matchedPoints=[e.view.readUint16(),e.view.readUint16()]:(h&2)>0?(d.dx=e.view.readInt8(),d.dy=e.view.readInt8()):d.matchedPoints=[e.view.readUint8(),e.view.readUint8()],(h&8)>0?d.xScale=d.yScale=e.view.readInt16()/16384:(h&64)>0?(d.xScale=e.view.readInt16()/16384,d.yScale=e.view.readInt16()/16384):(h&128)>0&&(d.xScale=e.view.readInt16()/16384,d.scale01=e.v