modern-text 0.1.18 → 0.1.19
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +1 -1
- package/dist/index.js +1 -1
- package/dist/index.mjs +174 -174
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});class x{constructor(t=0,e=0,n=0,o=0){this.x=t,this.y=e,this.width=n,this.height=o}get left(){return this.x}get top(){return this.y}get right(){return this.x+this.width}get bottom(){return this.y+this.height}static from(...t){const e=t[0],n=t.slice(1).reduce((o,c)=>(o.x=Math.min(o.x,c.x),o.y=Math.min(o.y,c.y),o.right=Math.max(o.right,c.right),o.bottom=Math.max(o.bottom,c.bottom),o),{x:e.x,y:e.y,right:e.right,bottom:e.bottom});return new x(n.x,n.y,n.right-n.x,n.bottom-n.y)}rotate90deg(){const{width:t,height:e}=this;this.width=e,this.height=t}translate(t,e){return this.x+=t,this.y+=e,this}clone(){return new x(this.x,this.y,this.width,this.height)}toArray(){return[this.x,this.y,this.width,this.height]}}function P(r,t){switch(r.shadowColor=t.shadowColor||"rgba(0, 0, 0, 0)",r.shadowOffsetX=t.shadowOffsetX||0,r.shadowOffsetY=t.shadowOffsetY||0,r.shadowBlur=t.shadowBlur||0,r.strokeStyle=t.textStrokeColor||"#000",r.lineWidth=t.textStrokeWidth||0,r.fillStyle=t.color||"#000",r.textAlign=t.textAlign||"start",r.fontKerning=t.fontKerning||"normal",t.verticalAlign){case"top":case"middle":case"bottom":r.textBaseline=t.verticalAlign;break;case"baseline":default:r.textBaseline="alphabetic";break}r.font=[t.fontStyle||"normal",t.fontWeight||"normal",`${t.fontSize||14}px`,t.fontFamily||"sans-serif"].join(" "),r.letterSpacing=`${t.letterSpacing||0}px`}const X="OffscreenCanvas"in globalThis;let N;function Y(){return N??(N=X?new OffscreenCanvas(1,1):document.createElement("canvas"))}function $(r,t){const e=Y().getContext("2d");P(e,{...t,textAlign:"center",verticalAlign:"baseline"});const{width:n,actualBoundingBoxAscent:o,actualBoundingBoxDescent:c,actualBoundingBoxLeft:i,actualBoundingBoxRight:B,fontBoundingBoxAscent:A,fontBoundingBoxDescent:D}=e.measureText(r),g=t.fontSize*t.lineHeight,d=A+D;return{width:n,height:t.fontSize,typoAscent:A,typoDescent:D,typoHeight:d,lineHeight:g,glyphLeft:i,glyphRight:B,glyphAscent:o,glyphDescent:c,glyphWidth:i+B,glyphHeight:o+c,baseline:(g-d)/2+A,centerX:n/2}}function I(r,t){const e=document.createDocumentFragment(),n=document.createElement("div");n.style.position="absolute",n.style.visibility="hidden",n.setAttribute("aria-hidden","true"),n.style.fontFamily=t.fontFamily,n.style.fontSize=`${t.fontSize}px`,n.style.lineHeight=String(t.lineHeight),n.style.whiteSpace="nowrap",n.style.writingMode=t.writingMode;const o=document.createElement("span");o.textContent=/\s/.test(r)?" ":r,n.appendChild(o),e.appendChild(n),document.body.appendChild(e);const c={leading:o.offsetHeight-t.fontSize};return document.body.removeChild(n),c}const K=/[\u{00A7}\u{00A9}\u{00AE}\u{00B1}\u{00BC}-\u{00BE}\u{00D7}\u{00F7}\u{02EA}-\u{02EB}\u{1100}-\u{11FF}\u{1401}-\u{166C}\u{166D}\u{166E}\u{166F}-\u{167F}\u{18B0}-\u{18F5}\u{18F6}-\u{18FF}\u{2016}\u{2020}-\u{2021}\u{2030}-\u{2031}\u{203B}-\u{203C}\u{2042}\u{2047}-\u{2049}\u{2051}\u{2065}\u{20DD}-\u{20E0}\u{20E2}-\u{20E4}\u{2100}-\u{2101}\u{2103}-\u{2106}\u{2107}\u{2108}-\u{2109}\u{210F}\u{2113}\u{2114}\u{2116}-\u{2117}\u{211E}-\u{2123}\u{2125}\u{2127}\u{2129}\u{212E}\u{2135}-\u{2138}\u{2139}\u{213A}-\u{213B}\u{213C}-\u{213F}\u{2145}-\u{2149}\u{214A}\u{214C}-\u{214D}\u{214F}\u{2150}-\u{215F}\u{2160}-\u{2182}\u{2183}-\u{2184}\u{2185}-\u{2188}\u{2189}\u{218C}-\u{218F}\u{221E}\u{2234}-\u{2235}\u{2300}-\u{2307}\u{230C}-\u{231F}\u{2324}-\u{2328}\u{232B}\u{237D}-\u{239A}\u{23BE}-\u{23CD}\u{23CF}\u{23D1}-\u{23DB}\u{23E2}-\u{23FF}\u{2400}-\u{2422}\u{2424}-\u{2426}\u{2427}-\u{243F}\u{2440}-\u{244A}\u{244B}-\u{245F}\u{2460}-\u{249B}\u{249C}-\u{24E9}\u{24EA}-\u{24FF}\u{25A0}-\u{25B6}\u{25B7}\u{25B8}-\u{25C0}\u{25C1}\u{25C2}-\u{25F7}\u{25F8}-\u{25FF}\u{2600}-\u{2619}\u{2620}-\u{266E}\u{266F}\u{2670}-\u{26FF}\u{2700}-\u{2767}\u{2776}-\u{2793}\u{2B12}-\u{2B2F}\u{2B50}-\u{2B59}\u{2B97}\u{2BB8}-\u{2BD1}\u{2BD3}-\u{2BEB}\u{2BF0}-\u{2BFF}\u{2E50}-\u{2E51}\u{2E80}-\u{2E99}\u{2E9A}\u{2E9B}-\u{2EF3}\u{2EF4}-\u{2EFF}\u{2F00}-\u{2FD5}\u{2FD6}-\u{2FDF}\u{2FE0}-\u{2FEF}\u{2FF0}-\u{2FFB}\u{2FFC}-\u{2FFF}\u{3000}\u{3001}-\u{3002}\u{3003}\u{3004}\u{3005}\u{3006}\u{3007}\u{3012}-\u{3013}\u{3020}\u{3021}-\u{3029}\u{302A}-\u{302D}\u{302E}-\u{302F}\u{3031}-\u{3035}\u{3036}-\u{3037}\u{3038}-\u{303A}\u{303B}\u{303C}\u{303D}\u{303E}-\u{303F}\u{3040}\u{3041}\u{3042}\u{3043}\u{3044}\u{3045}\u{3046}\u{3047}\u{3048}\u{3049}\u{304A}-\u{3062}\u{3063}\u{3064}-\u{3082}\u{3083}\u{3084}\u{3085}\u{3086}\u{3087}\u{3088}-\u{308D}\u{308E}\u{308F}-\u{3094}\u{3095}-\u{3096}\u{3097}-\u{3098}\u{3099}-\u{309A}\u{309B}-\u{309C}\u{309D}-\u{309E}\u{309F}\u{30A1}\u{30A2}\u{30A3}\u{30A4}\u{30A5}\u{30A6}\u{30A7}\u{30A8}\u{30A9}\u{30AA}-\u{30C2}\u{30C3}\u{30C4}-\u{30E2}\u{30E3}\u{30E4}\u{30E5}\u{30E6}\u{30E7}\u{30E8}-\u{30ED}\u{30EE}\u{30EF}-\u{30F4}\u{30F5}-\u{30F6}\u{30F7}-\u{30FA}\u{30FB}\u{30FD}-\u{30FE}\u{30FF}\u{3100}-\u{3104}\u{3105}-\u{3126}\u{3127}\u{3128}-\u{312F}\u{3130}\u{3131}-\u{318E}\u{318F}\u{3190}-\u{3191}\u{3192}-\u{3195}\u{3196}-\u{319F}\u{31A0}-\u{31BF}\u{31C0}-\u{31E3}\u{31E4}-\u{31EF}\u{31F0}-\u{31FF}\u{3200}-\u{321E}\u{321F}\u{3220}-\u{3229}\u{322A}-\u{3247}\u{3248}-\u{324F}\u{3250}\u{3251}-\u{325F}\u{3260}-\u{327F}\u{3280}-\u{3289}\u{328A}-\u{32B0}\u{32B1}-\u{32BF}\u{32C0}-\u{32FE}\u{32FF}\u{3300}-\u{3357}\u{3358}-\u{337A}\u{337B}-\u{337F}\u{3380}-\u{33FF}\u{3400}-\u{4DBF}\u{4DC0}-\u{4DFF}\u{4E00}-\u{9FFF}\u{A000}-\u{A014}\u{A015}\u{A016}-\u{A48C}\u{A48D}-\u{A48F}\u{A490}-\u{A4C6}\u{A4C7}-\u{A4CF}\u{A960}-\u{A97C}\u{A97D}-\u{A97F}\u{AC00}-\u{D7A3}\u{D7A4}-\u{D7AF}\u{D7B0}-\u{D7C6}\u{D7C7}-\u{D7CA}\u{D7CB}-\u{D7FB}\u{D7FC}-\u{D7FF}\u{E000}-\u{F8FF}\u{F900}-\u{FA6D}\u{FA6E}-\u{FA6F}\u{FA70}-\u{FAD9}\u{FADA}-\u{FAFF}\u{FE10}-\u{FE16}\u{FE17}\u{FE18}\u{FE19}\u{FE1A}-\u{FE1F}\u{FE30}\u{FE31}-\u{FE32}\u{FE33}-\u{FE34}\u{FE35}\u{FE36}\u{FE37}\u{FE38}\u{FE39}\u{FE3A}\u{FE3B}\u{FE3C}\u{FE3D}\u{FE3E}\u{FE3F}\u{FE40}\u{FE41}\u{FE42}\u{FE43}\u{FE44}\u{FE45}-\u{FE46}\u{FE47}\u{FE48}\u{FE50}-\u{FE52}\u{FE53}\u{FE54}-\u{FE57}\u{FE5F}-\u{FE61}\u{FE62}\u{FE67}\u{FE68}\u{FE69}\u{FE6A}-\u{FE6B}\u{FE6C}-\u{FE6F}\u{FF01}\u{FF02}-\u{FF03}\u{FF04}\u{FF05}-\u{FF07}\u{FF0A}\u{FF0B}\u{FF0C}\u{FF0E}\u{FF0F}\u{FF10}-\u{FF19}\u{FF1F}\u{FF20}\u{FF21}-\u{FF3A}\u{FF3C}\u{FF3E}\u{FF40}\u{FF41}-\u{FF5A}\u{FFE0}-\u{FFE1}\u{FFE2}\u{FFE4}\u{FFE5}-\u{FFE6}\u{FFE7}\u{FFF0}-\u{FFF8}\u{FFFC}-\u{FFFD}\u{10980}-\u{1099F}\u{11580}-\u{115AE}\u{115AF}-\u{115B1}\u{115B2}-\u{115B5}\u{115B6}-\u{115B7}\u{115B8}-\u{115BB}\u{115BC}-\u{115BD}\u{115BE}\u{115BF}-\u{115C0}\u{115C1}-\u{115D7}\u{115D8}-\u{115DB}\u{115DC}-\u{115DD}\u{115DE}-\u{115FF}\u{11A00}\u{11A01}-\u{11A0A}\u{11A0B}-\u{11A32}\u{11A33}-\u{11A38}\u{11A39}\u{11A3A}\u{11A3B}-\u{11A3E}\u{11A3F}-\u{11A46}\u{11A47}\u{11A48}-\u{11A4F}\u{11A50}\u{11A51}-\u{11A56}\u{11A57}-\u{11A58}\u{11A59}-\u{11A5B}\u{11A5C}-\u{11A89}\u{11A8A}-\u{11A96}\u{11A97}\u{11A98}-\u{11A99}\u{11A9A}-\u{11A9C}\u{11A9D}\u{11A9E}-\u{11AA2}\u{11AA3}-\u{11AAF}\u{11AB0}-\u{11ABF}\u{13000}-\u{1342E}\u{1342F}\u{13430}-\u{13438}\u{13439}-\u{1343F}\u{14400}-\u{14646}\u{14647}-\u{1467F}\u{16FE0}-\u{16FE1}\u{16FE2}\u{16FE3}\u{16FE4}\u{16FE5}-\u{16FEF}\u{16FF0}-\u{16FF1}\u{16FF2}-\u{16FFF}\u{17000}-\u{187F7}\u{187F8}-\u{187FF}\u{18800}-\u{18AFF}\u{18B00}-\u{18CD5}\u{18CD6}-\u{18CFF}\u{18D00}-\u{18D08}\u{18D09}-\u{18D7F}\u{1AFF0}-\u{1AFF3}\u{1AFF4}\u{1AFF5}-\u{1AFFB}\u{1AFFC}\u{1AFFD}-\u{1AFFE}\u{1AFFF}\u{1B000}-\u{1B0FF}\u{1B100}-\u{1B122}\u{1B123}-\u{1B12F}\u{1B130}-\u{1B14F}\u{1B150}-\u{1B152}\u{1B153}-\u{1B163}\u{1B164}-\u{1B167}\u{1B168}-\u{1B16F}\u{1B170}-\u{1B2FB}\u{1B2FC}-\u{1B2FF}\u{1CF00}-\u{1CF2D}\u{1CF2E}-\u{1CF2F}\u{1CF30}-\u{1CF46}\u{1CF47}-\u{1CF4F}\u{1CF50}-\u{1CFC3}\u{1CFC4}-\u{1CFCF}\u{1D000}-\u{1D0F5}\u{1D0F6}-\u{1D0FF}\u{1D100}-\u{1D126}\u{1D127}-\u{1D128}\u{1D129}-\u{1D164}\u{1D165}-\u{1D166}\u{1D167}-\u{1D169}\u{1D16A}-\u{1D16C}\u{1D16D}-\u{1D172}\u{1D173}-\u{1D17A}\u{1D17B}-\u{1D182}\u{1D183}-\u{1D184}\u{1D185}-\u{1D18B}\u{1D18C}-\u{1D1A9}\u{1D1AA}-\u{1D1AD}\u{1D1AE}-\u{1D1EA}\u{1D1EB}-\u{1D1FF}\u{1D2E0}-\u{1D2F3}\u{1D2F4}-\u{1D2FF}\u{1D300}-\u{1D356}\u{1D357}-\u{1D35F}\u{1D360}-\u{1D378}\u{1D379}-\u{1D37F}\u{1D800}-\u{1D9FF}\u{1DA00}-\u{1DA36}\u{1DA37}-\u{1DA3A}\u{1DA3B}-\u{1DA6C}\u{1DA6D}-\u{1DA74}\u{1DA75}\u{1DA76}-\u{1DA83}\u{1DA84}\u{1DA85}-\u{1DA86}\u{1DA87}-\u{1DA8B}\u{1DA8C}-\u{1DA9A}\u{1DA9B}-\u{1DA9F}\u{1DAA0}\u{1DAA1}-\u{1DAAF}\u{1F000}-\u{1F02B}\u{1F02C}-\u{1F02F}\u{1F030}-\u{1F093}\u{1F094}-\u{1F09F}\u{1F0A0}-\u{1F0AE}\u{1F0AF}-\u{1F0B0}\u{1F0B1}-\u{1F0BF}\u{1F0C0}\u{1F0C1}-\u{1F0CF}\u{1F0D0}\u{1F0D1}-\u{1F0F5}\u{1F0F6}-\u{1F0FF}\u{1F100}-\u{1F10C}\u{1F10D}-\u{1F1AD}\u{1F1AE}-\u{1F1E5}\u{1F1E6}-\u{1F1FF}\u{1F200}-\u{1F201}\u{1F202}\u{1F203}-\u{1F20F}\u{1F210}-\u{1F23B}\u{1F23C}-\u{1F23F}\u{1F240}-\u{1F248}\u{1F249}-\u{1F24F}\u{1F250}-\u{1F251}\u{1F252}-\u{1F25F}\u{1F260}-\u{1F265}\u{1F266}-\u{1F2FF}\u{1F300}-\u{1F3FA}\u{1F3FB}-\u{1F3FF}\u{1F400}-\u{1F5FF}\u{1F600}-\u{1F64F}\u{1F650}-\u{1F67F}\u{1F680}-\u{1F6D7}\u{1F6D8}-\u{1F6DC}\u{1F6DD}-\u{1F6EC}\u{1F6ED}-\u{1F6EF}\u{1F6F0}-\u{1F6FC}\u{1F6FD}-\u{1F6FF}\u{1F700}-\u{1F773}\u{1F774}-\u{1F77F}\u{1F780}-\u{1F7D8}\u{1F7D9}-\u{1F7DF}\u{1F7E0}-\u{1F7EB}\u{1F7EC}-\u{1F7EF}\u{1F7F0}\u{1F7F1}-\u{1F7FF}\u{1F900}-\u{1F9FF}\u{1FA00}-\u{1FA53}\u{1FA54}-\u{1FA5F}\u{1FA60}-\u{1FA6D}\u{1FA6E}-\u{1FA6F}\u{1FA70}-\u{1FA74}\u{1FA75}-\u{1FA77}\u{1FA78}-\u{1FA7C}\u{1FA7D}-\u{1FA7F}\u{1FA80}-\u{1FA86}\u{1FA87}-\u{1FA8F}\u{1FA90}-\u{1FAAC}\u{1FAAD}-\u{1FAAF}\u{1FAB0}-\u{1FABA}\u{1FABB}-\u{1FABF}\u{1FAC0}-\u{1FAC5}\u{1FAC6}-\u{1FACF}\u{1FAD0}-\u{1FAD9}\u{1FADA}-\u{1FADF}\u{1FAE0}-\u{1FAE7}\u{1FAE8}-\u{1FAEF}\u{1FAF0}-\u{1FAF6}\u{1FAF7}-\u{1FAFF}\u{20000}-\u{2A6DF}\u{2A6E0}-\u{2A6FF}\u{2A700}-\u{2B738}\u{2B739}-\u{2B73F}\u{2B740}-\u{2B81D}\u{2B81E}-\u{2B81F}\u{2B820}-\u{2CEA1}\u{2CEA2}-\u{2CEAF}\u{2CEB0}-\u{2EBE0}\u{2EBE1}-\u{2F7FF}\u{2F800}-\u{2FA1D}\u{2FA1E}-\u{2FFFD}\u{30000}-\u{3134A}\u{3134B}-\u{3134F}\u{31350}-\u{3FFFD}]/u,W=/[\u{2329}\u{232A}\u{3001}\u{3002}\u{3008}\u{3009}\u{300A}\u{300B}\u{300C}\u{300D}\u{300E}\u{300F}\u{3010}\u{3011}\u{3014}\u{3015}\u{3016}\u{3017}\u{3018}\u{3019}\u{301A}\u{301B}\u{301C}\u{301D}\u{301E}\u{301F}\u{3030}\u{3041}\u{3043}\u{3045}\u{3047}\u{3049}\u{3063}\u{3083}\u{3085}\u{3087}\u{308E}\u{3095}\u{3096}\u{309B}\u{309C}\u{30A0}\u{30A1}\u{30A3}\u{30A5}\u{30A7}\u{30A9}\u{30C3}\u{30E3}\u{30E5}\u{30E7}\u{30EE}\u{30F5}\u{30F6}\u{30FC}\u{3127}\u{31F0}\u{31F1}\u{31F2}\u{31F3}\u{31F4}\u{31F5}\u{31F6}\u{31F7}\u{31F8}\u{31F9}\u{31FA}\u{31FB}\u{31FC}\u{31FD}\u{31FE}\u{31FF}\u{32FF}\u{3300}\u{3301}\u{3302}\u{3303}\u{3304}\u{3305}\u{3306}\u{3307}\u{3308}\u{3309}\u{330A}\u{330B}\u{330C}\u{330D}\u{330E}\u{330F}\u{3310}\u{3311}\u{3312}\u{3313}\u{3314}\u{3315}\u{3316}\u{3317}\u{3318}\u{3319}\u{331A}\u{331B}\u{331C}\u{331D}\u{331E}\u{331F}\u{3320}\u{3321}\u{3322}\u{3323}\u{3324}\u{3325}\u{3326}\u{3327}\u{3328}\u{3329}\u{332A}\u{332B}\u{332C}\u{332D}\u{332E}\u{332F}\u{3330}\u{3331}\u{3332}\u{3333}\u{3334}\u{3335}\u{3336}\u{3337}\u{3338}\u{3339}\u{333A}\u{333B}\u{333C}\u{333D}\u{333E}\u{333F}\u{3340}\u{3341}\u{3342}\u{3343}\u{3344}\u{3345}\u{3346}\u{3347}\u{3348}\u{3349}\u{334A}\u{334B}\u{334C}\u{334D}\u{334E}\u{334F}\u{3350}\u{3351}\u{3352}\u{3353}\u{3354}\u{3355}\u{3356}\u{3357}\u{337B}\u{337C}\u{337D}\u{337E}\u{337F}\u{FE50}\u{FE51}\u{FE52}\u{FE59}\u{FE5A}\u{FE5B}\u{FE5C}\u{FE5D}\u{FE5E}\u{FF01}\u{FF08}\u{FF09}\u{FF0C}\u{FF0E}\u{FF1A}\u{FF1B}\u{FF1F}\u{FF3B}\u{FF3D}\u{FF3F}\u{FF5B}\u{FF5C}\u{FF5D}\u{FF5E}\u{FF5F}\u{FF60}\u{FFE3}\u{1F200}\u{1F201}]/u,_=/[\s\n\t\u200B\u200C\u200D\u200E\u200F.,?!:;"'(){}\[\]<>\/\\|~#\$%\*\+=&^,。?!:;“”‘’()【】《》……——]/u,j=/[\r\n]/;class R{constructor(t,e){this.content=t,this.parent=e,this.contentBox=new x,this.glyphBox=new x,this.baseline=0,this.verticalOrientation="U",this.isPunctuation=!1,this.isEOL=!1,this.update()}get computedStyle(){return this.parent.computedStyle}update(){switch(this.computedStyle.textOrientation){case"upright":this.verticalOrientation="U";break;case"sideways-right":case"sideways":this.verticalOrientation="R";break;case"mixed":default:this.verticalOrientation=K.test(this.content)?W.test(this.content)?"Tu":"U":W.test(this.content)?"Tr":"R";break}return this.isPunctuation=_.test(this.content),this.isEOL=j.test(this.content),this}measure(){const t=this.computedStyle,{width:e,height:n,glyphAscent:o,glyphLeft:c,glyphWidth:i,glyphHeight:B,lineHeight:A,baseline:D,centerX:g}=$(this.content,{...t,letterSpacing:0});switch(this.contentBox.width=e,this.contentBox.height=n,this.glyphBox.width=i,this.glyphBox.height=B,this.baseline=D,t.writingMode){case"vertical-lr":case"vertical-rl":{const d=t.fontSize*t.lineHeight;switch(this.verticalOrientation){case"Tr":case"R":this.contentBox.rotate90deg(),this.glyphBox.rotate90deg(),this.contentBox.x=(d-n)/2,this.glyphBox.x=(d-B)/2;break;case"U":{const{leading:a}=I(this.content,{...t,letterSpacing:0});this.contentBox.x=(d-e)/2,this.contentBox.y=a,this.glyphBox.x=(d-i)/2,this.glyphBox.y=0;break}case"Tu":this.contentBox.x=(d-e)/2,this.contentBox.y=0,this.glyphBox.x=this.contentBox.x+g-c,this.glyphBox.y=n-B;break}break}case"horizontal-tb":this.contentBox.x=0,this.contentBox.y=(A-n)/2,this.glyphBox.x=g-c,this.glyphBox.y=D-o;break}return this}clone(){const t=new R(this.content,this.parent);return t.contentBox=this.contentBox.clone(),t.glyphBox=this.glyphBox.clone(),t}}class T{constructor(t,e,n){this.content=t,this.style=e,this.parent=n,this.contentBox=new x,this.inlineBox=new x,this.glyphBox=new x,this.centerX=0,this.baseline=0,this.update()}update(){var n;this.computedStyle={...(n=this.parent)==null?void 0:n.computedStyle,...this.style};const t=this.computedStyle;this.computedContent=t.textTransform==="uppercase"?this.content.toUpperCase():t.textTransform==="lowercase"?this.content.toLowerCase():this.content;const e=[];for(const o of this.computedContent)e.push(new R(o,this));return this.characters=e,this}measure(){var e;const t=this.computedStyle;switch(t.writingMode){case"vertical-lr":case"vertical-rl":{let n=0,o=0,c=0;this.characters.forEach((i,B)=>{i.update().measure(),o=Math.max(o,i.contentBox.width),c=Math.max(c,i.glyphBox.width),n+=i.contentBox.y+i.contentBox.height,B!==this.characters.length-1&&(n+=t.letterSpacing)}),this.inlineBox.width=t.fontSize*t.lineHeight,this.inlineBox.height=n,this.contentBox.width=o,this.contentBox.height=n,this.glyphBox.width=c,this.glyphBox.height=n,this.baseline=((e=this.characters[0])==null?void 0:e.baseline)??0,this.centerX=n/2;break}case"horizontal-tb":{let n=0,o=0,c=0;this.characters.forEach((B,A)=>{B.update().measure(),o=Math.max(o,B.contentBox.height),c=Math.max(c,B.glyphBox.height),n+=B.contentBox.x+B.contentBox.width,A!==this.characters.length-1&&(n+=t.letterSpacing)}),this.inlineBox.width=n,this.inlineBox.height=t.fontSize*t.lineHeight,this.contentBox.width=n,this.contentBox.height=o,this.glyphBox.width=n,this.glyphBox.height=c,this.centerX=n/2,this.inlineBox.x=0,this.inlineBox.y=0;const i=this.characters[0];i&&(this.baseline=i.baseline,this.contentBox.x=i.contentBox.x,this.glyphBox.x=i.glyphBox.x),this.contentBox.y=(this.inlineBox.height-this.contentBox.height)/2,this.glyphBox.y=(this.inlineBox.height-this.glyphBox.height)/2;break}}return this}clone(t){return new T(t??this.content,this.style,this.parent)}}class v{constructor(t,e){this.style=t,this.parent=e,this.contentBox=new x,this.lineBox=new x,this.glyphBox=new x,this.baseline=0,this.xHeight=0,this.fragments=[],this.update()}update(){this.computedStyle={...this.parent,...this.style}}addFragment(t,e){return this.fragments.push(new T(t,e,this)),this}clone(t){const e=new v(this.style,this.parent);return e.contentBox=this.contentBox.clone(),e.lineBox=this.lineBox.clone(),e.glyphBox=this.glyphBox.clone(),e.baseline=this.baseline,e.xHeight=this.xHeight,e.fragments=t??this.fragments.map(n=>n.clone()),e}}function G(r,t){const e=[];if(typeof r=="string")e.push(new v(void 0,t).addFragment(r));else{r=Array.isArray(r)?r:[r];for(const n of r)if(typeof n=="string")e.push(new v(void 0,t).addFragment(n));else if(Array.isArray(n)){const o=new v(void 0,t);n.forEach(c=>{if(typeof c=="string")o.addFragment(c);else{const{content:i,...B}=c;o.addFragment(i,B)}}),e.push(o)}else if("fragments"in n){const{fragments:o,...c}=n,i=new v(c,t);o.forEach(B=>{const{content:A,...D}=B;i.addFragment(A,D)}),e.push(i)}else if("content"in n){const{content:o,...c}=n;e.push(new v(c,t).addFragment(o))}}return e}function V(r,t,e){var B;const n=[],o=r.slice();let c,i;for(;c=o.shift();){const A=c.fragments.slice();let D=0;const g=[];for(;i=A.shift();){const d=i.computedStyle;let a="",S=!1,k=0;const u=new T("",i.style,i.parent);for(const E of i.characters){if(u.content+=E.content,(B=i.characters[++k])!=null&&B.isPunctuation)continue;const C=E.isEOL;let p,F;switch(d.writingMode){case"vertical-lr":case"vertical-rl":p=e,F=u.update().measure().contentBox.height;break;case"horizontal-tb":default:p=t,F=u.update().measure().contentBox.width;break}if(C||p&&D+F>p){let l=C?a.length+1:a.length;!D&&!l&&(a+=u.computedContent,l+=u.computedContent.length),a.length&&g.push(i.clone(a)),g.length&&(n.push(c.clone(g.slice())),g.length=0);const h=i.computedContent.substring(l);(h.length||A.length)&&o.unshift(c.clone((h.length?[i.clone(h)]:[]).concat(A.slice()))),A.length=0,S=!0;break}else D+=F;a+=u.computedContent,u.content=""}S||g.push(i.clone())}g.length&&n.push(c.clone(g))}return n}const L={width:0,height:0,color:"#000",backgroundColor:"rgba(0, 0, 0, 0)",fontSize:14,fontWeight:"normal",fontFamily:"sans-serif",fontStyle:"normal",fontKerning:"normal",textWrap:"wrap",textAlign:"start",verticalAlign:"baseline",textTransform:"none",textDecoration:"none",textStrokeWidth:0,textStrokeColor:"#000",lineHeight:1,letterSpacing:0,shadowColor:"rgba(0, 0, 0, 0)",shadowOffsetX:0,shadowOffsetY:0,shadowBlur:0,writingMode:"horizontal-tb",textOrientation:"mixed"};function q(r){return{...L,...r}}function U(r){const{content:t,effects:e=[{}]}=r,{width:n,height:o,...c}=q(r.style);let i=G(t,c);i=V(i,n,o);let B=0,A=0;i.forEach(u=>{let E=null;u.fragments.forEach(s=>{s.update().measure(),(!E||E.contentBox.height<s.contentBox.height)&&(E=s)});const{glyphHeight:C,baseline:p}=$("x",(E??u).computedStyle);u.xHeight=C,u.baseline=p;const F=u.computedStyle;let l=B,h=A,y=0;u.fragments.forEach((s,f)=>{const m=s.computedStyle;switch(F.writingMode){case"vertical-rl":case"vertical-lr":{f||(h=0),s.inlineBox.translate(l,h),s.contentBox.translate(l,h),s.glyphBox.translate(l,h);let b=h;s.characters.forEach((w,O)=>{const z=w.contentBox.y+w.contentBox.height;w.contentBox.translate(l,b),w.glyphBox.translate(l,b),b+=z,O!==s.characters.length-1&&(b+=m.letterSpacing)}),h+=s.inlineBox.height,f===u.fragments.length-1&&(l+=s.inlineBox.width);break}case"horizontal-tb":{f||(l=0),s.inlineBox.translate(l,h),s.contentBox.translate(l,h),s.glyphBox.translate(l,h);let b=l;s.characters.forEach((w,O)=>{const z=w.contentBox.x+w.contentBox.width;w.contentBox.translate(b,h),w.glyphBox.translate(b,h),b+=z,O!==s.characters.length-1&&(b+=m.letterSpacing)}),l+=s.inlineBox.width,y=Math.max(y,s.inlineBox.height),f===u.fragments.length-1&&(h+=y);break}}}),B=l,A=h,u.lineBox=x.from(...u.fragments.map(s=>s.inlineBox))});const D=x.from(...i.map(u=>u.lineBox),new x(0,0,n,o)),{width:g,height:d}=D;i.forEach(u=>{let E=0;const C=0,p=u.computedStyle;switch(p.writingMode){case"vertical-rl":E+=g-(u.lineBox.x*2+u.lineBox.width);case"vertical-lr":u.lineBox.height=Math.max(u.lineBox.height,d);break;case"horizontal-tb":u.lineBox.width=Math.max(u.lineBox.width,g);break}u.contentBox=x.from(...u.fragments.map(F=>F.contentBox)),u.glyphBox=x.from(...u.fragments.map(F=>F.glyphBox)),u.fragments.forEach(F=>{let l=E,h=C;const y=F.computedStyle;switch(p.writingMode){case"vertical-rl":case"vertical-lr":{switch(y.textAlign){case"end":case"right":h+=d-u.contentBox.height;break;case"center":h+=(d-u.contentBox.height)/2;break}F.characters.forEach(s=>{let f=l;const m=h;switch(y.verticalAlign){case"top":case"middle":case"bottom":case"sub":case"super":case"text-top":case"text-bottom":case"baseline":default:f+=u.baseline-s.baseline;break}s.contentBox.translate(f,m),s.glyphBox.translate(f,m)});break}case"horizontal-tb":{switch(y.textAlign){case"end":case"right":l=g-u.contentBox.width;break;case"center":l=(g-u.contentBox.width)/2;break}switch(y.verticalAlign){case"top":h=u.lineBox.y-F.inlineBox.y;break;case"middle":h=F.inlineBox.y-(u.baseline-u.xHeight/2-F.inlineBox.height/2);break;case"bottom":h=u.lineBox.bottom-F.inlineBox.bottom;break;case"sub":h=u.lineBox.y+u.baseline-F.glyphBox.bottom;break;case"super":h=u.lineBox.y+u.baseline-F.glyphBox.y;break;case"text-top":h=u.glyphBox.y-F.inlineBox.y;break;case"text-bottom":h=u.glyphBox.bottom-F.inlineBox.bottom;break;case"baseline":default:F.inlineBox.height<u.lineBox.height&&(h=u.baseline-F.baseline);break}break}}F.characters.forEach(s=>{s.contentBox.translate(l,h),s.glyphBox.translate(l,h)}),F.inlineBox.translate(l,h),F.contentBox.translate(l,h),F.glyphBox.translate(l,h)}),u.lineBox=x.from(u.lineBox,...u.fragments.map(F=>F.inlineBox)),u.contentBox=x.from(...u.fragments.map(F=>F.contentBox)),u.glyphBox=x.from(...u.fragments.map(F=>F.glyphBox))});const a=x.from(...i.map(u=>u.contentBox)),S=x.from(...i.map(u=>u.glyphBox)),k=[];return i.forEach(u=>{u.fragments.forEach(E=>{const C=E.computedStyle;e.forEach(p=>{const F={...C,...p},{textStrokeWidth:l=0,offsetX:h=0,offsetY:y=0}=F;if(l||h||y){const{x:s,y:f,width:m,height:b}=E.contentBox;k.push(new x(Math.min(s,s+h-l/2),Math.min(f,f+y-l/2),Math.max(m,m+h+l),Math.max(b,b+y+l)))}})})}),{box:D,contentBox:a,glyphBox:S,paragraphs:i,viewBox:x.from(D,S,...k)}}function H(r,t,e){if(typeof t=="string"&&t.startsWith("linear-gradient")){const{x0:n,y0:o,x1:c,y1:i,stops:B}=J(t,e.left,e.top,e.width,e.height),A=r.createLinearGradient(n,o,c,i);return B.forEach(D=>A.addColorStop(D.offset,D.color)),A}return t}function J(r,t,e,n,o){var S;const c=((S=r.match(/linear-gradient\((.+)\)$/))==null?void 0:S[1])??"",i=c.split(",")[0],B=i.includes("deg")?i:"0deg",A=c.replace(B,"").matchAll(/(#|rgba|rgb)(.+?) ([\d.]+?%)/gi),g=(Number(B.replace("deg",""))||0)*Math.PI/180,d=n*Math.sin(g),a=o*Math.cos(g);return{x0:t+n/2-d,y0:e+o/2+a,x1:t+n/2+d,y1:e+o/2-a,stops:Array.from(A).map(k=>{let u=k[2];return u.startsWith("(")?u=u.split(",").length>3?`rgba${u}`:`rgb${u}`:u=`#${u}`,{offset:Number(k[3].replace("%",""))/100,color:u}})}}function M(r,t,e){e!=null&&e.color&&(e.color=H(r,e.color,t)),e!=null&&e.backgroundColor&&(e.backgroundColor=H(r,e.backgroundColor,t)),e!=null&&e.textStrokeColor&&(e.textStrokeColor=H(r,e.textStrokeColor,t))}function Q(r){const{view:t=document.createElement("canvas"),style:e,effects:n=[],pixelRatio:o=1}=r,c=n.length>0?n:[{}],{viewBox:i,paragraphs:B}=U(r),{x:A,y:D,width:g,height:d}=i,a=t.getContext("2d");t.style.width=`${g}px`,t.style.height=`${d}px`,t.dataset.viewbox=`${A} ${D} ${g} ${d}`,t.dataset.pixelRatio=String(o),t.width=Math.max(1,Math.floor(g*o)),t.height=Math.max(1,Math.floor(d*o)),a.scale(o,o),a.clearRect(0,0,t.width,t.height);const S=(u,E,C,p,F)=>{a.fillStyle=u,a.fillRect(-i.x+E,-i.y+C,p,F)},k={...e};return M(a,new x(0,0,g,d),k),B.forEach(u=>{M(a,u.contentBox,u.computedStyle),u.fragments.forEach(E=>{M(a,E.contentBox,E.computedStyle)})}),c.forEach(u=>{const E={...u};M(a,new x(0,0,g,d),E);const C={...k,...E};C!=null&&C.backgroundColor&&S(C.backgroundColor,0,0,t.width,t.height),B.forEach(p=>{var F;(F=p.style)!=null&&F.backgroundColor&&S(p.computedStyle.backgroundColor,...p.lineBox.toArray()),p.fragments.forEach(l=>{var h;(h=l.style)!=null&&h.backgroundColor&&S(l.computedStyle.backgroundColor,...l.inlineBox.toArray())})}),B.forEach(p=>{p.fragments.forEach(F=>{const l=-i.x+(E.offsetX??0),h=-i.y+(E.offsetY??0),y={...F.computedStyle,...E};switch(P(a,{...y,textAlign:"left"}),y.writingMode){case"vertical-rl":case"vertical-lr":{F.characters.forEach(s=>{let f=0,m=0;switch(s.verticalOrientation){case"Tr":case"R":{a.rotate(Math.PI/2),a.textBaseline="alphabetic",m=-(l+F.inlineBox.x+F.inlineBox.width-s.baseline),f=h+s.contentBox.y;break}case"Tu":a.textBaseline="top",f=l+s.contentBox.x+s.contentBox.right-s.glyphBox.right,m=h+s.contentBox.y+s.contentBox.y-s.glyphBox.y;break;case"U":f=l+s.contentBox.x,m=h+s.contentBox.y,a.textBaseline="top";break}a.fillText(s.content,f,m),y.textStrokeWidth&&a.strokeText(s.content,f,m),a.setTransform(1,0,0,1,0,0),a.scale(o,o)});break}case"horizontal-tb":{const s=l+F.contentBox.x,f=h+F.contentBox.y,m=h+F.inlineBox.y+F.baseline;a.textBaseline="alphabetic",a.fillText(F.computedContent,s,m),y.textStrokeWidth&&a.strokeText(F.computedContent,s,m);const{width:b,height:w}=F.contentBox;switch(y.textDecoration){case"underline":a.strokeStyle=a.fillStyle,a.lineWidth=y.fontSize/15,a.beginPath(),a.moveTo(s,f+w),a.lineTo(s+b,f+w),a.stroke();break;case"line-through":a.strokeStyle=a.fillStyle,a.lineWidth=y.fontSize/15,a.beginPath(),a.moveTo(s,f+w/2),a.lineTo(s+b,f+w/2),a.stroke();break}break}}})})}),t}exports.defaultTextStyles=L;exports.measureText=U;exports.renderText=Q;
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});class A{constructor(t=0,e=0,n=0,o=0){this.x=t,this.y=e,this.width=n,this.height=o}get left(){return this.x}get top(){return this.y}get right(){return this.x+this.width}get bottom(){return this.y+this.height}static from(...t){const e=t[0],n=t.slice(1).reduce((o,r)=>(o.x=Math.min(o.x,r.x),o.y=Math.min(o.y,r.y),o.right=Math.max(o.right,r.right),o.bottom=Math.max(o.bottom,r.bottom),o),{x:e.x,y:e.y,right:e.right,bottom:e.bottom});return new A(n.x,n.y,n.right-n.x,n.bottom-n.y)}rotate90deg(){const{width:t,height:e}=this;this.width=e,this.height=t}translate(t,e){return this.x+=t,this.y+=e,this}clone(){return new A(this.x,this.y,this.width,this.height)}toArray(){return[this.x,this.y,this.width,this.height]}}function P(h,t){switch(h.shadowColor=t.shadowColor||"rgba(0, 0, 0, 0)",h.shadowOffsetX=t.shadowOffsetX||0,h.shadowOffsetY=t.shadowOffsetY||0,h.shadowBlur=t.shadowBlur||0,h.strokeStyle=t.textStrokeColor||"#000",h.lineWidth=t.textStrokeWidth||0,h.fillStyle=t.color||"#000",h.textAlign=t.textAlign||"start",h.fontKerning=t.fontKerning||"normal",t.verticalAlign){case"top":case"middle":case"bottom":h.textBaseline=t.verticalAlign;break;case"baseline":default:h.textBaseline="alphabetic";break}h.font=[t.fontStyle||"normal",t.fontWeight||"normal",`${t.fontSize||14}px`,t.fontFamily||"sans-serif"].join(" "),h.letterSpacing=`${t.letterSpacing||0}px`}const X="OffscreenCanvas"in globalThis;let N;function Y(){return N??(N=X?new OffscreenCanvas(1,1):document.createElement("canvas"))}function $(h,t){const e=Y().getContext("2d");P(e,{...t,textAlign:"center",verticalAlign:"baseline"});const{width:n,actualBoundingBoxAscent:o,actualBoundingBoxDescent:r,actualBoundingBoxLeft:i,actualBoundingBoxRight:B,fontBoundingBoxAscent:E,fontBoundingBoxDescent:D}=e.measureText(h),g=t.fontSize*t.lineHeight,d=E+D;return{width:n,height:t.fontSize,typoAscent:E,typoDescent:D,typoHeight:d,lineHeight:g,glyphLeft:i,glyphRight:B,glyphAscent:o,glyphDescent:r,glyphWidth:i+B,glyphHeight:o+r,baseline:(g-d)/2+E,centerX:n/2}}function I(h,t){const e=document.createDocumentFragment(),n=document.createElement("div");n.style.position="absolute",n.style.visibility="hidden",n.setAttribute("aria-hidden","true"),n.style.fontFamily=t.fontFamily,n.style.fontSize=`${t.fontSize}px`,n.style.lineHeight=String(t.lineHeight),n.style.whiteSpace="nowrap",n.style.writingMode=t.writingMode;const o=document.createElement("span");o.textContent=/\s/.test(h)?" ":h,n.appendChild(o),e.appendChild(n),document.body.appendChild(e);const r={leading:o.offsetHeight-t.fontSize};return document.body.removeChild(n),r}const K=/[\u{00A7}\u{00A9}\u{00AE}\u{00B1}\u{00BC}-\u{00BE}\u{00D7}\u{00F7}\u{02EA}-\u{02EB}\u{1100}-\u{11FF}\u{1401}-\u{166C}\u{166D}\u{166E}\u{166F}-\u{167F}\u{18B0}-\u{18F5}\u{18F6}-\u{18FF}\u{2016}\u{2020}-\u{2021}\u{2030}-\u{2031}\u{203B}-\u{203C}\u{2042}\u{2047}-\u{2049}\u{2051}\u{2065}\u{20DD}-\u{20E0}\u{20E2}-\u{20E4}\u{2100}-\u{2101}\u{2103}-\u{2106}\u{2107}\u{2108}-\u{2109}\u{210F}\u{2113}\u{2114}\u{2116}-\u{2117}\u{211E}-\u{2123}\u{2125}\u{2127}\u{2129}\u{212E}\u{2135}-\u{2138}\u{2139}\u{213A}-\u{213B}\u{213C}-\u{213F}\u{2145}-\u{2149}\u{214A}\u{214C}-\u{214D}\u{214F}\u{2150}-\u{215F}\u{2160}-\u{2182}\u{2183}-\u{2184}\u{2185}-\u{2188}\u{2189}\u{218C}-\u{218F}\u{221E}\u{2234}-\u{2235}\u{2300}-\u{2307}\u{230C}-\u{231F}\u{2324}-\u{2328}\u{232B}\u{237D}-\u{239A}\u{23BE}-\u{23CD}\u{23CF}\u{23D1}-\u{23DB}\u{23E2}-\u{23FF}\u{2400}-\u{2422}\u{2424}-\u{2426}\u{2427}-\u{243F}\u{2440}-\u{244A}\u{244B}-\u{245F}\u{2460}-\u{249B}\u{249C}-\u{24E9}\u{24EA}-\u{24FF}\u{25A0}-\u{25B6}\u{25B7}\u{25B8}-\u{25C0}\u{25C1}\u{25C2}-\u{25F7}\u{25F8}-\u{25FF}\u{2600}-\u{2619}\u{2620}-\u{266E}\u{266F}\u{2670}-\u{26FF}\u{2700}-\u{2767}\u{2776}-\u{2793}\u{2B12}-\u{2B2F}\u{2B50}-\u{2B59}\u{2B97}\u{2BB8}-\u{2BD1}\u{2BD3}-\u{2BEB}\u{2BF0}-\u{2BFF}\u{2E50}-\u{2E51}\u{2E80}-\u{2E99}\u{2E9A}\u{2E9B}-\u{2EF3}\u{2EF4}-\u{2EFF}\u{2F00}-\u{2FD5}\u{2FD6}-\u{2FDF}\u{2FE0}-\u{2FEF}\u{2FF0}-\u{2FFB}\u{2FFC}-\u{2FFF}\u{3000}\u{3001}-\u{3002}\u{3003}\u{3004}\u{3005}\u{3006}\u{3007}\u{3012}-\u{3013}\u{3020}\u{3021}-\u{3029}\u{302A}-\u{302D}\u{302E}-\u{302F}\u{3031}-\u{3035}\u{3036}-\u{3037}\u{3038}-\u{303A}\u{303B}\u{303C}\u{303D}\u{303E}-\u{303F}\u{3040}\u{3041}\u{3042}\u{3043}\u{3044}\u{3045}\u{3046}\u{3047}\u{3048}\u{3049}\u{304A}-\u{3062}\u{3063}\u{3064}-\u{3082}\u{3083}\u{3084}\u{3085}\u{3086}\u{3087}\u{3088}-\u{308D}\u{308E}\u{308F}-\u{3094}\u{3095}-\u{3096}\u{3097}-\u{3098}\u{3099}-\u{309A}\u{309B}-\u{309C}\u{309D}-\u{309E}\u{309F}\u{30A1}\u{30A2}\u{30A3}\u{30A4}\u{30A5}\u{30A6}\u{30A7}\u{30A8}\u{30A9}\u{30AA}-\u{30C2}\u{30C3}\u{30C4}-\u{30E2}\u{30E3}\u{30E4}\u{30E5}\u{30E6}\u{30E7}\u{30E8}-\u{30ED}\u{30EE}\u{30EF}-\u{30F4}\u{30F5}-\u{30F6}\u{30F7}-\u{30FA}\u{30FB}\u{30FD}-\u{30FE}\u{30FF}\u{3100}-\u{3104}\u{3105}-\u{3126}\u{3127}\u{3128}-\u{312F}\u{3130}\u{3131}-\u{318E}\u{318F}\u{3190}-\u{3191}\u{3192}-\u{3195}\u{3196}-\u{319F}\u{31A0}-\u{31BF}\u{31C0}-\u{31E3}\u{31E4}-\u{31EF}\u{31F0}-\u{31FF}\u{3200}-\u{321E}\u{321F}\u{3220}-\u{3229}\u{322A}-\u{3247}\u{3248}-\u{324F}\u{3250}\u{3251}-\u{325F}\u{3260}-\u{327F}\u{3280}-\u{3289}\u{328A}-\u{32B0}\u{32B1}-\u{32BF}\u{32C0}-\u{32FE}\u{32FF}\u{3300}-\u{3357}\u{3358}-\u{337A}\u{337B}-\u{337F}\u{3380}-\u{33FF}\u{3400}-\u{4DBF}\u{4DC0}-\u{4DFF}\u{4E00}-\u{9FFF}\u{A000}-\u{A014}\u{A015}\u{A016}-\u{A48C}\u{A48D}-\u{A48F}\u{A490}-\u{A4C6}\u{A4C7}-\u{A4CF}\u{A960}-\u{A97C}\u{A97D}-\u{A97F}\u{AC00}-\u{D7A3}\u{D7A4}-\u{D7AF}\u{D7B0}-\u{D7C6}\u{D7C7}-\u{D7CA}\u{D7CB}-\u{D7FB}\u{D7FC}-\u{D7FF}\u{E000}-\u{F8FF}\u{F900}-\u{FA6D}\u{FA6E}-\u{FA6F}\u{FA70}-\u{FAD9}\u{FADA}-\u{FAFF}\u{FE10}-\u{FE16}\u{FE17}\u{FE18}\u{FE19}\u{FE1A}-\u{FE1F}\u{FE30}\u{FE31}-\u{FE32}\u{FE33}-\u{FE34}\u{FE35}\u{FE36}\u{FE37}\u{FE38}\u{FE39}\u{FE3A}\u{FE3B}\u{FE3C}\u{FE3D}\u{FE3E}\u{FE3F}\u{FE40}\u{FE41}\u{FE42}\u{FE43}\u{FE44}\u{FE45}-\u{FE46}\u{FE47}\u{FE48}\u{FE50}-\u{FE52}\u{FE53}\u{FE54}-\u{FE57}\u{FE5F}-\u{FE61}\u{FE62}\u{FE67}\u{FE68}\u{FE69}\u{FE6A}-\u{FE6B}\u{FE6C}-\u{FE6F}\u{FF01}\u{FF02}-\u{FF03}\u{FF04}\u{FF05}-\u{FF07}\u{FF0A}\u{FF0B}\u{FF0C}\u{FF0E}\u{FF0F}\u{FF10}-\u{FF19}\u{FF1F}\u{FF20}\u{FF21}-\u{FF3A}\u{FF3C}\u{FF3E}\u{FF40}\u{FF41}-\u{FF5A}\u{FFE0}-\u{FFE1}\u{FFE2}\u{FFE4}\u{FFE5}-\u{FFE6}\u{FFE7}\u{FFF0}-\u{FFF8}\u{FFFC}-\u{FFFD}\u{10980}-\u{1099F}\u{11580}-\u{115AE}\u{115AF}-\u{115B1}\u{115B2}-\u{115B5}\u{115B6}-\u{115B7}\u{115B8}-\u{115BB}\u{115BC}-\u{115BD}\u{115BE}\u{115BF}-\u{115C0}\u{115C1}-\u{115D7}\u{115D8}-\u{115DB}\u{115DC}-\u{115DD}\u{115DE}-\u{115FF}\u{11A00}\u{11A01}-\u{11A0A}\u{11A0B}-\u{11A32}\u{11A33}-\u{11A38}\u{11A39}\u{11A3A}\u{11A3B}-\u{11A3E}\u{11A3F}-\u{11A46}\u{11A47}\u{11A48}-\u{11A4F}\u{11A50}\u{11A51}-\u{11A56}\u{11A57}-\u{11A58}\u{11A59}-\u{11A5B}\u{11A5C}-\u{11A89}\u{11A8A}-\u{11A96}\u{11A97}\u{11A98}-\u{11A99}\u{11A9A}-\u{11A9C}\u{11A9D}\u{11A9E}-\u{11AA2}\u{11AA3}-\u{11AAF}\u{11AB0}-\u{11ABF}\u{13000}-\u{1342E}\u{1342F}\u{13430}-\u{13438}\u{13439}-\u{1343F}\u{14400}-\u{14646}\u{14647}-\u{1467F}\u{16FE0}-\u{16FE1}\u{16FE2}\u{16FE3}\u{16FE4}\u{16FE5}-\u{16FEF}\u{16FF0}-\u{16FF1}\u{16FF2}-\u{16FFF}\u{17000}-\u{187F7}\u{187F8}-\u{187FF}\u{18800}-\u{18AFF}\u{18B00}-\u{18CD5}\u{18CD6}-\u{18CFF}\u{18D00}-\u{18D08}\u{18D09}-\u{18D7F}\u{1AFF0}-\u{1AFF3}\u{1AFF4}\u{1AFF5}-\u{1AFFB}\u{1AFFC}\u{1AFFD}-\u{1AFFE}\u{1AFFF}\u{1B000}-\u{1B0FF}\u{1B100}-\u{1B122}\u{1B123}-\u{1B12F}\u{1B130}-\u{1B14F}\u{1B150}-\u{1B152}\u{1B153}-\u{1B163}\u{1B164}-\u{1B167}\u{1B168}-\u{1B16F}\u{1B170}-\u{1B2FB}\u{1B2FC}-\u{1B2FF}\u{1CF00}-\u{1CF2D}\u{1CF2E}-\u{1CF2F}\u{1CF30}-\u{1CF46}\u{1CF47}-\u{1CF4F}\u{1CF50}-\u{1CFC3}\u{1CFC4}-\u{1CFCF}\u{1D000}-\u{1D0F5}\u{1D0F6}-\u{1D0FF}\u{1D100}-\u{1D126}\u{1D127}-\u{1D128}\u{1D129}-\u{1D164}\u{1D165}-\u{1D166}\u{1D167}-\u{1D169}\u{1D16A}-\u{1D16C}\u{1D16D}-\u{1D172}\u{1D173}-\u{1D17A}\u{1D17B}-\u{1D182}\u{1D183}-\u{1D184}\u{1D185}-\u{1D18B}\u{1D18C}-\u{1D1A9}\u{1D1AA}-\u{1D1AD}\u{1D1AE}-\u{1D1EA}\u{1D1EB}-\u{1D1FF}\u{1D2E0}-\u{1D2F3}\u{1D2F4}-\u{1D2FF}\u{1D300}-\u{1D356}\u{1D357}-\u{1D35F}\u{1D360}-\u{1D378}\u{1D379}-\u{1D37F}\u{1D800}-\u{1D9FF}\u{1DA00}-\u{1DA36}\u{1DA37}-\u{1DA3A}\u{1DA3B}-\u{1DA6C}\u{1DA6D}-\u{1DA74}\u{1DA75}\u{1DA76}-\u{1DA83}\u{1DA84}\u{1DA85}-\u{1DA86}\u{1DA87}-\u{1DA8B}\u{1DA8C}-\u{1DA9A}\u{1DA9B}-\u{1DA9F}\u{1DAA0}\u{1DAA1}-\u{1DAAF}\u{1F000}-\u{1F02B}\u{1F02C}-\u{1F02F}\u{1F030}-\u{1F093}\u{1F094}-\u{1F09F}\u{1F0A0}-\u{1F0AE}\u{1F0AF}-\u{1F0B0}\u{1F0B1}-\u{1F0BF}\u{1F0C0}\u{1F0C1}-\u{1F0CF}\u{1F0D0}\u{1F0D1}-\u{1F0F5}\u{1F0F6}-\u{1F0FF}\u{1F100}-\u{1F10C}\u{1F10D}-\u{1F1AD}\u{1F1AE}-\u{1F1E5}\u{1F1E6}-\u{1F1FF}\u{1F200}-\u{1F201}\u{1F202}\u{1F203}-\u{1F20F}\u{1F210}-\u{1F23B}\u{1F23C}-\u{1F23F}\u{1F240}-\u{1F248}\u{1F249}-\u{1F24F}\u{1F250}-\u{1F251}\u{1F252}-\u{1F25F}\u{1F260}-\u{1F265}\u{1F266}-\u{1F2FF}\u{1F300}-\u{1F3FA}\u{1F3FB}-\u{1F3FF}\u{1F400}-\u{1F5FF}\u{1F600}-\u{1F64F}\u{1F650}-\u{1F67F}\u{1F680}-\u{1F6D7}\u{1F6D8}-\u{1F6DC}\u{1F6DD}-\u{1F6EC}\u{1F6ED}-\u{1F6EF}\u{1F6F0}-\u{1F6FC}\u{1F6FD}-\u{1F6FF}\u{1F700}-\u{1F773}\u{1F774}-\u{1F77F}\u{1F780}-\u{1F7D8}\u{1F7D9}-\u{1F7DF}\u{1F7E0}-\u{1F7EB}\u{1F7EC}-\u{1F7EF}\u{1F7F0}\u{1F7F1}-\u{1F7FF}\u{1F900}-\u{1F9FF}\u{1FA00}-\u{1FA53}\u{1FA54}-\u{1FA5F}\u{1FA60}-\u{1FA6D}\u{1FA6E}-\u{1FA6F}\u{1FA70}-\u{1FA74}\u{1FA75}-\u{1FA77}\u{1FA78}-\u{1FA7C}\u{1FA7D}-\u{1FA7F}\u{1FA80}-\u{1FA86}\u{1FA87}-\u{1FA8F}\u{1FA90}-\u{1FAAC}\u{1FAAD}-\u{1FAAF}\u{1FAB0}-\u{1FABA}\u{1FABB}-\u{1FABF}\u{1FAC0}-\u{1FAC5}\u{1FAC6}-\u{1FACF}\u{1FAD0}-\u{1FAD9}\u{1FADA}-\u{1FADF}\u{1FAE0}-\u{1FAE7}\u{1FAE8}-\u{1FAEF}\u{1FAF0}-\u{1FAF6}\u{1FAF7}-\u{1FAFF}\u{20000}-\u{2A6DF}\u{2A6E0}-\u{2A6FF}\u{2A700}-\u{2B738}\u{2B739}-\u{2B73F}\u{2B740}-\u{2B81D}\u{2B81E}-\u{2B81F}\u{2B820}-\u{2CEA1}\u{2CEA2}-\u{2CEAF}\u{2CEB0}-\u{2EBE0}\u{2EBE1}-\u{2F7FF}\u{2F800}-\u{2FA1D}\u{2FA1E}-\u{2FFFD}\u{30000}-\u{3134A}\u{3134B}-\u{3134F}\u{31350}-\u{3FFFD}]/u,W=/[\u{2329}\u{232A}\u{3001}\u{3002}\u{3008}\u{3009}\u{300A}\u{300B}\u{300C}\u{300D}\u{300E}\u{300F}\u{3010}\u{3011}\u{3014}\u{3015}\u{3016}\u{3017}\u{3018}\u{3019}\u{301A}\u{301B}\u{301C}\u{301D}\u{301E}\u{301F}\u{3030}\u{3041}\u{3043}\u{3045}\u{3047}\u{3049}\u{3063}\u{3083}\u{3085}\u{3087}\u{308E}\u{3095}\u{3096}\u{309B}\u{309C}\u{30A0}\u{30A1}\u{30A3}\u{30A5}\u{30A7}\u{30A9}\u{30C3}\u{30E3}\u{30E5}\u{30E7}\u{30EE}\u{30F5}\u{30F6}\u{30FC}\u{3127}\u{31F0}\u{31F1}\u{31F2}\u{31F3}\u{31F4}\u{31F5}\u{31F6}\u{31F7}\u{31F8}\u{31F9}\u{31FA}\u{31FB}\u{31FC}\u{31FD}\u{31FE}\u{31FF}\u{32FF}\u{3300}\u{3301}\u{3302}\u{3303}\u{3304}\u{3305}\u{3306}\u{3307}\u{3308}\u{3309}\u{330A}\u{330B}\u{330C}\u{330D}\u{330E}\u{330F}\u{3310}\u{3311}\u{3312}\u{3313}\u{3314}\u{3315}\u{3316}\u{3317}\u{3318}\u{3319}\u{331A}\u{331B}\u{331C}\u{331D}\u{331E}\u{331F}\u{3320}\u{3321}\u{3322}\u{3323}\u{3324}\u{3325}\u{3326}\u{3327}\u{3328}\u{3329}\u{332A}\u{332B}\u{332C}\u{332D}\u{332E}\u{332F}\u{3330}\u{3331}\u{3332}\u{3333}\u{3334}\u{3335}\u{3336}\u{3337}\u{3338}\u{3339}\u{333A}\u{333B}\u{333C}\u{333D}\u{333E}\u{333F}\u{3340}\u{3341}\u{3342}\u{3343}\u{3344}\u{3345}\u{3346}\u{3347}\u{3348}\u{3349}\u{334A}\u{334B}\u{334C}\u{334D}\u{334E}\u{334F}\u{3350}\u{3351}\u{3352}\u{3353}\u{3354}\u{3355}\u{3356}\u{3357}\u{337B}\u{337C}\u{337D}\u{337E}\u{337F}\u{FE50}\u{FE51}\u{FE52}\u{FE59}\u{FE5A}\u{FE5B}\u{FE5C}\u{FE5D}\u{FE5E}\u{FF01}\u{FF08}\u{FF09}\u{FF0C}\u{FF0E}\u{FF1A}\u{FF1B}\u{FF1F}\u{FF3B}\u{FF3D}\u{FF3F}\u{FF5B}\u{FF5C}\u{FF5D}\u{FF5E}\u{FF5F}\u{FF60}\u{FFE3}\u{1F200}\u{1F201}]/u,_=/[\s\n\t\u200B\u200C\u200D\u200E\u200F.,?!:;"'(){}\[\]<>\/\\|~#\$%\*\+=&^,。?!:;“”‘’()【】《》……——]/u,j=/[\r\n]/;class R{constructor(t,e){this.content=t,this.parent=e,this.contentBox=new A,this.glyphBox=new A,this.baseline=0,this.verticalOrientation="U",this.isPunctuation=!1,this.isEOL=!1,this.update()}get computedStyle(){return this.parent.computedStyle}update(){switch(this.computedStyle.textOrientation){case"upright":this.verticalOrientation="U";break;case"sideways-right":case"sideways":this.verticalOrientation="R";break;case"mixed":default:this.verticalOrientation=K.test(this.content)?W.test(this.content)?"Tu":"U":W.test(this.content)?"Tr":"R";break}return this.isPunctuation=_.test(this.content),this.isEOL=j.test(this.content),this}measure(){const t=this.computedStyle,{width:e,height:n,glyphAscent:o,glyphLeft:r,glyphWidth:i,glyphHeight:B,lineHeight:E,baseline:D,centerX:g}=$(this.content,{...t,letterSpacing:0});switch(this.contentBox.width=e,this.contentBox.height=n,this.glyphBox.width=i,this.glyphBox.height=B,this.baseline=D,t.writingMode){case"vertical-lr":case"vertical-rl":{const d=t.fontSize*t.lineHeight;switch(this.verticalOrientation){case"Tr":case"R":this.contentBox.rotate90deg(),this.glyphBox.rotate90deg(),this.contentBox.x=(d-n)/2,this.glyphBox.x=(d-B)/2;break;case"U":{const{leading:a}=I(this.content,{...t,letterSpacing:0});this.contentBox.x=(d-e)/2,this.contentBox.y=a,this.glyphBox.x=(d-i)/2,this.glyphBox.y=0;break}case"Tu":this.contentBox.x=(d-e)/2,this.contentBox.y=0,this.glyphBox.x=this.contentBox.x+g-r,this.glyphBox.y=n-B;break}break}case"horizontal-tb":this.contentBox.x=0,this.contentBox.y=(E-n)/2,this.glyphBox.x=g-r,this.glyphBox.y=D-o;break}return this}clone(){const t=new R(this.content,this.parent);return t.contentBox=this.contentBox.clone(),t.glyphBox=this.glyphBox.clone(),t}}class T{constructor(t,e,n){this.content=t,this.style=e,this.parent=n,this.contentBox=new A,this.inlineBox=new A,this.glyphBox=new A,this.centerX=0,this.baseline=0,this.update()}update(){var n;this.computedStyle={...(n=this.parent)==null?void 0:n.computedStyle,...this.style};const t=this.computedStyle;this.computedContent=t.textTransform==="uppercase"?this.content.toUpperCase():t.textTransform==="lowercase"?this.content.toLowerCase():this.content;const e=[];for(const o of this.computedContent)e.push(new R(o,this));return this.characters=e,this}measure(){var e;const t=this.computedStyle;switch(t.writingMode){case"vertical-lr":case"vertical-rl":{let n=0,o=0,r=0;this.characters.forEach((i,B)=>{i.update().measure(),o=Math.max(o,i.contentBox.width),r=Math.max(r,i.glyphBox.width),n+=i.contentBox.y+i.contentBox.height,B!==this.characters.length-1&&(n+=t.letterSpacing)}),this.inlineBox.width=t.fontSize*t.lineHeight,this.inlineBox.height=n,this.contentBox.width=o,this.contentBox.height=n,this.glyphBox.width=r,this.glyphBox.height=n,this.baseline=((e=this.characters[0])==null?void 0:e.baseline)??0,this.centerX=n/2;break}case"horizontal-tb":{let n=0,o=0,r=0;this.characters.forEach((B,E)=>{B.update().measure(),o=Math.max(o,B.contentBox.height),r=Math.max(r,B.glyphBox.height),n+=B.contentBox.x+B.contentBox.width,E!==this.characters.length-1&&(n+=t.letterSpacing)}),this.inlineBox.width=n,this.inlineBox.height=t.fontSize*t.lineHeight,this.contentBox.width=n,this.contentBox.height=o,this.glyphBox.width=n,this.glyphBox.height=r,this.centerX=n/2,this.inlineBox.x=0,this.inlineBox.y=0;const i=this.characters[0];i&&(this.baseline=i.baseline,this.contentBox.x=i.contentBox.x,this.glyphBox.x=i.glyphBox.x),this.contentBox.y=(this.inlineBox.height-this.contentBox.height)/2,this.glyphBox.y=(this.inlineBox.height-this.glyphBox.height)/2;break}}return this}clone(t){return new T(t??this.content,this.style,this.parent)}}class v{constructor(t,e){this.style=t,this.parent=e,this.contentBox=new A,this.lineBox=new A,this.glyphBox=new A,this.baseline=0,this.xHeight=0,this.fragments=[],this.update()}update(){this.computedStyle={...this.parent,...this.style}}addFragment(t,e){return this.fragments.push(new T(t,e,this)),this}clone(t){const e=new v(this.style,this.parent);return e.contentBox=this.contentBox.clone(),e.lineBox=this.lineBox.clone(),e.glyphBox=this.glyphBox.clone(),e.baseline=this.baseline,e.xHeight=this.xHeight,e.fragments=t??this.fragments.map(n=>n.clone()),e}}function G(h,t){const e=[];if(typeof h=="string")e.push(new v(void 0,t).addFragment(h));else{h=Array.isArray(h)?h:[h];for(const n of h)if(typeof n=="string")e.push(new v(void 0,t).addFragment(n));else if(Array.isArray(n)){const o=new v(void 0,t);n.forEach(r=>{if(typeof r=="string")o.addFragment(r);else{const{content:i,...B}=r;o.addFragment(i,B)}}),e.push(o)}else if("fragments"in n){const{fragments:o,...r}=n,i=new v(r,t);o.forEach(B=>{const{content:E,...D}=B;i.addFragment(E,D)}),e.push(i)}else if("content"in n){const{content:o,...r}=n;e.push(new v(r,t).addFragment(o))}}return e}function V(h,t,e){var B;const n=[],o=h.slice();let r,i;for(;r=o.shift();){const E=r.fragments.slice();let D=0;const g=[];for(;i=E.shift();){const d=i.computedStyle;let a="",S=!1,k=0;const u=new T("",i.style,i.parent);for(const x of i.characters){if(u.content+=x.content,(B=i.characters[++k])!=null&&B.isPunctuation)continue;let m,p;switch(d.writingMode){case"vertical-lr":case"vertical-rl":m=e,p=u.update().measure().contentBox.height;break;case"horizontal-tb":default:m=t,p=u.update().measure().contentBox.width;break}if(p+=d.letterSpacing,x.isEOL||m&&D+p>m){let s=x.isEOL?a.length+1:a.length;!D&&!s&&(a+=u.computedContent,s+=u.computedContent.length),a.length&&g.push(i.clone(a)),g.length&&(n.push(r.clone(g.slice())),g.length=0);const l=i.computedContent.substring(s);(l.length||E.length)&&o.unshift(r.clone((l.length?[i.clone(l)]:[]).concat(E.slice()))),E.length=0,S=!0;break}else D+=p;a+=u.computedContent,u.content=""}S||g.push(i.clone())}g.length&&n.push(r.clone(g))}return n}const L={width:0,height:0,color:"#000",backgroundColor:"rgba(0, 0, 0, 0)",fontSize:14,fontWeight:"normal",fontFamily:"sans-serif",fontStyle:"normal",fontKerning:"normal",textWrap:"wrap",textAlign:"start",verticalAlign:"baseline",textTransform:"none",textDecoration:"none",textStrokeWidth:0,textStrokeColor:"#000",lineHeight:1,letterSpacing:0,shadowColor:"rgba(0, 0, 0, 0)",shadowOffsetX:0,shadowOffsetY:0,shadowBlur:0,writingMode:"horizontal-tb",textOrientation:"mixed"};function q(h){return{...L,...h}}function U(h){const{content:t,effects:e=[{}]}=h,{width:n,height:o,...r}=q(h.style);let i=G(t,r);i=V(i,n,o);let B=0,E=0;i.forEach(u=>{let x=null;u.fragments.forEach(F=>{F.update().measure(),(!x||x.contentBox.height<F.contentBox.height)&&(x=F)});const{glyphHeight:m,baseline:p}=$("x",(x??u).computedStyle);u.xHeight=m,u.baseline=p;const s=u.computedStyle;let l=B,c=E,y=0;u.fragments.forEach((F,f)=>{const C=F.computedStyle;switch(s.writingMode){case"vertical-rl":case"vertical-lr":{f||(c=0),F.inlineBox.translate(l,c),F.contentBox.translate(l,c),F.glyphBox.translate(l,c);let b=c;F.characters.forEach((w,O)=>{const z=w.contentBox.y+w.contentBox.height;w.contentBox.translate(l,b),w.glyphBox.translate(l,b),b+=z,O!==F.characters.length-1&&(b+=C.letterSpacing)}),c+=F.inlineBox.height,f===u.fragments.length-1&&(l+=F.inlineBox.width);break}case"horizontal-tb":{f||(l=0),F.inlineBox.translate(l,c),F.contentBox.translate(l,c),F.glyphBox.translate(l,c);let b=l;F.characters.forEach((w,O)=>{const z=w.contentBox.x+w.contentBox.width;w.contentBox.translate(b,c),w.glyphBox.translate(b,c),b+=z,O!==F.characters.length-1&&(b+=C.letterSpacing)}),l+=F.inlineBox.width,y=Math.max(y,F.inlineBox.height),f===u.fragments.length-1&&(c+=y);break}}}),B=l,E=c,u.lineBox=A.from(...u.fragments.map(F=>F.inlineBox))});const D=A.from(...i.map(u=>u.lineBox),new A(0,0,n,o)),{width:g,height:d}=D;i.forEach(u=>{let x=0;const m=0,p=u.computedStyle;switch(p.writingMode){case"vertical-rl":x+=g-(u.lineBox.x*2+u.lineBox.width);case"vertical-lr":u.lineBox.height=Math.max(u.lineBox.height,d);break;case"horizontal-tb":u.lineBox.width=Math.max(u.lineBox.width,g);break}u.contentBox=A.from(...u.fragments.map(s=>s.contentBox)),u.glyphBox=A.from(...u.fragments.map(s=>s.glyphBox)),u.fragments.forEach(s=>{let l=x,c=m;const y=s.computedStyle;switch(p.writingMode){case"vertical-rl":case"vertical-lr":{switch(y.textAlign){case"end":case"right":c+=d-u.contentBox.height;break;case"center":c+=(d-u.contentBox.height)/2;break}s.characters.forEach(F=>{let f=l;const C=c;switch(y.verticalAlign){case"top":case"middle":case"bottom":case"sub":case"super":case"text-top":case"text-bottom":case"baseline":default:f+=u.baseline-F.baseline;break}F.contentBox.translate(f,C),F.glyphBox.translate(f,C)});break}case"horizontal-tb":{switch(y.textAlign){case"end":case"right":l=g-u.contentBox.width;break;case"center":l=(g-u.contentBox.width)/2;break}switch(y.verticalAlign){case"top":c=u.lineBox.y-s.inlineBox.y;break;case"middle":c=s.inlineBox.y-(u.baseline-u.xHeight/2-s.inlineBox.height/2);break;case"bottom":c=u.lineBox.bottom-s.inlineBox.bottom;break;case"sub":c=u.lineBox.y+u.baseline-s.glyphBox.bottom;break;case"super":c=u.lineBox.y+u.baseline-s.glyphBox.y;break;case"text-top":c=u.glyphBox.y-s.inlineBox.y;break;case"text-bottom":c=u.glyphBox.bottom-s.inlineBox.bottom;break;case"baseline":default:s.inlineBox.height<u.lineBox.height&&(c=u.baseline-s.baseline);break}s.characters.forEach(F=>{F.contentBox.translate(l,c),F.glyphBox.translate(l,c)});break}}s.inlineBox.translate(l,c),s.contentBox.translate(l,c),s.glyphBox.translate(l,c)}),u.lineBox=A.from(u.lineBox,...u.fragments.map(s=>s.inlineBox)),u.contentBox=A.from(...u.fragments.map(s=>s.contentBox)),u.glyphBox=A.from(...u.fragments.map(s=>s.glyphBox))});const a=A.from(...i.map(u=>u.contentBox)),S=A.from(...i.map(u=>u.glyphBox)),k=[];return i.forEach(u=>{u.fragments.forEach(x=>{const m=x.computedStyle;e.forEach(p=>{const s={...m,...p},{textStrokeWidth:l=0,offsetX:c=0,offsetY:y=0}=s;if(l||c||y){const{x:F,y:f,width:C,height:b}=x.contentBox;k.push(new A(Math.min(F,F+c-l/2),Math.min(f,f+y-l/2),Math.max(C,C+c+l),Math.max(b,b+y+l)))}})})}),{box:D,contentBox:a,glyphBox:S,paragraphs:i,viewBox:A.from(D,S,...k)}}function H(h,t,e){if(typeof t=="string"&&t.startsWith("linear-gradient")){const{x0:n,y0:o,x1:r,y1:i,stops:B}=J(t,e.left,e.top,e.width,e.height),E=h.createLinearGradient(n,o,r,i);return B.forEach(D=>E.addColorStop(D.offset,D.color)),E}return t}function J(h,t,e,n,o){var S;const r=((S=h.match(/linear-gradient\((.+)\)$/))==null?void 0:S[1])??"",i=r.split(",")[0],B=i.includes("deg")?i:"0deg",E=r.replace(B,"").matchAll(/(#|rgba|rgb)(.+?) ([\d.]+?%)/gi),g=(Number(B.replace("deg",""))||0)*Math.PI/180,d=n*Math.sin(g),a=o*Math.cos(g);return{x0:t+n/2-d,y0:e+o/2+a,x1:t+n/2+d,y1:e+o/2-a,stops:Array.from(E).map(k=>{let u=k[2];return u.startsWith("(")?u=u.split(",").length>3?`rgba${u}`:`rgb${u}`:u=`#${u}`,{offset:Number(k[3].replace("%",""))/100,color:u}})}}function M(h,t,e){e!=null&&e.color&&(e.color=H(h,e.color,t)),e!=null&&e.backgroundColor&&(e.backgroundColor=H(h,e.backgroundColor,t)),e!=null&&e.textStrokeColor&&(e.textStrokeColor=H(h,e.textStrokeColor,t))}function Q(h){const{view:t=document.createElement("canvas"),style:e,effects:n=[],pixelRatio:o=1}=h,r=n.length>0?n:[{}],{viewBox:i,paragraphs:B}=U(h),{x:E,y:D,width:g,height:d}=i,a=t.getContext("2d");t.style.width=`${g}px`,t.style.height=`${d}px`,t.dataset.viewbox=`${E} ${D} ${g} ${d}`,t.dataset.pixelRatio=String(o),t.width=Math.max(1,Math.floor(g*o)),t.height=Math.max(1,Math.floor(d*o)),a.scale(o,o),a.clearRect(0,0,t.width,t.height);const S=(u,x,m,p,s)=>{a.fillStyle=u,a.fillRect(-i.x+x,-i.y+m,p,s)},k={...e};return M(a,new A(0,0,g,d),k),B.forEach(u=>{M(a,u.contentBox,u.computedStyle),u.fragments.forEach(x=>{M(a,x.contentBox,x.computedStyle)})}),r.forEach(u=>{const x={...u};M(a,new A(0,0,g,d),x);const m={...k,...x};m!=null&&m.backgroundColor&&S(m.backgroundColor,0,0,t.width,t.height),B.forEach(p=>{var s;(s=p.style)!=null&&s.backgroundColor&&S(p.computedStyle.backgroundColor,...p.lineBox.toArray()),p.fragments.forEach(l=>{var c;(c=l.style)!=null&&c.backgroundColor&&S(l.computedStyle.backgroundColor,...l.inlineBox.toArray())})}),B.forEach(p=>{p.fragments.forEach(s=>{const l=-i.x+(x.offsetX??0),c=-i.y+(x.offsetY??0),y={...s.computedStyle,...x};switch(P(a,{...y,textAlign:"left"}),y.writingMode){case"vertical-rl":case"vertical-lr":{s.characters.forEach(F=>{let f=0,C=0;switch(F.verticalOrientation){case"Tr":case"R":{a.rotate(Math.PI/2),a.textBaseline="alphabetic",C=-(l+s.inlineBox.x+s.inlineBox.width-F.baseline),f=c+F.contentBox.y;break}case"Tu":a.textBaseline="top",f=l+F.contentBox.x+F.contentBox.right-F.glyphBox.right,C=c+F.contentBox.y+F.contentBox.y-F.glyphBox.y;break;case"U":f=l+F.contentBox.x,C=c+F.contentBox.y,a.textBaseline="top";break}a.fillText(F.content,f,C),y.textStrokeWidth&&a.strokeText(F.content,f,C),a.setTransform(1,0,0,1,0,0),a.scale(o,o)});break}case"horizontal-tb":{const F=l+s.contentBox.x,f=c+s.contentBox.y,C=c+s.inlineBox.y+s.baseline;a.textBaseline="alphabetic",a.fillText(s.computedContent,F,C),y.textStrokeWidth&&a.strokeText(s.computedContent,F,C);const{width:b,height:w}=s.contentBox;switch(y.textDecoration){case"underline":a.strokeStyle=a.fillStyle,a.lineWidth=y.fontSize/15,a.beginPath(),a.moveTo(F,f+w),a.lineTo(F+b,f+w),a.stroke();break;case"line-through":a.strokeStyle=a.fillStyle,a.lineWidth=y.fontSize/15,a.beginPath(),a.moveTo(F,f+w/2),a.lineTo(F+b,f+w/2),a.stroke();break}break}}})})}),t}exports.defaultTextStyles=L;exports.measureText=U;exports.renderText=Q;
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(v,g){typeof exports=="object"&&typeof module<"u"?g(exports):typeof define=="function"&&define.amd?define(["exports"],g):(v=typeof globalThis<"u"?globalThis:v||self,g(v.modernText={}))})(this,function(v){"use strict";class g{constructor(t=0,e=0,n=0,o=0){this.x=t,this.y=e,this.width=n,this.height=o}get left(){return this.x}get top(){return this.y}get right(){return this.x+this.width}get bottom(){return this.y+this.height}static from(...t){const e=t[0],n=t.slice(1).reduce((o,c)=>(o.x=Math.min(o.x,c.x),o.y=Math.min(o.y,c.y),o.right=Math.max(o.right,c.right),o.bottom=Math.max(o.bottom,c.bottom),o),{x:e.x,y:e.y,right:e.right,bottom:e.bottom});return new g(n.x,n.y,n.right-n.x,n.bottom-n.y)}rotate90deg(){const{width:t,height:e}=this;this.width=e,this.height=t}translate(t,e){return this.x+=t,this.y+=e,this}clone(){return new g(this.x,this.y,this.width,this.height)}toArray(){return[this.x,this.y,this.width,this.height]}}function P(r,t){switch(r.shadowColor=t.shadowColor||"rgba(0, 0, 0, 0)",r.shadowOffsetX=t.shadowOffsetX||0,r.shadowOffsetY=t.shadowOffsetY||0,r.shadowBlur=t.shadowBlur||0,r.strokeStyle=t.textStrokeColor||"#000",r.lineWidth=t.textStrokeWidth||0,r.fillStyle=t.color||"#000",r.textAlign=t.textAlign||"start",r.fontKerning=t.fontKerning||"normal",t.verticalAlign){case"top":case"middle":case"bottom":r.textBaseline=t.verticalAlign;break;case"baseline":default:r.textBaseline="alphabetic";break}r.font=[t.fontStyle||"normal",t.fontWeight||"normal",`${t.fontSize||14}px`,t.fontFamily||"sans-serif"].join(" "),r.letterSpacing=`${t.letterSpacing||0}px`}const N="OffscreenCanvas"in globalThis;let Y;function j(){return Y??(Y=N?new OffscreenCanvas(1,1):document.createElement("canvas"))}function $(r,t){const e=j().getContext("2d");P(e,{...t,textAlign:"center",verticalAlign:"baseline"});const{width:n,actualBoundingBoxAscent:o,actualBoundingBoxDescent:c,actualBoundingBoxLeft:i,actualBoundingBoxRight:B,fontBoundingBoxAscent:A,fontBoundingBoxDescent:D}=e.measureText(r),x=t.fontSize*t.lineHeight,E=A+D;return{width:n,height:t.fontSize,typoAscent:A,typoDescent:D,typoHeight:E,lineHeight:x,glyphLeft:i,glyphRight:B,glyphAscent:o,glyphDescent:c,glyphWidth:i+B,glyphHeight:o+c,baseline:(x-E)/2+A,centerX:n/2}}function I(r,t){const e=document.createDocumentFragment(),n=document.createElement("div");n.style.position="absolute",n.style.visibility="hidden",n.setAttribute("aria-hidden","true"),n.style.fontFamily=t.fontFamily,n.style.fontSize=`${t.fontSize}px`,n.style.lineHeight=String(t.lineHeight),n.style.whiteSpace="nowrap",n.style.writingMode=t.writingMode;const o=document.createElement("span");o.textContent=/\s/.test(r)?" ":r,n.appendChild(o),e.appendChild(n),document.body.appendChild(e);const c={leading:o.offsetHeight-t.fontSize};return document.body.removeChild(n),c}const K=/[\u{00A7}\u{00A9}\u{00AE}\u{00B1}\u{00BC}-\u{00BE}\u{00D7}\u{00F7}\u{02EA}-\u{02EB}\u{1100}-\u{11FF}\u{1401}-\u{166C}\u{166D}\u{166E}\u{166F}-\u{167F}\u{18B0}-\u{18F5}\u{18F6}-\u{18FF}\u{2016}\u{2020}-\u{2021}\u{2030}-\u{2031}\u{203B}-\u{203C}\u{2042}\u{2047}-\u{2049}\u{2051}\u{2065}\u{20DD}-\u{20E0}\u{20E2}-\u{20E4}\u{2100}-\u{2101}\u{2103}-\u{2106}\u{2107}\u{2108}-\u{2109}\u{210F}\u{2113}\u{2114}\u{2116}-\u{2117}\u{211E}-\u{2123}\u{2125}\u{2127}\u{2129}\u{212E}\u{2135}-\u{2138}\u{2139}\u{213A}-\u{213B}\u{213C}-\u{213F}\u{2145}-\u{2149}\u{214A}\u{214C}-\u{214D}\u{214F}\u{2150}-\u{215F}\u{2160}-\u{2182}\u{2183}-\u{2184}\u{2185}-\u{2188}\u{2189}\u{218C}-\u{218F}\u{221E}\u{2234}-\u{2235}\u{2300}-\u{2307}\u{230C}-\u{231F}\u{2324}-\u{2328}\u{232B}\u{237D}-\u{239A}\u{23BE}-\u{23CD}\u{23CF}\u{23D1}-\u{23DB}\u{23E2}-\u{23FF}\u{2400}-\u{2422}\u{2424}-\u{2426}\u{2427}-\u{243F}\u{2440}-\u{244A}\u{244B}-\u{245F}\u{2460}-\u{249B}\u{249C}-\u{24E9}\u{24EA}-\u{24FF}\u{25A0}-\u{25B6}\u{25B7}\u{25B8}-\u{25C0}\u{25C1}\u{25C2}-\u{25F7}\u{25F8}-\u{25FF}\u{2600}-\u{2619}\u{2620}-\u{266E}\u{266F}\u{2670}-\u{26FF}\u{2700}-\u{2767}\u{2776}-\u{2793}\u{2B12}-\u{2B2F}\u{2B50}-\u{2B59}\u{2B97}\u{2BB8}-\u{2BD1}\u{2BD3}-\u{2BEB}\u{2BF0}-\u{2BFF}\u{2E50}-\u{2E51}\u{2E80}-\u{2E99}\u{2E9A}\u{2E9B}-\u{2EF3}\u{2EF4}-\u{2EFF}\u{2F00}-\u{2FD5}\u{2FD6}-\u{2FDF}\u{2FE0}-\u{2FEF}\u{2FF0}-\u{2FFB}\u{2FFC}-\u{2FFF}\u{3000}\u{3001}-\u{3002}\u{3003}\u{3004}\u{3005}\u{3006}\u{3007}\u{3012}-\u{3013}\u{3020}\u{3021}-\u{3029}\u{302A}-\u{302D}\u{302E}-\u{302F}\u{3031}-\u{3035}\u{3036}-\u{3037}\u{3038}-\u{303A}\u{303B}\u{303C}\u{303D}\u{303E}-\u{303F}\u{3040}\u{3041}\u{3042}\u{3043}\u{3044}\u{3045}\u{3046}\u{3047}\u{3048}\u{3049}\u{304A}-\u{3062}\u{3063}\u{3064}-\u{3082}\u{3083}\u{3084}\u{3085}\u{3086}\u{3087}\u{3088}-\u{308D}\u{308E}\u{308F}-\u{3094}\u{3095}-\u{3096}\u{3097}-\u{3098}\u{3099}-\u{309A}\u{309B}-\u{309C}\u{309D}-\u{309E}\u{309F}\u{30A1}\u{30A2}\u{30A3}\u{30A4}\u{30A5}\u{30A6}\u{30A7}\u{30A8}\u{30A9}\u{30AA}-\u{30C2}\u{30C3}\u{30C4}-\u{30E2}\u{30E3}\u{30E4}\u{30E5}\u{30E6}\u{30E7}\u{30E8}-\u{30ED}\u{30EE}\u{30EF}-\u{30F4}\u{30F5}-\u{30F6}\u{30F7}-\u{30FA}\u{30FB}\u{30FD}-\u{30FE}\u{30FF}\u{3100}-\u{3104}\u{3105}-\u{3126}\u{3127}\u{3128}-\u{312F}\u{3130}\u{3131}-\u{318E}\u{318F}\u{3190}-\u{3191}\u{3192}-\u{3195}\u{3196}-\u{319F}\u{31A0}-\u{31BF}\u{31C0}-\u{31E3}\u{31E4}-\u{31EF}\u{31F0}-\u{31FF}\u{3200}-\u{321E}\u{321F}\u{3220}-\u{3229}\u{322A}-\u{3247}\u{3248}-\u{324F}\u{3250}\u{3251}-\u{325F}\u{3260}-\u{327F}\u{3280}-\u{3289}\u{328A}-\u{32B0}\u{32B1}-\u{32BF}\u{32C0}-\u{32FE}\u{32FF}\u{3300}-\u{3357}\u{3358}-\u{337A}\u{337B}-\u{337F}\u{3380}-\u{33FF}\u{3400}-\u{4DBF}\u{4DC0}-\u{4DFF}\u{4E00}-\u{9FFF}\u{A000}-\u{A014}\u{A015}\u{A016}-\u{A48C}\u{A48D}-\u{A48F}\u{A490}-\u{A4C6}\u{A4C7}-\u{A4CF}\u{A960}-\u{A97C}\u{A97D}-\u{A97F}\u{AC00}-\u{D7A3}\u{D7A4}-\u{D7AF}\u{D7B0}-\u{D7C6}\u{D7C7}-\u{D7CA}\u{D7CB}-\u{D7FB}\u{D7FC}-\u{D7FF}\u{E000}-\u{F8FF}\u{F900}-\u{FA6D}\u{FA6E}-\u{FA6F}\u{FA70}-\u{FAD9}\u{FADA}-\u{FAFF}\u{FE10}-\u{FE16}\u{FE17}\u{FE18}\u{FE19}\u{FE1A}-\u{FE1F}\u{FE30}\u{FE31}-\u{FE32}\u{FE33}-\u{FE34}\u{FE35}\u{FE36}\u{FE37}\u{FE38}\u{FE39}\u{FE3A}\u{FE3B}\u{FE3C}\u{FE3D}\u{FE3E}\u{FE3F}\u{FE40}\u{FE41}\u{FE42}\u{FE43}\u{FE44}\u{FE45}-\u{FE46}\u{FE47}\u{FE48}\u{FE50}-\u{FE52}\u{FE53}\u{FE54}-\u{FE57}\u{FE5F}-\u{FE61}\u{FE62}\u{FE67}\u{FE68}\u{FE69}\u{FE6A}-\u{FE6B}\u{FE6C}-\u{FE6F}\u{FF01}\u{FF02}-\u{FF03}\u{FF04}\u{FF05}-\u{FF07}\u{FF0A}\u{FF0B}\u{FF0C}\u{FF0E}\u{FF0F}\u{FF10}-\u{FF19}\u{FF1F}\u{FF20}\u{FF21}-\u{FF3A}\u{FF3C}\u{FF3E}\u{FF40}\u{FF41}-\u{FF5A}\u{FFE0}-\u{FFE1}\u{FFE2}\u{FFE4}\u{FFE5}-\u{FFE6}\u{FFE7}\u{FFF0}-\u{FFF8}\u{FFFC}-\u{FFFD}\u{10980}-\u{1099F}\u{11580}-\u{115AE}\u{115AF}-\u{115B1}\u{115B2}-\u{115B5}\u{115B6}-\u{115B7}\u{115B8}-\u{115BB}\u{115BC}-\u{115BD}\u{115BE}\u{115BF}-\u{115C0}\u{115C1}-\u{115D7}\u{115D8}-\u{115DB}\u{115DC}-\u{115DD}\u{115DE}-\u{115FF}\u{11A00}\u{11A01}-\u{11A0A}\u{11A0B}-\u{11A32}\u{11A33}-\u{11A38}\u{11A39}\u{11A3A}\u{11A3B}-\u{11A3E}\u{11A3F}-\u{11A46}\u{11A47}\u{11A48}-\u{11A4F}\u{11A50}\u{11A51}-\u{11A56}\u{11A57}-\u{11A58}\u{11A59}-\u{11A5B}\u{11A5C}-\u{11A89}\u{11A8A}-\u{11A96}\u{11A97}\u{11A98}-\u{11A99}\u{11A9A}-\u{11A9C}\u{11A9D}\u{11A9E}-\u{11AA2}\u{11AA3}-\u{11AAF}\u{11AB0}-\u{11ABF}\u{13000}-\u{1342E}\u{1342F}\u{13430}-\u{13438}\u{13439}-\u{1343F}\u{14400}-\u{14646}\u{14647}-\u{1467F}\u{16FE0}-\u{16FE1}\u{16FE2}\u{16FE3}\u{16FE4}\u{16FE5}-\u{16FEF}\u{16FF0}-\u{16FF1}\u{16FF2}-\u{16FFF}\u{17000}-\u{187F7}\u{187F8}-\u{187FF}\u{18800}-\u{18AFF}\u{18B00}-\u{18CD5}\u{18CD6}-\u{18CFF}\u{18D00}-\u{18D08}\u{18D09}-\u{18D7F}\u{1AFF0}-\u{1AFF3}\u{1AFF4}\u{1AFF5}-\u{1AFFB}\u{1AFFC}\u{1AFFD}-\u{1AFFE}\u{1AFFF}\u{1B000}-\u{1B0FF}\u{1B100}-\u{1B122}\u{1B123}-\u{1B12F}\u{1B130}-\u{1B14F}\u{1B150}-\u{1B152}\u{1B153}-\u{1B163}\u{1B164}-\u{1B167}\u{1B168}-\u{1B16F}\u{1B170}-\u{1B2FB}\u{1B2FC}-\u{1B2FF}\u{1CF00}-\u{1CF2D}\u{1CF2E}-\u{1CF2F}\u{1CF30}-\u{1CF46}\u{1CF47}-\u{1CF4F}\u{1CF50}-\u{1CFC3}\u{1CFC4}-\u{1CFCF}\u{1D000}-\u{1D0F5}\u{1D0F6}-\u{1D0FF}\u{1D100}-\u{1D126}\u{1D127}-\u{1D128}\u{1D129}-\u{1D164}\u{1D165}-\u{1D166}\u{1D167}-\u{1D169}\u{1D16A}-\u{1D16C}\u{1D16D}-\u{1D172}\u{1D173}-\u{1D17A}\u{1D17B}-\u{1D182}\u{1D183}-\u{1D184}\u{1D185}-\u{1D18B}\u{1D18C}-\u{1D1A9}\u{1D1AA}-\u{1D1AD}\u{1D1AE}-\u{1D1EA}\u{1D1EB}-\u{1D1FF}\u{1D2E0}-\u{1D2F3}\u{1D2F4}-\u{1D2FF}\u{1D300}-\u{1D356}\u{1D357}-\u{1D35F}\u{1D360}-\u{1D378}\u{1D379}-\u{1D37F}\u{1D800}-\u{1D9FF}\u{1DA00}-\u{1DA36}\u{1DA37}-\u{1DA3A}\u{1DA3B}-\u{1DA6C}\u{1DA6D}-\u{1DA74}\u{1DA75}\u{1DA76}-\u{1DA83}\u{1DA84}\u{1DA85}-\u{1DA86}\u{1DA87}-\u{1DA8B}\u{1DA8C}-\u{1DA9A}\u{1DA9B}-\u{1DA9F}\u{1DAA0}\u{1DAA1}-\u{1DAAF}\u{1F000}-\u{1F02B}\u{1F02C}-\u{1F02F}\u{1F030}-\u{1F093}\u{1F094}-\u{1F09F}\u{1F0A0}-\u{1F0AE}\u{1F0AF}-\u{1F0B0}\u{1F0B1}-\u{1F0BF}\u{1F0C0}\u{1F0C1}-\u{1F0CF}\u{1F0D0}\u{1F0D1}-\u{1F0F5}\u{1F0F6}-\u{1F0FF}\u{1F100}-\u{1F10C}\u{1F10D}-\u{1F1AD}\u{1F1AE}-\u{1F1E5}\u{1F1E6}-\u{1F1FF}\u{1F200}-\u{1F201}\u{1F202}\u{1F203}-\u{1F20F}\u{1F210}-\u{1F23B}\u{1F23C}-\u{1F23F}\u{1F240}-\u{1F248}\u{1F249}-\u{1F24F}\u{1F250}-\u{1F251}\u{1F252}-\u{1F25F}\u{1F260}-\u{1F265}\u{1F266}-\u{1F2FF}\u{1F300}-\u{1F3FA}\u{1F3FB}-\u{1F3FF}\u{1F400}-\u{1F5FF}\u{1F600}-\u{1F64F}\u{1F650}-\u{1F67F}\u{1F680}-\u{1F6D7}\u{1F6D8}-\u{1F6DC}\u{1F6DD}-\u{1F6EC}\u{1F6ED}-\u{1F6EF}\u{1F6F0}-\u{1F6FC}\u{1F6FD}-\u{1F6FF}\u{1F700}-\u{1F773}\u{1F774}-\u{1F77F}\u{1F780}-\u{1F7D8}\u{1F7D9}-\u{1F7DF}\u{1F7E0}-\u{1F7EB}\u{1F7EC}-\u{1F7EF}\u{1F7F0}\u{1F7F1}-\u{1F7FF}\u{1F900}-\u{1F9FF}\u{1FA00}-\u{1FA53}\u{1FA54}-\u{1FA5F}\u{1FA60}-\u{1FA6D}\u{1FA6E}-\u{1FA6F}\u{1FA70}-\u{1FA74}\u{1FA75}-\u{1FA77}\u{1FA78}-\u{1FA7C}\u{1FA7D}-\u{1FA7F}\u{1FA80}-\u{1FA86}\u{1FA87}-\u{1FA8F}\u{1FA90}-\u{1FAAC}\u{1FAAD}-\u{1FAAF}\u{1FAB0}-\u{1FABA}\u{1FABB}-\u{1FABF}\u{1FAC0}-\u{1FAC5}\u{1FAC6}-\u{1FACF}\u{1FAD0}-\u{1FAD9}\u{1FADA}-\u{1FADF}\u{1FAE0}-\u{1FAE7}\u{1FAE8}-\u{1FAEF}\u{1FAF0}-\u{1FAF6}\u{1FAF7}-\u{1FAFF}\u{20000}-\u{2A6DF}\u{2A6E0}-\u{2A6FF}\u{2A700}-\u{2B738}\u{2B739}-\u{2B73F}\u{2B740}-\u{2B81D}\u{2B81E}-\u{2B81F}\u{2B820}-\u{2CEA1}\u{2CEA2}-\u{2CEAF}\u{2CEB0}-\u{2EBE0}\u{2EBE1}-\u{2F7FF}\u{2F800}-\u{2FA1D}\u{2FA1E}-\u{2FFFD}\u{30000}-\u{3134A}\u{3134B}-\u{3134F}\u{31350}-\u{3FFFD}]/u,L=/[\u{2329}\u{232A}\u{3001}\u{3002}\u{3008}\u{3009}\u{300A}\u{300B}\u{300C}\u{300D}\u{300E}\u{300F}\u{3010}\u{3011}\u{3014}\u{3015}\u{3016}\u{3017}\u{3018}\u{3019}\u{301A}\u{301B}\u{301C}\u{301D}\u{301E}\u{301F}\u{3030}\u{3041}\u{3043}\u{3045}\u{3047}\u{3049}\u{3063}\u{3083}\u{3085}\u{3087}\u{308E}\u{3095}\u{3096}\u{309B}\u{309C}\u{30A0}\u{30A1}\u{30A3}\u{30A5}\u{30A7}\u{30A9}\u{30C3}\u{30E3}\u{30E5}\u{30E7}\u{30EE}\u{30F5}\u{30F6}\u{30FC}\u{3127}\u{31F0}\u{31F1}\u{31F2}\u{31F3}\u{31F4}\u{31F5}\u{31F6}\u{31F7}\u{31F8}\u{31F9}\u{31FA}\u{31FB}\u{31FC}\u{31FD}\u{31FE}\u{31FF}\u{32FF}\u{3300}\u{3301}\u{3302}\u{3303}\u{3304}\u{3305}\u{3306}\u{3307}\u{3308}\u{3309}\u{330A}\u{330B}\u{330C}\u{330D}\u{330E}\u{330F}\u{3310}\u{3311}\u{3312}\u{3313}\u{3314}\u{3315}\u{3316}\u{3317}\u{3318}\u{3319}\u{331A}\u{331B}\u{331C}\u{331D}\u{331E}\u{331F}\u{3320}\u{3321}\u{3322}\u{3323}\u{3324}\u{3325}\u{3326}\u{3327}\u{3328}\u{3329}\u{332A}\u{332B}\u{332C}\u{332D}\u{332E}\u{332F}\u{3330}\u{3331}\u{3332}\u{3333}\u{3334}\u{3335}\u{3336}\u{3337}\u{3338}\u{3339}\u{333A}\u{333B}\u{333C}\u{333D}\u{333E}\u{333F}\u{3340}\u{3341}\u{3342}\u{3343}\u{3344}\u{3345}\u{3346}\u{3347}\u{3348}\u{3349}\u{334A}\u{334B}\u{334C}\u{334D}\u{334E}\u{334F}\u{3350}\u{3351}\u{3352}\u{3353}\u{3354}\u{3355}\u{3356}\u{3357}\u{337B}\u{337C}\u{337D}\u{337E}\u{337F}\u{FE50}\u{FE51}\u{FE52}\u{FE59}\u{FE5A}\u{FE5B}\u{FE5C}\u{FE5D}\u{FE5E}\u{FF01}\u{FF08}\u{FF09}\u{FF0C}\u{FF0E}\u{FF1A}\u{FF1B}\u{FF1F}\u{FF3B}\u{FF3D}\u{FF3F}\u{FF5B}\u{FF5C}\u{FF5D}\u{FF5E}\u{FF5F}\u{FF60}\u{FFE3}\u{1F200}\u{1F201}]/u,_=/[\s\n\t\u200B\u200C\u200D\u200E\u200F.,?!:;"'(){}\[\]<>\/\\|~#\$%\*\+=&^,。?!:;“”‘’()【】《》……——]/u,G=/[\r\n]/;class z{constructor(t,e){this.content=t,this.parent=e,this.contentBox=new g,this.glyphBox=new g,this.baseline=0,this.verticalOrientation="U",this.isPunctuation=!1,this.isEOL=!1,this.update()}get computedStyle(){return this.parent.computedStyle}update(){switch(this.computedStyle.textOrientation){case"upright":this.verticalOrientation="U";break;case"sideways-right":case"sideways":this.verticalOrientation="R";break;case"mixed":default:this.verticalOrientation=K.test(this.content)?L.test(this.content)?"Tu":"U":L.test(this.content)?"Tr":"R";break}return this.isPunctuation=_.test(this.content),this.isEOL=G.test(this.content),this}measure(){const t=this.computedStyle,{width:e,height:n,glyphAscent:o,glyphLeft:c,glyphWidth:i,glyphHeight:B,lineHeight:A,baseline:D,centerX:x}=$(this.content,{...t,letterSpacing:0});switch(this.contentBox.width=e,this.contentBox.height=n,this.glyphBox.width=i,this.glyphBox.height=B,this.baseline=D,t.writingMode){case"vertical-lr":case"vertical-rl":{const E=t.fontSize*t.lineHeight;switch(this.verticalOrientation){case"Tr":case"R":this.contentBox.rotate90deg(),this.glyphBox.rotate90deg(),this.contentBox.x=(E-n)/2,this.glyphBox.x=(E-B)/2;break;case"U":{const{leading:a}=I(this.content,{...t,letterSpacing:0});this.contentBox.x=(E-e)/2,this.contentBox.y=a,this.glyphBox.x=(E-i)/2,this.glyphBox.y=0;break}case"Tu":this.contentBox.x=(E-e)/2,this.contentBox.y=0,this.glyphBox.x=this.contentBox.x+x-c,this.glyphBox.y=n-B;break}break}case"horizontal-tb":this.contentBox.x=0,this.contentBox.y=(A-n)/2,this.glyphBox.x=x-c,this.glyphBox.y=D-o;break}return this}clone(){const t=new z(this.content,this.parent);return t.contentBox=this.contentBox.clone(),t.glyphBox=this.glyphBox.clone(),t}}class T{constructor(t,e,n){this.content=t,this.style=e,this.parent=n,this.contentBox=new g,this.inlineBox=new g,this.glyphBox=new g,this.centerX=0,this.baseline=0,this.update()}update(){var n;this.computedStyle={...(n=this.parent)==null?void 0:n.computedStyle,...this.style};const t=this.computedStyle;this.computedContent=t.textTransform==="uppercase"?this.content.toUpperCase():t.textTransform==="lowercase"?this.content.toLowerCase():this.content;const e=[];for(const o of this.computedContent)e.push(new z(o,this));return this.characters=e,this}measure(){var e;const t=this.computedStyle;switch(t.writingMode){case"vertical-lr":case"vertical-rl":{let n=0,o=0,c=0;this.characters.forEach((i,B)=>{i.update().measure(),o=Math.max(o,i.contentBox.width),c=Math.max(c,i.glyphBox.width),n+=i.contentBox.y+i.contentBox.height,B!==this.characters.length-1&&(n+=t.letterSpacing)}),this.inlineBox.width=t.fontSize*t.lineHeight,this.inlineBox.height=n,this.contentBox.width=o,this.contentBox.height=n,this.glyphBox.width=c,this.glyphBox.height=n,this.baseline=((e=this.characters[0])==null?void 0:e.baseline)??0,this.centerX=n/2;break}case"horizontal-tb":{let n=0,o=0,c=0;this.characters.forEach((B,A)=>{B.update().measure(),o=Math.max(o,B.contentBox.height),c=Math.max(c,B.glyphBox.height),n+=B.contentBox.x+B.contentBox.width,A!==this.characters.length-1&&(n+=t.letterSpacing)}),this.inlineBox.width=n,this.inlineBox.height=t.fontSize*t.lineHeight,this.contentBox.width=n,this.contentBox.height=o,this.glyphBox.width=n,this.glyphBox.height=c,this.centerX=n/2,this.inlineBox.x=0,this.inlineBox.y=0;const i=this.characters[0];i&&(this.baseline=i.baseline,this.contentBox.x=i.contentBox.x,this.glyphBox.x=i.glyphBox.x),this.contentBox.y=(this.inlineBox.height-this.contentBox.height)/2,this.glyphBox.y=(this.inlineBox.height-this.glyphBox.height)/2;break}}return this}clone(t){return new T(t??this.content,this.style,this.parent)}}class M{constructor(t,e){this.style=t,this.parent=e,this.contentBox=new g,this.lineBox=new g,this.glyphBox=new g,this.baseline=0,this.xHeight=0,this.fragments=[],this.update()}update(){this.computedStyle={...this.parent,...this.style}}addFragment(t,e){return this.fragments.push(new T(t,e,this)),this}clone(t){const e=new M(this.style,this.parent);return e.contentBox=this.contentBox.clone(),e.lineBox=this.lineBox.clone(),e.glyphBox=this.glyphBox.clone(),e.baseline=this.baseline,e.xHeight=this.xHeight,e.fragments=t??this.fragments.map(n=>n.clone()),e}}function V(r,t){const e=[];if(typeof r=="string")e.push(new M(void 0,t).addFragment(r));else{r=Array.isArray(r)?r:[r];for(const n of r)if(typeof n=="string")e.push(new M(void 0,t).addFragment(n));else if(Array.isArray(n)){const o=new M(void 0,t);n.forEach(c=>{if(typeof c=="string")o.addFragment(c);else{const{content:i,...B}=c;o.addFragment(i,B)}}),e.push(o)}else if("fragments"in n){const{fragments:o,...c}=n,i=new M(c,t);o.forEach(B=>{const{content:A,...D}=B;i.addFragment(A,D)}),e.push(i)}else if("content"in n){const{content:o,...c}=n;e.push(new M(c,t).addFragment(o))}}return e}function q(r,t,e){var B;const n=[],o=r.slice();let c,i;for(;c=o.shift();){const A=c.fragments.slice();let D=0;const x=[];for(;i=A.shift();){const E=i.computedStyle;let a="",S=!1,k=0;const u=new T("",i.style,i.parent);for(const d of i.characters){if(u.content+=d.content,(B=i.characters[++k])!=null&&B.isPunctuation)continue;const C=d.isEOL;let p,F;switch(E.writingMode){case"vertical-lr":case"vertical-rl":p=e,F=u.update().measure().contentBox.height;break;case"horizontal-tb":default:p=t,F=u.update().measure().contentBox.width;break}if(C||p&&D+F>p){let l=C?a.length+1:a.length;!D&&!l&&(a+=u.computedContent,l+=u.computedContent.length),a.length&&x.push(i.clone(a)),x.length&&(n.push(c.clone(x.slice())),x.length=0);const h=i.computedContent.substring(l);(h.length||A.length)&&o.unshift(c.clone((h.length?[i.clone(h)]:[]).concat(A.slice()))),A.length=0,S=!0;break}else D+=F;a+=u.computedContent,u.content=""}S||x.push(i.clone())}x.length&&n.push(c.clone(x))}return n}const U={width:0,height:0,color:"#000",backgroundColor:"rgba(0, 0, 0, 0)",fontSize:14,fontWeight:"normal",fontFamily:"sans-serif",fontStyle:"normal",fontKerning:"normal",textWrap:"wrap",textAlign:"start",verticalAlign:"baseline",textTransform:"none",textDecoration:"none",textStrokeWidth:0,textStrokeColor:"#000",lineHeight:1,letterSpacing:0,shadowColor:"rgba(0, 0, 0, 0)",shadowOffsetX:0,shadowOffsetY:0,shadowBlur:0,writingMode:"horizontal-tb",textOrientation:"mixed"};function J(r){return{...U,...r}}function X(r){const{content:t,effects:e=[{}]}=r,{width:n,height:o,...c}=J(r.style);let i=V(t,c);i=q(i,n,o);let B=0,A=0;i.forEach(u=>{let d=null;u.fragments.forEach(s=>{s.update().measure(),(!d||d.contentBox.height<s.contentBox.height)&&(d=s)});const{glyphHeight:C,baseline:p}=$("x",(d??u).computedStyle);u.xHeight=C,u.baseline=p;const F=u.computedStyle;let l=B,h=A,m=0;u.fragments.forEach((s,f)=>{const y=s.computedStyle;switch(F.writingMode){case"vertical-rl":case"vertical-lr":{f||(h=0),s.inlineBox.translate(l,h),s.contentBox.translate(l,h),s.glyphBox.translate(l,h);let b=h;s.characters.forEach((w,R)=>{const W=w.contentBox.y+w.contentBox.height;w.contentBox.translate(l,b),w.glyphBox.translate(l,b),b+=W,R!==s.characters.length-1&&(b+=y.letterSpacing)}),h+=s.inlineBox.height,f===u.fragments.length-1&&(l+=s.inlineBox.width);break}case"horizontal-tb":{f||(l=0),s.inlineBox.translate(l,h),s.contentBox.translate(l,h),s.glyphBox.translate(l,h);let b=l;s.characters.forEach((w,R)=>{const W=w.contentBox.x+w.contentBox.width;w.contentBox.translate(b,h),w.glyphBox.translate(b,h),b+=W,R!==s.characters.length-1&&(b+=y.letterSpacing)}),l+=s.inlineBox.width,m=Math.max(m,s.inlineBox.height),f===u.fragments.length-1&&(h+=m);break}}}),B=l,A=h,u.lineBox=g.from(...u.fragments.map(s=>s.inlineBox))});const D=g.from(...i.map(u=>u.lineBox),new g(0,0,n,o)),{width:x,height:E}=D;i.forEach(u=>{let d=0;const C=0,p=u.computedStyle;switch(p.writingMode){case"vertical-rl":d+=x-(u.lineBox.x*2+u.lineBox.width);case"vertical-lr":u.lineBox.height=Math.max(u.lineBox.height,E);break;case"horizontal-tb":u.lineBox.width=Math.max(u.lineBox.width,x);break}u.contentBox=g.from(...u.fragments.map(F=>F.contentBox)),u.glyphBox=g.from(...u.fragments.map(F=>F.glyphBox)),u.fragments.forEach(F=>{let l=d,h=C;const m=F.computedStyle;switch(p.writingMode){case"vertical-rl":case"vertical-lr":{switch(m.textAlign){case"end":case"right":h+=E-u.contentBox.height;break;case"center":h+=(E-u.contentBox.height)/2;break}F.characters.forEach(s=>{let f=l;const y=h;switch(m.verticalAlign){case"top":case"middle":case"bottom":case"sub":case"super":case"text-top":case"text-bottom":case"baseline":default:f+=u.baseline-s.baseline;break}s.contentBox.translate(f,y),s.glyphBox.translate(f,y)});break}case"horizontal-tb":{switch(m.textAlign){case"end":case"right":l=x-u.contentBox.width;break;case"center":l=(x-u.contentBox.width)/2;break}switch(m.verticalAlign){case"top":h=u.lineBox.y-F.inlineBox.y;break;case"middle":h=F.inlineBox.y-(u.baseline-u.xHeight/2-F.inlineBox.height/2);break;case"bottom":h=u.lineBox.bottom-F.inlineBox.bottom;break;case"sub":h=u.lineBox.y+u.baseline-F.glyphBox.bottom;break;case"super":h=u.lineBox.y+u.baseline-F.glyphBox.y;break;case"text-top":h=u.glyphBox.y-F.inlineBox.y;break;case"text-bottom":h=u.glyphBox.bottom-F.inlineBox.bottom;break;case"baseline":default:F.inlineBox.height<u.lineBox.height&&(h=u.baseline-F.baseline);break}break}}F.characters.forEach(s=>{s.contentBox.translate(l,h),s.glyphBox.translate(l,h)}),F.inlineBox.translate(l,h),F.contentBox.translate(l,h),F.glyphBox.translate(l,h)}),u.lineBox=g.from(u.lineBox,...u.fragments.map(F=>F.inlineBox)),u.contentBox=g.from(...u.fragments.map(F=>F.contentBox)),u.glyphBox=g.from(...u.fragments.map(F=>F.glyphBox))});const a=g.from(...i.map(u=>u.contentBox)),S=g.from(...i.map(u=>u.glyphBox)),k=[];return i.forEach(u=>{u.fragments.forEach(d=>{const C=d.computedStyle;e.forEach(p=>{const F={...C,...p},{textStrokeWidth:l=0,offsetX:h=0,offsetY:m=0}=F;if(l||h||m){const{x:s,y:f,width:y,height:b}=d.contentBox;k.push(new g(Math.min(s,s+h-l/2),Math.min(f,f+m-l/2),Math.max(y,y+h+l),Math.max(b,b+m+l)))}})})}),{box:D,contentBox:a,glyphBox:S,paragraphs:i,viewBox:g.from(D,S,...k)}}function H(r,t,e){if(typeof t=="string"&&t.startsWith("linear-gradient")){const{x0:n,y0:o,x1:c,y1:i,stops:B}=Q(t,e.left,e.top,e.width,e.height),A=r.createLinearGradient(n,o,c,i);return B.forEach(D=>A.addColorStop(D.offset,D.color)),A}return t}function Q(r,t,e,n,o){var S;const c=((S=r.match(/linear-gradient\((.+)\)$/))==null?void 0:S[1])??"",i=c.split(",")[0],B=i.includes("deg")?i:"0deg",A=c.replace(B,"").matchAll(/(#|rgba|rgb)(.+?) ([\d.]+?%)/gi),x=(Number(B.replace("deg",""))||0)*Math.PI/180,E=n*Math.sin(x),a=o*Math.cos(x);return{x0:t+n/2-E,y0:e+o/2+a,x1:t+n/2+E,y1:e+o/2-a,stops:Array.from(A).map(k=>{let u=k[2];return u.startsWith("(")?u=u.split(",").length>3?`rgba${u}`:`rgb${u}`:u=`#${u}`,{offset:Number(k[3].replace("%",""))/100,color:u}})}}function O(r,t,e){e!=null&&e.color&&(e.color=H(r,e.color,t)),e!=null&&e.backgroundColor&&(e.backgroundColor=H(r,e.backgroundColor,t)),e!=null&&e.textStrokeColor&&(e.textStrokeColor=H(r,e.textStrokeColor,t))}function Z(r){const{view:t=document.createElement("canvas"),style:e,effects:n=[],pixelRatio:o=1}=r,c=n.length>0?n:[{}],{viewBox:i,paragraphs:B}=X(r),{x:A,y:D,width:x,height:E}=i,a=t.getContext("2d");t.style.width=`${x}px`,t.style.height=`${E}px`,t.dataset.viewbox=`${A} ${D} ${x} ${E}`,t.dataset.pixelRatio=String(o),t.width=Math.max(1,Math.floor(x*o)),t.height=Math.max(1,Math.floor(E*o)),a.scale(o,o),a.clearRect(0,0,t.width,t.height);const S=(u,d,C,p,F)=>{a.fillStyle=u,a.fillRect(-i.x+d,-i.y+C,p,F)},k={...e};return O(a,new g(0,0,x,E),k),B.forEach(u=>{O(a,u.contentBox,u.computedStyle),u.fragments.forEach(d=>{O(a,d.contentBox,d.computedStyle)})}),c.forEach(u=>{const d={...u};O(a,new g(0,0,x,E),d);const C={...k,...d};C!=null&&C.backgroundColor&&S(C.backgroundColor,0,0,t.width,t.height),B.forEach(p=>{var F;(F=p.style)!=null&&F.backgroundColor&&S(p.computedStyle.backgroundColor,...p.lineBox.toArray()),p.fragments.forEach(l=>{var h;(h=l.style)!=null&&h.backgroundColor&&S(l.computedStyle.backgroundColor,...l.inlineBox.toArray())})}),B.forEach(p=>{p.fragments.forEach(F=>{const l=-i.x+(d.offsetX??0),h=-i.y+(d.offsetY??0),m={...F.computedStyle,...d};switch(P(a,{...m,textAlign:"left"}),m.writingMode){case"vertical-rl":case"vertical-lr":{F.characters.forEach(s=>{let f=0,y=0;switch(s.verticalOrientation){case"Tr":case"R":{a.rotate(Math.PI/2),a.textBaseline="alphabetic",y=-(l+F.inlineBox.x+F.inlineBox.width-s.baseline),f=h+s.contentBox.y;break}case"Tu":a.textBaseline="top",f=l+s.contentBox.x+s.contentBox.right-s.glyphBox.right,y=h+s.contentBox.y+s.contentBox.y-s.glyphBox.y;break;case"U":f=l+s.contentBox.x,y=h+s.contentBox.y,a.textBaseline="top";break}a.fillText(s.content,f,y),m.textStrokeWidth&&a.strokeText(s.content,f,y),a.setTransform(1,0,0,1,0,0),a.scale(o,o)});break}case"horizontal-tb":{const s=l+F.contentBox.x,f=h+F.contentBox.y,y=h+F.inlineBox.y+F.baseline;a.textBaseline="alphabetic",a.fillText(F.computedContent,s,y),m.textStrokeWidth&&a.strokeText(F.computedContent,s,y);const{width:b,height:w}=F.contentBox;switch(m.textDecoration){case"underline":a.strokeStyle=a.fillStyle,a.lineWidth=m.fontSize/15,a.beginPath(),a.moveTo(s,f+w),a.lineTo(s+b,f+w),a.stroke();break;case"line-through":a.strokeStyle=a.fillStyle,a.lineWidth=m.fontSize/15,a.beginPath(),a.moveTo(s,f+w/2),a.lineTo(s+b,f+w/2),a.stroke();break}break}}})})}),t}v.defaultTextStyles=U,v.measureText=X,v.renderText=Z,Object.defineProperty(v,Symbol.toStringTag,{value:"Module"})});
|
|
1
|
+
(function(v,g){typeof exports=="object"&&typeof module<"u"?g(exports):typeof define=="function"&&define.amd?define(["exports"],g):(v=typeof globalThis<"u"?globalThis:v||self,g(v.modernText={}))})(this,function(v){"use strict";class g{constructor(t=0,e=0,n=0,o=0){this.x=t,this.y=e,this.width=n,this.height=o}get left(){return this.x}get top(){return this.y}get right(){return this.x+this.width}get bottom(){return this.y+this.height}static from(...t){const e=t[0],n=t.slice(1).reduce((o,r)=>(o.x=Math.min(o.x,r.x),o.y=Math.min(o.y,r.y),o.right=Math.max(o.right,r.right),o.bottom=Math.max(o.bottom,r.bottom),o),{x:e.x,y:e.y,right:e.right,bottom:e.bottom});return new g(n.x,n.y,n.right-n.x,n.bottom-n.y)}rotate90deg(){const{width:t,height:e}=this;this.width=e,this.height=t}translate(t,e){return this.x+=t,this.y+=e,this}clone(){return new g(this.x,this.y,this.width,this.height)}toArray(){return[this.x,this.y,this.width,this.height]}}function P(h,t){switch(h.shadowColor=t.shadowColor||"rgba(0, 0, 0, 0)",h.shadowOffsetX=t.shadowOffsetX||0,h.shadowOffsetY=t.shadowOffsetY||0,h.shadowBlur=t.shadowBlur||0,h.strokeStyle=t.textStrokeColor||"#000",h.lineWidth=t.textStrokeWidth||0,h.fillStyle=t.color||"#000",h.textAlign=t.textAlign||"start",h.fontKerning=t.fontKerning||"normal",t.verticalAlign){case"top":case"middle":case"bottom":h.textBaseline=t.verticalAlign;break;case"baseline":default:h.textBaseline="alphabetic";break}h.font=[t.fontStyle||"normal",t.fontWeight||"normal",`${t.fontSize||14}px`,t.fontFamily||"sans-serif"].join(" "),h.letterSpacing=`${t.letterSpacing||0}px`}const N="OffscreenCanvas"in globalThis;let Y;function j(){return Y??(Y=N?new OffscreenCanvas(1,1):document.createElement("canvas"))}function $(h,t){const e=j().getContext("2d");P(e,{...t,textAlign:"center",verticalAlign:"baseline"});const{width:n,actualBoundingBoxAscent:o,actualBoundingBoxDescent:r,actualBoundingBoxLeft:i,actualBoundingBoxRight:B,fontBoundingBoxAscent:d,fontBoundingBoxDescent:D}=e.measureText(h),x=t.fontSize*t.lineHeight,E=d+D;return{width:n,height:t.fontSize,typoAscent:d,typoDescent:D,typoHeight:E,lineHeight:x,glyphLeft:i,glyphRight:B,glyphAscent:o,glyphDescent:r,glyphWidth:i+B,glyphHeight:o+r,baseline:(x-E)/2+d,centerX:n/2}}function I(h,t){const e=document.createDocumentFragment(),n=document.createElement("div");n.style.position="absolute",n.style.visibility="hidden",n.setAttribute("aria-hidden","true"),n.style.fontFamily=t.fontFamily,n.style.fontSize=`${t.fontSize}px`,n.style.lineHeight=String(t.lineHeight),n.style.whiteSpace="nowrap",n.style.writingMode=t.writingMode;const o=document.createElement("span");o.textContent=/\s/.test(h)?" ":h,n.appendChild(o),e.appendChild(n),document.body.appendChild(e);const r={leading:o.offsetHeight-t.fontSize};return document.body.removeChild(n),r}const K=/[\u{00A7}\u{00A9}\u{00AE}\u{00B1}\u{00BC}-\u{00BE}\u{00D7}\u{00F7}\u{02EA}-\u{02EB}\u{1100}-\u{11FF}\u{1401}-\u{166C}\u{166D}\u{166E}\u{166F}-\u{167F}\u{18B0}-\u{18F5}\u{18F6}-\u{18FF}\u{2016}\u{2020}-\u{2021}\u{2030}-\u{2031}\u{203B}-\u{203C}\u{2042}\u{2047}-\u{2049}\u{2051}\u{2065}\u{20DD}-\u{20E0}\u{20E2}-\u{20E4}\u{2100}-\u{2101}\u{2103}-\u{2106}\u{2107}\u{2108}-\u{2109}\u{210F}\u{2113}\u{2114}\u{2116}-\u{2117}\u{211E}-\u{2123}\u{2125}\u{2127}\u{2129}\u{212E}\u{2135}-\u{2138}\u{2139}\u{213A}-\u{213B}\u{213C}-\u{213F}\u{2145}-\u{2149}\u{214A}\u{214C}-\u{214D}\u{214F}\u{2150}-\u{215F}\u{2160}-\u{2182}\u{2183}-\u{2184}\u{2185}-\u{2188}\u{2189}\u{218C}-\u{218F}\u{221E}\u{2234}-\u{2235}\u{2300}-\u{2307}\u{230C}-\u{231F}\u{2324}-\u{2328}\u{232B}\u{237D}-\u{239A}\u{23BE}-\u{23CD}\u{23CF}\u{23D1}-\u{23DB}\u{23E2}-\u{23FF}\u{2400}-\u{2422}\u{2424}-\u{2426}\u{2427}-\u{243F}\u{2440}-\u{244A}\u{244B}-\u{245F}\u{2460}-\u{249B}\u{249C}-\u{24E9}\u{24EA}-\u{24FF}\u{25A0}-\u{25B6}\u{25B7}\u{25B8}-\u{25C0}\u{25C1}\u{25C2}-\u{25F7}\u{25F8}-\u{25FF}\u{2600}-\u{2619}\u{2620}-\u{266E}\u{266F}\u{2670}-\u{26FF}\u{2700}-\u{2767}\u{2776}-\u{2793}\u{2B12}-\u{2B2F}\u{2B50}-\u{2B59}\u{2B97}\u{2BB8}-\u{2BD1}\u{2BD3}-\u{2BEB}\u{2BF0}-\u{2BFF}\u{2E50}-\u{2E51}\u{2E80}-\u{2E99}\u{2E9A}\u{2E9B}-\u{2EF3}\u{2EF4}-\u{2EFF}\u{2F00}-\u{2FD5}\u{2FD6}-\u{2FDF}\u{2FE0}-\u{2FEF}\u{2FF0}-\u{2FFB}\u{2FFC}-\u{2FFF}\u{3000}\u{3001}-\u{3002}\u{3003}\u{3004}\u{3005}\u{3006}\u{3007}\u{3012}-\u{3013}\u{3020}\u{3021}-\u{3029}\u{302A}-\u{302D}\u{302E}-\u{302F}\u{3031}-\u{3035}\u{3036}-\u{3037}\u{3038}-\u{303A}\u{303B}\u{303C}\u{303D}\u{303E}-\u{303F}\u{3040}\u{3041}\u{3042}\u{3043}\u{3044}\u{3045}\u{3046}\u{3047}\u{3048}\u{3049}\u{304A}-\u{3062}\u{3063}\u{3064}-\u{3082}\u{3083}\u{3084}\u{3085}\u{3086}\u{3087}\u{3088}-\u{308D}\u{308E}\u{308F}-\u{3094}\u{3095}-\u{3096}\u{3097}-\u{3098}\u{3099}-\u{309A}\u{309B}-\u{309C}\u{309D}-\u{309E}\u{309F}\u{30A1}\u{30A2}\u{30A3}\u{30A4}\u{30A5}\u{30A6}\u{30A7}\u{30A8}\u{30A9}\u{30AA}-\u{30C2}\u{30C3}\u{30C4}-\u{30E2}\u{30E3}\u{30E4}\u{30E5}\u{30E6}\u{30E7}\u{30E8}-\u{30ED}\u{30EE}\u{30EF}-\u{30F4}\u{30F5}-\u{30F6}\u{30F7}-\u{30FA}\u{30FB}\u{30FD}-\u{30FE}\u{30FF}\u{3100}-\u{3104}\u{3105}-\u{3126}\u{3127}\u{3128}-\u{312F}\u{3130}\u{3131}-\u{318E}\u{318F}\u{3190}-\u{3191}\u{3192}-\u{3195}\u{3196}-\u{319F}\u{31A0}-\u{31BF}\u{31C0}-\u{31E3}\u{31E4}-\u{31EF}\u{31F0}-\u{31FF}\u{3200}-\u{321E}\u{321F}\u{3220}-\u{3229}\u{322A}-\u{3247}\u{3248}-\u{324F}\u{3250}\u{3251}-\u{325F}\u{3260}-\u{327F}\u{3280}-\u{3289}\u{328A}-\u{32B0}\u{32B1}-\u{32BF}\u{32C0}-\u{32FE}\u{32FF}\u{3300}-\u{3357}\u{3358}-\u{337A}\u{337B}-\u{337F}\u{3380}-\u{33FF}\u{3400}-\u{4DBF}\u{4DC0}-\u{4DFF}\u{4E00}-\u{9FFF}\u{A000}-\u{A014}\u{A015}\u{A016}-\u{A48C}\u{A48D}-\u{A48F}\u{A490}-\u{A4C6}\u{A4C7}-\u{A4CF}\u{A960}-\u{A97C}\u{A97D}-\u{A97F}\u{AC00}-\u{D7A3}\u{D7A4}-\u{D7AF}\u{D7B0}-\u{D7C6}\u{D7C7}-\u{D7CA}\u{D7CB}-\u{D7FB}\u{D7FC}-\u{D7FF}\u{E000}-\u{F8FF}\u{F900}-\u{FA6D}\u{FA6E}-\u{FA6F}\u{FA70}-\u{FAD9}\u{FADA}-\u{FAFF}\u{FE10}-\u{FE16}\u{FE17}\u{FE18}\u{FE19}\u{FE1A}-\u{FE1F}\u{FE30}\u{FE31}-\u{FE32}\u{FE33}-\u{FE34}\u{FE35}\u{FE36}\u{FE37}\u{FE38}\u{FE39}\u{FE3A}\u{FE3B}\u{FE3C}\u{FE3D}\u{FE3E}\u{FE3F}\u{FE40}\u{FE41}\u{FE42}\u{FE43}\u{FE44}\u{FE45}-\u{FE46}\u{FE47}\u{FE48}\u{FE50}-\u{FE52}\u{FE53}\u{FE54}-\u{FE57}\u{FE5F}-\u{FE61}\u{FE62}\u{FE67}\u{FE68}\u{FE69}\u{FE6A}-\u{FE6B}\u{FE6C}-\u{FE6F}\u{FF01}\u{FF02}-\u{FF03}\u{FF04}\u{FF05}-\u{FF07}\u{FF0A}\u{FF0B}\u{FF0C}\u{FF0E}\u{FF0F}\u{FF10}-\u{FF19}\u{FF1F}\u{FF20}\u{FF21}-\u{FF3A}\u{FF3C}\u{FF3E}\u{FF40}\u{FF41}-\u{FF5A}\u{FFE0}-\u{FFE1}\u{FFE2}\u{FFE4}\u{FFE5}-\u{FFE6}\u{FFE7}\u{FFF0}-\u{FFF8}\u{FFFC}-\u{FFFD}\u{10980}-\u{1099F}\u{11580}-\u{115AE}\u{115AF}-\u{115B1}\u{115B2}-\u{115B5}\u{115B6}-\u{115B7}\u{115B8}-\u{115BB}\u{115BC}-\u{115BD}\u{115BE}\u{115BF}-\u{115C0}\u{115C1}-\u{115D7}\u{115D8}-\u{115DB}\u{115DC}-\u{115DD}\u{115DE}-\u{115FF}\u{11A00}\u{11A01}-\u{11A0A}\u{11A0B}-\u{11A32}\u{11A33}-\u{11A38}\u{11A39}\u{11A3A}\u{11A3B}-\u{11A3E}\u{11A3F}-\u{11A46}\u{11A47}\u{11A48}-\u{11A4F}\u{11A50}\u{11A51}-\u{11A56}\u{11A57}-\u{11A58}\u{11A59}-\u{11A5B}\u{11A5C}-\u{11A89}\u{11A8A}-\u{11A96}\u{11A97}\u{11A98}-\u{11A99}\u{11A9A}-\u{11A9C}\u{11A9D}\u{11A9E}-\u{11AA2}\u{11AA3}-\u{11AAF}\u{11AB0}-\u{11ABF}\u{13000}-\u{1342E}\u{1342F}\u{13430}-\u{13438}\u{13439}-\u{1343F}\u{14400}-\u{14646}\u{14647}-\u{1467F}\u{16FE0}-\u{16FE1}\u{16FE2}\u{16FE3}\u{16FE4}\u{16FE5}-\u{16FEF}\u{16FF0}-\u{16FF1}\u{16FF2}-\u{16FFF}\u{17000}-\u{187F7}\u{187F8}-\u{187FF}\u{18800}-\u{18AFF}\u{18B00}-\u{18CD5}\u{18CD6}-\u{18CFF}\u{18D00}-\u{18D08}\u{18D09}-\u{18D7F}\u{1AFF0}-\u{1AFF3}\u{1AFF4}\u{1AFF5}-\u{1AFFB}\u{1AFFC}\u{1AFFD}-\u{1AFFE}\u{1AFFF}\u{1B000}-\u{1B0FF}\u{1B100}-\u{1B122}\u{1B123}-\u{1B12F}\u{1B130}-\u{1B14F}\u{1B150}-\u{1B152}\u{1B153}-\u{1B163}\u{1B164}-\u{1B167}\u{1B168}-\u{1B16F}\u{1B170}-\u{1B2FB}\u{1B2FC}-\u{1B2FF}\u{1CF00}-\u{1CF2D}\u{1CF2E}-\u{1CF2F}\u{1CF30}-\u{1CF46}\u{1CF47}-\u{1CF4F}\u{1CF50}-\u{1CFC3}\u{1CFC4}-\u{1CFCF}\u{1D000}-\u{1D0F5}\u{1D0F6}-\u{1D0FF}\u{1D100}-\u{1D126}\u{1D127}-\u{1D128}\u{1D129}-\u{1D164}\u{1D165}-\u{1D166}\u{1D167}-\u{1D169}\u{1D16A}-\u{1D16C}\u{1D16D}-\u{1D172}\u{1D173}-\u{1D17A}\u{1D17B}-\u{1D182}\u{1D183}-\u{1D184}\u{1D185}-\u{1D18B}\u{1D18C}-\u{1D1A9}\u{1D1AA}-\u{1D1AD}\u{1D1AE}-\u{1D1EA}\u{1D1EB}-\u{1D1FF}\u{1D2E0}-\u{1D2F3}\u{1D2F4}-\u{1D2FF}\u{1D300}-\u{1D356}\u{1D357}-\u{1D35F}\u{1D360}-\u{1D378}\u{1D379}-\u{1D37F}\u{1D800}-\u{1D9FF}\u{1DA00}-\u{1DA36}\u{1DA37}-\u{1DA3A}\u{1DA3B}-\u{1DA6C}\u{1DA6D}-\u{1DA74}\u{1DA75}\u{1DA76}-\u{1DA83}\u{1DA84}\u{1DA85}-\u{1DA86}\u{1DA87}-\u{1DA8B}\u{1DA8C}-\u{1DA9A}\u{1DA9B}-\u{1DA9F}\u{1DAA0}\u{1DAA1}-\u{1DAAF}\u{1F000}-\u{1F02B}\u{1F02C}-\u{1F02F}\u{1F030}-\u{1F093}\u{1F094}-\u{1F09F}\u{1F0A0}-\u{1F0AE}\u{1F0AF}-\u{1F0B0}\u{1F0B1}-\u{1F0BF}\u{1F0C0}\u{1F0C1}-\u{1F0CF}\u{1F0D0}\u{1F0D1}-\u{1F0F5}\u{1F0F6}-\u{1F0FF}\u{1F100}-\u{1F10C}\u{1F10D}-\u{1F1AD}\u{1F1AE}-\u{1F1E5}\u{1F1E6}-\u{1F1FF}\u{1F200}-\u{1F201}\u{1F202}\u{1F203}-\u{1F20F}\u{1F210}-\u{1F23B}\u{1F23C}-\u{1F23F}\u{1F240}-\u{1F248}\u{1F249}-\u{1F24F}\u{1F250}-\u{1F251}\u{1F252}-\u{1F25F}\u{1F260}-\u{1F265}\u{1F266}-\u{1F2FF}\u{1F300}-\u{1F3FA}\u{1F3FB}-\u{1F3FF}\u{1F400}-\u{1F5FF}\u{1F600}-\u{1F64F}\u{1F650}-\u{1F67F}\u{1F680}-\u{1F6D7}\u{1F6D8}-\u{1F6DC}\u{1F6DD}-\u{1F6EC}\u{1F6ED}-\u{1F6EF}\u{1F6F0}-\u{1F6FC}\u{1F6FD}-\u{1F6FF}\u{1F700}-\u{1F773}\u{1F774}-\u{1F77F}\u{1F780}-\u{1F7D8}\u{1F7D9}-\u{1F7DF}\u{1F7E0}-\u{1F7EB}\u{1F7EC}-\u{1F7EF}\u{1F7F0}\u{1F7F1}-\u{1F7FF}\u{1F900}-\u{1F9FF}\u{1FA00}-\u{1FA53}\u{1FA54}-\u{1FA5F}\u{1FA60}-\u{1FA6D}\u{1FA6E}-\u{1FA6F}\u{1FA70}-\u{1FA74}\u{1FA75}-\u{1FA77}\u{1FA78}-\u{1FA7C}\u{1FA7D}-\u{1FA7F}\u{1FA80}-\u{1FA86}\u{1FA87}-\u{1FA8F}\u{1FA90}-\u{1FAAC}\u{1FAAD}-\u{1FAAF}\u{1FAB0}-\u{1FABA}\u{1FABB}-\u{1FABF}\u{1FAC0}-\u{1FAC5}\u{1FAC6}-\u{1FACF}\u{1FAD0}-\u{1FAD9}\u{1FADA}-\u{1FADF}\u{1FAE0}-\u{1FAE7}\u{1FAE8}-\u{1FAEF}\u{1FAF0}-\u{1FAF6}\u{1FAF7}-\u{1FAFF}\u{20000}-\u{2A6DF}\u{2A6E0}-\u{2A6FF}\u{2A700}-\u{2B738}\u{2B739}-\u{2B73F}\u{2B740}-\u{2B81D}\u{2B81E}-\u{2B81F}\u{2B820}-\u{2CEA1}\u{2CEA2}-\u{2CEAF}\u{2CEB0}-\u{2EBE0}\u{2EBE1}-\u{2F7FF}\u{2F800}-\u{2FA1D}\u{2FA1E}-\u{2FFFD}\u{30000}-\u{3134A}\u{3134B}-\u{3134F}\u{31350}-\u{3FFFD}]/u,L=/[\u{2329}\u{232A}\u{3001}\u{3002}\u{3008}\u{3009}\u{300A}\u{300B}\u{300C}\u{300D}\u{300E}\u{300F}\u{3010}\u{3011}\u{3014}\u{3015}\u{3016}\u{3017}\u{3018}\u{3019}\u{301A}\u{301B}\u{301C}\u{301D}\u{301E}\u{301F}\u{3030}\u{3041}\u{3043}\u{3045}\u{3047}\u{3049}\u{3063}\u{3083}\u{3085}\u{3087}\u{308E}\u{3095}\u{3096}\u{309B}\u{309C}\u{30A0}\u{30A1}\u{30A3}\u{30A5}\u{30A7}\u{30A9}\u{30C3}\u{30E3}\u{30E5}\u{30E7}\u{30EE}\u{30F5}\u{30F6}\u{30FC}\u{3127}\u{31F0}\u{31F1}\u{31F2}\u{31F3}\u{31F4}\u{31F5}\u{31F6}\u{31F7}\u{31F8}\u{31F9}\u{31FA}\u{31FB}\u{31FC}\u{31FD}\u{31FE}\u{31FF}\u{32FF}\u{3300}\u{3301}\u{3302}\u{3303}\u{3304}\u{3305}\u{3306}\u{3307}\u{3308}\u{3309}\u{330A}\u{330B}\u{330C}\u{330D}\u{330E}\u{330F}\u{3310}\u{3311}\u{3312}\u{3313}\u{3314}\u{3315}\u{3316}\u{3317}\u{3318}\u{3319}\u{331A}\u{331B}\u{331C}\u{331D}\u{331E}\u{331F}\u{3320}\u{3321}\u{3322}\u{3323}\u{3324}\u{3325}\u{3326}\u{3327}\u{3328}\u{3329}\u{332A}\u{332B}\u{332C}\u{332D}\u{332E}\u{332F}\u{3330}\u{3331}\u{3332}\u{3333}\u{3334}\u{3335}\u{3336}\u{3337}\u{3338}\u{3339}\u{333A}\u{333B}\u{333C}\u{333D}\u{333E}\u{333F}\u{3340}\u{3341}\u{3342}\u{3343}\u{3344}\u{3345}\u{3346}\u{3347}\u{3348}\u{3349}\u{334A}\u{334B}\u{334C}\u{334D}\u{334E}\u{334F}\u{3350}\u{3351}\u{3352}\u{3353}\u{3354}\u{3355}\u{3356}\u{3357}\u{337B}\u{337C}\u{337D}\u{337E}\u{337F}\u{FE50}\u{FE51}\u{FE52}\u{FE59}\u{FE5A}\u{FE5B}\u{FE5C}\u{FE5D}\u{FE5E}\u{FF01}\u{FF08}\u{FF09}\u{FF0C}\u{FF0E}\u{FF1A}\u{FF1B}\u{FF1F}\u{FF3B}\u{FF3D}\u{FF3F}\u{FF5B}\u{FF5C}\u{FF5D}\u{FF5E}\u{FF5F}\u{FF60}\u{FFE3}\u{1F200}\u{1F201}]/u,_=/[\s\n\t\u200B\u200C\u200D\u200E\u200F.,?!:;"'(){}\[\]<>\/\\|~#\$%\*\+=&^,。?!:;“”‘’()【】《》……——]/u,G=/[\r\n]/;class z{constructor(t,e){this.content=t,this.parent=e,this.contentBox=new g,this.glyphBox=new g,this.baseline=0,this.verticalOrientation="U",this.isPunctuation=!1,this.isEOL=!1,this.update()}get computedStyle(){return this.parent.computedStyle}update(){switch(this.computedStyle.textOrientation){case"upright":this.verticalOrientation="U";break;case"sideways-right":case"sideways":this.verticalOrientation="R";break;case"mixed":default:this.verticalOrientation=K.test(this.content)?L.test(this.content)?"Tu":"U":L.test(this.content)?"Tr":"R";break}return this.isPunctuation=_.test(this.content),this.isEOL=G.test(this.content),this}measure(){const t=this.computedStyle,{width:e,height:n,glyphAscent:o,glyphLeft:r,glyphWidth:i,glyphHeight:B,lineHeight:d,baseline:D,centerX:x}=$(this.content,{...t,letterSpacing:0});switch(this.contentBox.width=e,this.contentBox.height=n,this.glyphBox.width=i,this.glyphBox.height=B,this.baseline=D,t.writingMode){case"vertical-lr":case"vertical-rl":{const E=t.fontSize*t.lineHeight;switch(this.verticalOrientation){case"Tr":case"R":this.contentBox.rotate90deg(),this.glyphBox.rotate90deg(),this.contentBox.x=(E-n)/2,this.glyphBox.x=(E-B)/2;break;case"U":{const{leading:a}=I(this.content,{...t,letterSpacing:0});this.contentBox.x=(E-e)/2,this.contentBox.y=a,this.glyphBox.x=(E-i)/2,this.glyphBox.y=0;break}case"Tu":this.contentBox.x=(E-e)/2,this.contentBox.y=0,this.glyphBox.x=this.contentBox.x+x-r,this.glyphBox.y=n-B;break}break}case"horizontal-tb":this.contentBox.x=0,this.contentBox.y=(d-n)/2,this.glyphBox.x=x-r,this.glyphBox.y=D-o;break}return this}clone(){const t=new z(this.content,this.parent);return t.contentBox=this.contentBox.clone(),t.glyphBox=this.glyphBox.clone(),t}}class T{constructor(t,e,n){this.content=t,this.style=e,this.parent=n,this.contentBox=new g,this.inlineBox=new g,this.glyphBox=new g,this.centerX=0,this.baseline=0,this.update()}update(){var n;this.computedStyle={...(n=this.parent)==null?void 0:n.computedStyle,...this.style};const t=this.computedStyle;this.computedContent=t.textTransform==="uppercase"?this.content.toUpperCase():t.textTransform==="lowercase"?this.content.toLowerCase():this.content;const e=[];for(const o of this.computedContent)e.push(new z(o,this));return this.characters=e,this}measure(){var e;const t=this.computedStyle;switch(t.writingMode){case"vertical-lr":case"vertical-rl":{let n=0,o=0,r=0;this.characters.forEach((i,B)=>{i.update().measure(),o=Math.max(o,i.contentBox.width),r=Math.max(r,i.glyphBox.width),n+=i.contentBox.y+i.contentBox.height,B!==this.characters.length-1&&(n+=t.letterSpacing)}),this.inlineBox.width=t.fontSize*t.lineHeight,this.inlineBox.height=n,this.contentBox.width=o,this.contentBox.height=n,this.glyphBox.width=r,this.glyphBox.height=n,this.baseline=((e=this.characters[0])==null?void 0:e.baseline)??0,this.centerX=n/2;break}case"horizontal-tb":{let n=0,o=0,r=0;this.characters.forEach((B,d)=>{B.update().measure(),o=Math.max(o,B.contentBox.height),r=Math.max(r,B.glyphBox.height),n+=B.contentBox.x+B.contentBox.width,d!==this.characters.length-1&&(n+=t.letterSpacing)}),this.inlineBox.width=n,this.inlineBox.height=t.fontSize*t.lineHeight,this.contentBox.width=n,this.contentBox.height=o,this.glyphBox.width=n,this.glyphBox.height=r,this.centerX=n/2,this.inlineBox.x=0,this.inlineBox.y=0;const i=this.characters[0];i&&(this.baseline=i.baseline,this.contentBox.x=i.contentBox.x,this.glyphBox.x=i.glyphBox.x),this.contentBox.y=(this.inlineBox.height-this.contentBox.height)/2,this.glyphBox.y=(this.inlineBox.height-this.glyphBox.height)/2;break}}return this}clone(t){return new T(t??this.content,this.style,this.parent)}}class M{constructor(t,e){this.style=t,this.parent=e,this.contentBox=new g,this.lineBox=new g,this.glyphBox=new g,this.baseline=0,this.xHeight=0,this.fragments=[],this.update()}update(){this.computedStyle={...this.parent,...this.style}}addFragment(t,e){return this.fragments.push(new T(t,e,this)),this}clone(t){const e=new M(this.style,this.parent);return e.contentBox=this.contentBox.clone(),e.lineBox=this.lineBox.clone(),e.glyphBox=this.glyphBox.clone(),e.baseline=this.baseline,e.xHeight=this.xHeight,e.fragments=t??this.fragments.map(n=>n.clone()),e}}function V(h,t){const e=[];if(typeof h=="string")e.push(new M(void 0,t).addFragment(h));else{h=Array.isArray(h)?h:[h];for(const n of h)if(typeof n=="string")e.push(new M(void 0,t).addFragment(n));else if(Array.isArray(n)){const o=new M(void 0,t);n.forEach(r=>{if(typeof r=="string")o.addFragment(r);else{const{content:i,...B}=r;o.addFragment(i,B)}}),e.push(o)}else if("fragments"in n){const{fragments:o,...r}=n,i=new M(r,t);o.forEach(B=>{const{content:d,...D}=B;i.addFragment(d,D)}),e.push(i)}else if("content"in n){const{content:o,...r}=n;e.push(new M(r,t).addFragment(o))}}return e}function q(h,t,e){var B;const n=[],o=h.slice();let r,i;for(;r=o.shift();){const d=r.fragments.slice();let D=0;const x=[];for(;i=d.shift();){const E=i.computedStyle;let a="",S=!1,k=0;const u=new T("",i.style,i.parent);for(const A of i.characters){if(u.content+=A.content,(B=i.characters[++k])!=null&&B.isPunctuation)continue;let y,p;switch(E.writingMode){case"vertical-lr":case"vertical-rl":y=e,p=u.update().measure().contentBox.height;break;case"horizontal-tb":default:y=t,p=u.update().measure().contentBox.width;break}if(p+=E.letterSpacing,A.isEOL||y&&D+p>y){let s=A.isEOL?a.length+1:a.length;!D&&!s&&(a+=u.computedContent,s+=u.computedContent.length),a.length&&x.push(i.clone(a)),x.length&&(n.push(r.clone(x.slice())),x.length=0);const l=i.computedContent.substring(s);(l.length||d.length)&&o.unshift(r.clone((l.length?[i.clone(l)]:[]).concat(d.slice()))),d.length=0,S=!0;break}else D+=p;a+=u.computedContent,u.content=""}S||x.push(i.clone())}x.length&&n.push(r.clone(x))}return n}const U={width:0,height:0,color:"#000",backgroundColor:"rgba(0, 0, 0, 0)",fontSize:14,fontWeight:"normal",fontFamily:"sans-serif",fontStyle:"normal",fontKerning:"normal",textWrap:"wrap",textAlign:"start",verticalAlign:"baseline",textTransform:"none",textDecoration:"none",textStrokeWidth:0,textStrokeColor:"#000",lineHeight:1,letterSpacing:0,shadowColor:"rgba(0, 0, 0, 0)",shadowOffsetX:0,shadowOffsetY:0,shadowBlur:0,writingMode:"horizontal-tb",textOrientation:"mixed"};function J(h){return{...U,...h}}function X(h){const{content:t,effects:e=[{}]}=h,{width:n,height:o,...r}=J(h.style);let i=V(t,r);i=q(i,n,o);let B=0,d=0;i.forEach(u=>{let A=null;u.fragments.forEach(F=>{F.update().measure(),(!A||A.contentBox.height<F.contentBox.height)&&(A=F)});const{glyphHeight:y,baseline:p}=$("x",(A??u).computedStyle);u.xHeight=y,u.baseline=p;const s=u.computedStyle;let l=B,c=d,m=0;u.fragments.forEach((F,f)=>{const C=F.computedStyle;switch(s.writingMode){case"vertical-rl":case"vertical-lr":{f||(c=0),F.inlineBox.translate(l,c),F.contentBox.translate(l,c),F.glyphBox.translate(l,c);let b=c;F.characters.forEach((w,R)=>{const W=w.contentBox.y+w.contentBox.height;w.contentBox.translate(l,b),w.glyphBox.translate(l,b),b+=W,R!==F.characters.length-1&&(b+=C.letterSpacing)}),c+=F.inlineBox.height,f===u.fragments.length-1&&(l+=F.inlineBox.width);break}case"horizontal-tb":{f||(l=0),F.inlineBox.translate(l,c),F.contentBox.translate(l,c),F.glyphBox.translate(l,c);let b=l;F.characters.forEach((w,R)=>{const W=w.contentBox.x+w.contentBox.width;w.contentBox.translate(b,c),w.glyphBox.translate(b,c),b+=W,R!==F.characters.length-1&&(b+=C.letterSpacing)}),l+=F.inlineBox.width,m=Math.max(m,F.inlineBox.height),f===u.fragments.length-1&&(c+=m);break}}}),B=l,d=c,u.lineBox=g.from(...u.fragments.map(F=>F.inlineBox))});const D=g.from(...i.map(u=>u.lineBox),new g(0,0,n,o)),{width:x,height:E}=D;i.forEach(u=>{let A=0;const y=0,p=u.computedStyle;switch(p.writingMode){case"vertical-rl":A+=x-(u.lineBox.x*2+u.lineBox.width);case"vertical-lr":u.lineBox.height=Math.max(u.lineBox.height,E);break;case"horizontal-tb":u.lineBox.width=Math.max(u.lineBox.width,x);break}u.contentBox=g.from(...u.fragments.map(s=>s.contentBox)),u.glyphBox=g.from(...u.fragments.map(s=>s.glyphBox)),u.fragments.forEach(s=>{let l=A,c=y;const m=s.computedStyle;switch(p.writingMode){case"vertical-rl":case"vertical-lr":{switch(m.textAlign){case"end":case"right":c+=E-u.contentBox.height;break;case"center":c+=(E-u.contentBox.height)/2;break}s.characters.forEach(F=>{let f=l;const C=c;switch(m.verticalAlign){case"top":case"middle":case"bottom":case"sub":case"super":case"text-top":case"text-bottom":case"baseline":default:f+=u.baseline-F.baseline;break}F.contentBox.translate(f,C),F.glyphBox.translate(f,C)});break}case"horizontal-tb":{switch(m.textAlign){case"end":case"right":l=x-u.contentBox.width;break;case"center":l=(x-u.contentBox.width)/2;break}switch(m.verticalAlign){case"top":c=u.lineBox.y-s.inlineBox.y;break;case"middle":c=s.inlineBox.y-(u.baseline-u.xHeight/2-s.inlineBox.height/2);break;case"bottom":c=u.lineBox.bottom-s.inlineBox.bottom;break;case"sub":c=u.lineBox.y+u.baseline-s.glyphBox.bottom;break;case"super":c=u.lineBox.y+u.baseline-s.glyphBox.y;break;case"text-top":c=u.glyphBox.y-s.inlineBox.y;break;case"text-bottom":c=u.glyphBox.bottom-s.inlineBox.bottom;break;case"baseline":default:s.inlineBox.height<u.lineBox.height&&(c=u.baseline-s.baseline);break}s.characters.forEach(F=>{F.contentBox.translate(l,c),F.glyphBox.translate(l,c)});break}}s.inlineBox.translate(l,c),s.contentBox.translate(l,c),s.glyphBox.translate(l,c)}),u.lineBox=g.from(u.lineBox,...u.fragments.map(s=>s.inlineBox)),u.contentBox=g.from(...u.fragments.map(s=>s.contentBox)),u.glyphBox=g.from(...u.fragments.map(s=>s.glyphBox))});const a=g.from(...i.map(u=>u.contentBox)),S=g.from(...i.map(u=>u.glyphBox)),k=[];return i.forEach(u=>{u.fragments.forEach(A=>{const y=A.computedStyle;e.forEach(p=>{const s={...y,...p},{textStrokeWidth:l=0,offsetX:c=0,offsetY:m=0}=s;if(l||c||m){const{x:F,y:f,width:C,height:b}=A.contentBox;k.push(new g(Math.min(F,F+c-l/2),Math.min(f,f+m-l/2),Math.max(C,C+c+l),Math.max(b,b+m+l)))}})})}),{box:D,contentBox:a,glyphBox:S,paragraphs:i,viewBox:g.from(D,S,...k)}}function H(h,t,e){if(typeof t=="string"&&t.startsWith("linear-gradient")){const{x0:n,y0:o,x1:r,y1:i,stops:B}=Q(t,e.left,e.top,e.width,e.height),d=h.createLinearGradient(n,o,r,i);return B.forEach(D=>d.addColorStop(D.offset,D.color)),d}return t}function Q(h,t,e,n,o){var S;const r=((S=h.match(/linear-gradient\((.+)\)$/))==null?void 0:S[1])??"",i=r.split(",")[0],B=i.includes("deg")?i:"0deg",d=r.replace(B,"").matchAll(/(#|rgba|rgb)(.+?) ([\d.]+?%)/gi),x=(Number(B.replace("deg",""))||0)*Math.PI/180,E=n*Math.sin(x),a=o*Math.cos(x);return{x0:t+n/2-E,y0:e+o/2+a,x1:t+n/2+E,y1:e+o/2-a,stops:Array.from(d).map(k=>{let u=k[2];return u.startsWith("(")?u=u.split(",").length>3?`rgba${u}`:`rgb${u}`:u=`#${u}`,{offset:Number(k[3].replace("%",""))/100,color:u}})}}function O(h,t,e){e!=null&&e.color&&(e.color=H(h,e.color,t)),e!=null&&e.backgroundColor&&(e.backgroundColor=H(h,e.backgroundColor,t)),e!=null&&e.textStrokeColor&&(e.textStrokeColor=H(h,e.textStrokeColor,t))}function Z(h){const{view:t=document.createElement("canvas"),style:e,effects:n=[],pixelRatio:o=1}=h,r=n.length>0?n:[{}],{viewBox:i,paragraphs:B}=X(h),{x:d,y:D,width:x,height:E}=i,a=t.getContext("2d");t.style.width=`${x}px`,t.style.height=`${E}px`,t.dataset.viewbox=`${d} ${D} ${x} ${E}`,t.dataset.pixelRatio=String(o),t.width=Math.max(1,Math.floor(x*o)),t.height=Math.max(1,Math.floor(E*o)),a.scale(o,o),a.clearRect(0,0,t.width,t.height);const S=(u,A,y,p,s)=>{a.fillStyle=u,a.fillRect(-i.x+A,-i.y+y,p,s)},k={...e};return O(a,new g(0,0,x,E),k),B.forEach(u=>{O(a,u.contentBox,u.computedStyle),u.fragments.forEach(A=>{O(a,A.contentBox,A.computedStyle)})}),r.forEach(u=>{const A={...u};O(a,new g(0,0,x,E),A);const y={...k,...A};y!=null&&y.backgroundColor&&S(y.backgroundColor,0,0,t.width,t.height),B.forEach(p=>{var s;(s=p.style)!=null&&s.backgroundColor&&S(p.computedStyle.backgroundColor,...p.lineBox.toArray()),p.fragments.forEach(l=>{var c;(c=l.style)!=null&&c.backgroundColor&&S(l.computedStyle.backgroundColor,...l.inlineBox.toArray())})}),B.forEach(p=>{p.fragments.forEach(s=>{const l=-i.x+(A.offsetX??0),c=-i.y+(A.offsetY??0),m={...s.computedStyle,...A};switch(P(a,{...m,textAlign:"left"}),m.writingMode){case"vertical-rl":case"vertical-lr":{s.characters.forEach(F=>{let f=0,C=0;switch(F.verticalOrientation){case"Tr":case"R":{a.rotate(Math.PI/2),a.textBaseline="alphabetic",C=-(l+s.inlineBox.x+s.inlineBox.width-F.baseline),f=c+F.contentBox.y;break}case"Tu":a.textBaseline="top",f=l+F.contentBox.x+F.contentBox.right-F.glyphBox.right,C=c+F.contentBox.y+F.contentBox.y-F.glyphBox.y;break;case"U":f=l+F.contentBox.x,C=c+F.contentBox.y,a.textBaseline="top";break}a.fillText(F.content,f,C),m.textStrokeWidth&&a.strokeText(F.content,f,C),a.setTransform(1,0,0,1,0,0),a.scale(o,o)});break}case"horizontal-tb":{const F=l+s.contentBox.x,f=c+s.contentBox.y,C=c+s.inlineBox.y+s.baseline;a.textBaseline="alphabetic",a.fillText(s.computedContent,F,C),m.textStrokeWidth&&a.strokeText(s.computedContent,F,C);const{width:b,height:w}=s.contentBox;switch(m.textDecoration){case"underline":a.strokeStyle=a.fillStyle,a.lineWidth=m.fontSize/15,a.beginPath(),a.moveTo(F,f+w),a.lineTo(F+b,f+w),a.stroke();break;case"line-through":a.strokeStyle=a.fillStyle,a.lineWidth=m.fontSize/15,a.beginPath(),a.moveTo(F,f+w/2),a.lineTo(F+b,f+w/2),a.stroke();break}break}}})})}),t}v.defaultTextStyles=U,v.measureText=X,v.renderText=Z,Object.defineProperty(v,Symbol.toStringTag,{value:"Module"})});
|
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
class
|
|
1
|
+
class A {
|
|
2
2
|
constructor(t = 0, e = 0, n = 0, o = 0) {
|
|
3
3
|
this.x = t, this.y = e, this.width = n, this.height = o;
|
|
4
4
|
}
|
|
@@ -15,8 +15,8 @@ class x {
|
|
|
15
15
|
return this.y + this.height;
|
|
16
16
|
}
|
|
17
17
|
static from(...t) {
|
|
18
|
-
const e = t[0], n = t.slice(1).reduce((o,
|
|
19
|
-
return new
|
|
18
|
+
const e = t[0], n = t.slice(1).reduce((o, r) => (o.x = Math.min(o.x, r.x), o.y = Math.min(o.y, r.y), o.right = Math.max(o.right, r.right), o.bottom = Math.max(o.bottom, r.bottom), o), { x: e.x, y: e.y, right: e.right, bottom: e.bottom });
|
|
19
|
+
return new A(
|
|
20
20
|
n.x,
|
|
21
21
|
n.y,
|
|
22
22
|
n.right - n.x,
|
|
@@ -31,7 +31,7 @@ class x {
|
|
|
31
31
|
return this.x += t, this.y += e, this;
|
|
32
32
|
}
|
|
33
33
|
clone() {
|
|
34
|
-
return new
|
|
34
|
+
return new A(
|
|
35
35
|
this.x,
|
|
36
36
|
this.y,
|
|
37
37
|
this.width,
|
|
@@ -42,31 +42,31 @@ class x {
|
|
|
42
42
|
return [this.x, this.y, this.width, this.height];
|
|
43
43
|
}
|
|
44
44
|
}
|
|
45
|
-
function P(
|
|
46
|
-
switch (
|
|
45
|
+
function P(h, t) {
|
|
46
|
+
switch (h.shadowColor = t.shadowColor || "rgba(0, 0, 0, 0)", h.shadowOffsetX = t.shadowOffsetX || 0, h.shadowOffsetY = t.shadowOffsetY || 0, h.shadowBlur = t.shadowBlur || 0, h.strokeStyle = t.textStrokeColor || "#000", h.lineWidth = t.textStrokeWidth || 0, h.fillStyle = t.color || "#000", h.textAlign = t.textAlign || "start", h.fontKerning = t.fontKerning || "normal", t.verticalAlign) {
|
|
47
47
|
case "top":
|
|
48
48
|
case "middle":
|
|
49
49
|
case "bottom":
|
|
50
|
-
|
|
50
|
+
h.textBaseline = t.verticalAlign;
|
|
51
51
|
break;
|
|
52
52
|
case "baseline":
|
|
53
53
|
default:
|
|
54
|
-
|
|
54
|
+
h.textBaseline = "alphabetic";
|
|
55
55
|
break;
|
|
56
56
|
}
|
|
57
|
-
|
|
57
|
+
h.font = [
|
|
58
58
|
t.fontStyle || "normal",
|
|
59
59
|
t.fontWeight || "normal",
|
|
60
60
|
`${t.fontSize || 14}px`,
|
|
61
61
|
t.fontFamily || "sans-serif"
|
|
62
|
-
].join(" "),
|
|
62
|
+
].join(" "), h.letterSpacing = `${t.letterSpacing || 0}px`;
|
|
63
63
|
}
|
|
64
64
|
const L = "OffscreenCanvas" in globalThis;
|
|
65
65
|
let U;
|
|
66
66
|
function X() {
|
|
67
67
|
return U ?? (U = L ? new OffscreenCanvas(1, 1) : document.createElement("canvas"));
|
|
68
68
|
}
|
|
69
|
-
function $(
|
|
69
|
+
function $(h, t) {
|
|
70
70
|
const e = X().getContext("2d");
|
|
71
71
|
P(e, {
|
|
72
72
|
...t,
|
|
@@ -76,43 +76,43 @@ function $(r, t) {
|
|
|
76
76
|
const {
|
|
77
77
|
width: n,
|
|
78
78
|
actualBoundingBoxAscent: o,
|
|
79
|
-
actualBoundingBoxDescent:
|
|
79
|
+
actualBoundingBoxDescent: r,
|
|
80
80
|
actualBoundingBoxLeft: i,
|
|
81
81
|
actualBoundingBoxRight: B,
|
|
82
|
-
fontBoundingBoxAscent:
|
|
82
|
+
fontBoundingBoxAscent: E,
|
|
83
83
|
fontBoundingBoxDescent: D
|
|
84
|
-
} = e.measureText(
|
|
84
|
+
} = e.measureText(h), g = t.fontSize * t.lineHeight, d = E + D;
|
|
85
85
|
return {
|
|
86
86
|
width: n,
|
|
87
87
|
height: t.fontSize,
|
|
88
|
-
typoAscent:
|
|
88
|
+
typoAscent: E,
|
|
89
89
|
typoDescent: D,
|
|
90
90
|
typoHeight: d,
|
|
91
91
|
lineHeight: g,
|
|
92
92
|
glyphLeft: i,
|
|
93
93
|
glyphRight: B,
|
|
94
94
|
glyphAscent: o,
|
|
95
|
-
glyphDescent:
|
|
95
|
+
glyphDescent: r,
|
|
96
96
|
glyphWidth: i + B,
|
|
97
|
-
glyphHeight: o +
|
|
98
|
-
baseline: (g - d) / 2 +
|
|
97
|
+
glyphHeight: o + r,
|
|
98
|
+
baseline: (g - d) / 2 + E,
|
|
99
99
|
centerX: n / 2
|
|
100
100
|
};
|
|
101
101
|
}
|
|
102
|
-
function N(
|
|
102
|
+
function N(h, t) {
|
|
103
103
|
const e = document.createDocumentFragment(), n = document.createElement("div");
|
|
104
104
|
n.style.position = "absolute", n.style.visibility = "hidden", n.setAttribute("aria-hidden", "true"), n.style.fontFamily = t.fontFamily, n.style.fontSize = `${t.fontSize}px`, n.style.lineHeight = String(t.lineHeight), n.style.whiteSpace = "nowrap", n.style.writingMode = t.writingMode;
|
|
105
105
|
const o = document.createElement("span");
|
|
106
|
-
o.textContent = /\s/.test(
|
|
107
|
-
const
|
|
106
|
+
o.textContent = /\s/.test(h) ? " " : h, n.appendChild(o), e.appendChild(n), document.body.appendChild(e);
|
|
107
|
+
const r = {
|
|
108
108
|
leading: o.offsetHeight - t.fontSize
|
|
109
109
|
};
|
|
110
|
-
return document.body.removeChild(n),
|
|
110
|
+
return document.body.removeChild(n), r;
|
|
111
111
|
}
|
|
112
112
|
const Y = /[\u{00A7}\u{00A9}\u{00AE}\u{00B1}\u{00BC}-\u{00BE}\u{00D7}\u{00F7}\u{02EA}-\u{02EB}\u{1100}-\u{11FF}\u{1401}-\u{166C}\u{166D}\u{166E}\u{166F}-\u{167F}\u{18B0}-\u{18F5}\u{18F6}-\u{18FF}\u{2016}\u{2020}-\u{2021}\u{2030}-\u{2031}\u{203B}-\u{203C}\u{2042}\u{2047}-\u{2049}\u{2051}\u{2065}\u{20DD}-\u{20E0}\u{20E2}-\u{20E4}\u{2100}-\u{2101}\u{2103}-\u{2106}\u{2107}\u{2108}-\u{2109}\u{210F}\u{2113}\u{2114}\u{2116}-\u{2117}\u{211E}-\u{2123}\u{2125}\u{2127}\u{2129}\u{212E}\u{2135}-\u{2138}\u{2139}\u{213A}-\u{213B}\u{213C}-\u{213F}\u{2145}-\u{2149}\u{214A}\u{214C}-\u{214D}\u{214F}\u{2150}-\u{215F}\u{2160}-\u{2182}\u{2183}-\u{2184}\u{2185}-\u{2188}\u{2189}\u{218C}-\u{218F}\u{221E}\u{2234}-\u{2235}\u{2300}-\u{2307}\u{230C}-\u{231F}\u{2324}-\u{2328}\u{232B}\u{237D}-\u{239A}\u{23BE}-\u{23CD}\u{23CF}\u{23D1}-\u{23DB}\u{23E2}-\u{23FF}\u{2400}-\u{2422}\u{2424}-\u{2426}\u{2427}-\u{243F}\u{2440}-\u{244A}\u{244B}-\u{245F}\u{2460}-\u{249B}\u{249C}-\u{24E9}\u{24EA}-\u{24FF}\u{25A0}-\u{25B6}\u{25B7}\u{25B8}-\u{25C0}\u{25C1}\u{25C2}-\u{25F7}\u{25F8}-\u{25FF}\u{2600}-\u{2619}\u{2620}-\u{266E}\u{266F}\u{2670}-\u{26FF}\u{2700}-\u{2767}\u{2776}-\u{2793}\u{2B12}-\u{2B2F}\u{2B50}-\u{2B59}\u{2B97}\u{2BB8}-\u{2BD1}\u{2BD3}-\u{2BEB}\u{2BF0}-\u{2BFF}\u{2E50}-\u{2E51}\u{2E80}-\u{2E99}\u{2E9A}\u{2E9B}-\u{2EF3}\u{2EF4}-\u{2EFF}\u{2F00}-\u{2FD5}\u{2FD6}-\u{2FDF}\u{2FE0}-\u{2FEF}\u{2FF0}-\u{2FFB}\u{2FFC}-\u{2FFF}\u{3000}\u{3001}-\u{3002}\u{3003}\u{3004}\u{3005}\u{3006}\u{3007}\u{3012}-\u{3013}\u{3020}\u{3021}-\u{3029}\u{302A}-\u{302D}\u{302E}-\u{302F}\u{3031}-\u{3035}\u{3036}-\u{3037}\u{3038}-\u{303A}\u{303B}\u{303C}\u{303D}\u{303E}-\u{303F}\u{3040}\u{3041}\u{3042}\u{3043}\u{3044}\u{3045}\u{3046}\u{3047}\u{3048}\u{3049}\u{304A}-\u{3062}\u{3063}\u{3064}-\u{3082}\u{3083}\u{3084}\u{3085}\u{3086}\u{3087}\u{3088}-\u{308D}\u{308E}\u{308F}-\u{3094}\u{3095}-\u{3096}\u{3097}-\u{3098}\u{3099}-\u{309A}\u{309B}-\u{309C}\u{309D}-\u{309E}\u{309F}\u{30A1}\u{30A2}\u{30A3}\u{30A4}\u{30A5}\u{30A6}\u{30A7}\u{30A8}\u{30A9}\u{30AA}-\u{30C2}\u{30C3}\u{30C4}-\u{30E2}\u{30E3}\u{30E4}\u{30E5}\u{30E6}\u{30E7}\u{30E8}-\u{30ED}\u{30EE}\u{30EF}-\u{30F4}\u{30F5}-\u{30F6}\u{30F7}-\u{30FA}\u{30FB}\u{30FD}-\u{30FE}\u{30FF}\u{3100}-\u{3104}\u{3105}-\u{3126}\u{3127}\u{3128}-\u{312F}\u{3130}\u{3131}-\u{318E}\u{318F}\u{3190}-\u{3191}\u{3192}-\u{3195}\u{3196}-\u{319F}\u{31A0}-\u{31BF}\u{31C0}-\u{31E3}\u{31E4}-\u{31EF}\u{31F0}-\u{31FF}\u{3200}-\u{321E}\u{321F}\u{3220}-\u{3229}\u{322A}-\u{3247}\u{3248}-\u{324F}\u{3250}\u{3251}-\u{325F}\u{3260}-\u{327F}\u{3280}-\u{3289}\u{328A}-\u{32B0}\u{32B1}-\u{32BF}\u{32C0}-\u{32FE}\u{32FF}\u{3300}-\u{3357}\u{3358}-\u{337A}\u{337B}-\u{337F}\u{3380}-\u{33FF}\u{3400}-\u{4DBF}\u{4DC0}-\u{4DFF}\u{4E00}-\u{9FFF}\u{A000}-\u{A014}\u{A015}\u{A016}-\u{A48C}\u{A48D}-\u{A48F}\u{A490}-\u{A4C6}\u{A4C7}-\u{A4CF}\u{A960}-\u{A97C}\u{A97D}-\u{A97F}\u{AC00}-\u{D7A3}\u{D7A4}-\u{D7AF}\u{D7B0}-\u{D7C6}\u{D7C7}-\u{D7CA}\u{D7CB}-\u{D7FB}\u{D7FC}-\u{D7FF}\u{E000}-\u{F8FF}\u{F900}-\u{FA6D}\u{FA6E}-\u{FA6F}\u{FA70}-\u{FAD9}\u{FADA}-\u{FAFF}\u{FE10}-\u{FE16}\u{FE17}\u{FE18}\u{FE19}\u{FE1A}-\u{FE1F}\u{FE30}\u{FE31}-\u{FE32}\u{FE33}-\u{FE34}\u{FE35}\u{FE36}\u{FE37}\u{FE38}\u{FE39}\u{FE3A}\u{FE3B}\u{FE3C}\u{FE3D}\u{FE3E}\u{FE3F}\u{FE40}\u{FE41}\u{FE42}\u{FE43}\u{FE44}\u{FE45}-\u{FE46}\u{FE47}\u{FE48}\u{FE50}-\u{FE52}\u{FE53}\u{FE54}-\u{FE57}\u{FE5F}-\u{FE61}\u{FE62}\u{FE67}\u{FE68}\u{FE69}\u{FE6A}-\u{FE6B}\u{FE6C}-\u{FE6F}\u{FF01}\u{FF02}-\u{FF03}\u{FF04}\u{FF05}-\u{FF07}\u{FF0A}\u{FF0B}\u{FF0C}\u{FF0E}\u{FF0F}\u{FF10}-\u{FF19}\u{FF1F}\u{FF20}\u{FF21}-\u{FF3A}\u{FF3C}\u{FF3E}\u{FF40}\u{FF41}-\u{FF5A}\u{FFE0}-\u{FFE1}\u{FFE2}\u{FFE4}\u{FFE5}-\u{FFE6}\u{FFE7}\u{FFF0}-\u{FFF8}\u{FFFC}-\u{FFFD}\u{10980}-\u{1099F}\u{11580}-\u{115AE}\u{115AF}-\u{115B1}\u{115B2}-\u{115B5}\u{115B6}-\u{115B7}\u{115B8}-\u{115BB}\u{115BC}-\u{115BD}\u{115BE}\u{115BF}-\u{115C0}\u{115C1}-\u{115D7}\u{115D8}-\u{115DB}\u{115DC}-\u{115DD}\u{115DE}-\u{115FF}\u{11A00}\u{11A01}-\u{11A0A}\u{11A0B}-\u{11A32}\u{11A33}-\u{11A38}\u{11A39}\u{11A3A}\u{11A3B}-\u{11A3E}\u{11A3F}-\u{11A46}\u{11A47}\u{11A48}-\u{11A4F}\u{11A50}\u{11A51}-\u{11A56}\u{11A57}-\u{11A58}\u{11A59}-\u{11A5B}\u{11A5C}-\u{11A89}\u{11A8A}-\u{11A96}\u{11A97}\u{11A98}-\u{11A99}\u{11A9A}-\u{11A9C}\u{11A9D}\u{11A9E}-\u{11AA2}\u{11AA3}-\u{11AAF}\u{11AB0}-\u{11ABF}\u{13000}-\u{1342E}\u{1342F}\u{13430}-\u{13438}\u{13439}-\u{1343F}\u{14400}-\u{14646}\u{14647}-\u{1467F}\u{16FE0}-\u{16FE1}\u{16FE2}\u{16FE3}\u{16FE4}\u{16FE5}-\u{16FEF}\u{16FF0}-\u{16FF1}\u{16FF2}-\u{16FFF}\u{17000}-\u{187F7}\u{187F8}-\u{187FF}\u{18800}-\u{18AFF}\u{18B00}-\u{18CD5}\u{18CD6}-\u{18CFF}\u{18D00}-\u{18D08}\u{18D09}-\u{18D7F}\u{1AFF0}-\u{1AFF3}\u{1AFF4}\u{1AFF5}-\u{1AFFB}\u{1AFFC}\u{1AFFD}-\u{1AFFE}\u{1AFFF}\u{1B000}-\u{1B0FF}\u{1B100}-\u{1B122}\u{1B123}-\u{1B12F}\u{1B130}-\u{1B14F}\u{1B150}-\u{1B152}\u{1B153}-\u{1B163}\u{1B164}-\u{1B167}\u{1B168}-\u{1B16F}\u{1B170}-\u{1B2FB}\u{1B2FC}-\u{1B2FF}\u{1CF00}-\u{1CF2D}\u{1CF2E}-\u{1CF2F}\u{1CF30}-\u{1CF46}\u{1CF47}-\u{1CF4F}\u{1CF50}-\u{1CFC3}\u{1CFC4}-\u{1CFCF}\u{1D000}-\u{1D0F5}\u{1D0F6}-\u{1D0FF}\u{1D100}-\u{1D126}\u{1D127}-\u{1D128}\u{1D129}-\u{1D164}\u{1D165}-\u{1D166}\u{1D167}-\u{1D169}\u{1D16A}-\u{1D16C}\u{1D16D}-\u{1D172}\u{1D173}-\u{1D17A}\u{1D17B}-\u{1D182}\u{1D183}-\u{1D184}\u{1D185}-\u{1D18B}\u{1D18C}-\u{1D1A9}\u{1D1AA}-\u{1D1AD}\u{1D1AE}-\u{1D1EA}\u{1D1EB}-\u{1D1FF}\u{1D2E0}-\u{1D2F3}\u{1D2F4}-\u{1D2FF}\u{1D300}-\u{1D356}\u{1D357}-\u{1D35F}\u{1D360}-\u{1D378}\u{1D379}-\u{1D37F}\u{1D800}-\u{1D9FF}\u{1DA00}-\u{1DA36}\u{1DA37}-\u{1DA3A}\u{1DA3B}-\u{1DA6C}\u{1DA6D}-\u{1DA74}\u{1DA75}\u{1DA76}-\u{1DA83}\u{1DA84}\u{1DA85}-\u{1DA86}\u{1DA87}-\u{1DA8B}\u{1DA8C}-\u{1DA9A}\u{1DA9B}-\u{1DA9F}\u{1DAA0}\u{1DAA1}-\u{1DAAF}\u{1F000}-\u{1F02B}\u{1F02C}-\u{1F02F}\u{1F030}-\u{1F093}\u{1F094}-\u{1F09F}\u{1F0A0}-\u{1F0AE}\u{1F0AF}-\u{1F0B0}\u{1F0B1}-\u{1F0BF}\u{1F0C0}\u{1F0C1}-\u{1F0CF}\u{1F0D0}\u{1F0D1}-\u{1F0F5}\u{1F0F6}-\u{1F0FF}\u{1F100}-\u{1F10C}\u{1F10D}-\u{1F1AD}\u{1F1AE}-\u{1F1E5}\u{1F1E6}-\u{1F1FF}\u{1F200}-\u{1F201}\u{1F202}\u{1F203}-\u{1F20F}\u{1F210}-\u{1F23B}\u{1F23C}-\u{1F23F}\u{1F240}-\u{1F248}\u{1F249}-\u{1F24F}\u{1F250}-\u{1F251}\u{1F252}-\u{1F25F}\u{1F260}-\u{1F265}\u{1F266}-\u{1F2FF}\u{1F300}-\u{1F3FA}\u{1F3FB}-\u{1F3FF}\u{1F400}-\u{1F5FF}\u{1F600}-\u{1F64F}\u{1F650}-\u{1F67F}\u{1F680}-\u{1F6D7}\u{1F6D8}-\u{1F6DC}\u{1F6DD}-\u{1F6EC}\u{1F6ED}-\u{1F6EF}\u{1F6F0}-\u{1F6FC}\u{1F6FD}-\u{1F6FF}\u{1F700}-\u{1F773}\u{1F774}-\u{1F77F}\u{1F780}-\u{1F7D8}\u{1F7D9}-\u{1F7DF}\u{1F7E0}-\u{1F7EB}\u{1F7EC}-\u{1F7EF}\u{1F7F0}\u{1F7F1}-\u{1F7FF}\u{1F900}-\u{1F9FF}\u{1FA00}-\u{1FA53}\u{1FA54}-\u{1FA5F}\u{1FA60}-\u{1FA6D}\u{1FA6E}-\u{1FA6F}\u{1FA70}-\u{1FA74}\u{1FA75}-\u{1FA77}\u{1FA78}-\u{1FA7C}\u{1FA7D}-\u{1FA7F}\u{1FA80}-\u{1FA86}\u{1FA87}-\u{1FA8F}\u{1FA90}-\u{1FAAC}\u{1FAAD}-\u{1FAAF}\u{1FAB0}-\u{1FABA}\u{1FABB}-\u{1FABF}\u{1FAC0}-\u{1FAC5}\u{1FAC6}-\u{1FACF}\u{1FAD0}-\u{1FAD9}\u{1FADA}-\u{1FADF}\u{1FAE0}-\u{1FAE7}\u{1FAE8}-\u{1FAEF}\u{1FAF0}-\u{1FAF6}\u{1FAF7}-\u{1FAFF}\u{20000}-\u{2A6DF}\u{2A6E0}-\u{2A6FF}\u{2A700}-\u{2B738}\u{2B739}-\u{2B73F}\u{2B740}-\u{2B81D}\u{2B81E}-\u{2B81F}\u{2B820}-\u{2CEA1}\u{2CEA2}-\u{2CEAF}\u{2CEB0}-\u{2EBE0}\u{2EBE1}-\u{2F7FF}\u{2F800}-\u{2FA1D}\u{2FA1E}-\u{2FFFD}\u{30000}-\u{3134A}\u{3134B}-\u{3134F}\u{31350}-\u{3FFFD}]/u, W = /[\u{2329}\u{232A}\u{3001}\u{3002}\u{3008}\u{3009}\u{300A}\u{300B}\u{300C}\u{300D}\u{300E}\u{300F}\u{3010}\u{3011}\u{3014}\u{3015}\u{3016}\u{3017}\u{3018}\u{3019}\u{301A}\u{301B}\u{301C}\u{301D}\u{301E}\u{301F}\u{3030}\u{3041}\u{3043}\u{3045}\u{3047}\u{3049}\u{3063}\u{3083}\u{3085}\u{3087}\u{308E}\u{3095}\u{3096}\u{309B}\u{309C}\u{30A0}\u{30A1}\u{30A3}\u{30A5}\u{30A7}\u{30A9}\u{30C3}\u{30E3}\u{30E5}\u{30E7}\u{30EE}\u{30F5}\u{30F6}\u{30FC}\u{3127}\u{31F0}\u{31F1}\u{31F2}\u{31F3}\u{31F4}\u{31F5}\u{31F6}\u{31F7}\u{31F8}\u{31F9}\u{31FA}\u{31FB}\u{31FC}\u{31FD}\u{31FE}\u{31FF}\u{32FF}\u{3300}\u{3301}\u{3302}\u{3303}\u{3304}\u{3305}\u{3306}\u{3307}\u{3308}\u{3309}\u{330A}\u{330B}\u{330C}\u{330D}\u{330E}\u{330F}\u{3310}\u{3311}\u{3312}\u{3313}\u{3314}\u{3315}\u{3316}\u{3317}\u{3318}\u{3319}\u{331A}\u{331B}\u{331C}\u{331D}\u{331E}\u{331F}\u{3320}\u{3321}\u{3322}\u{3323}\u{3324}\u{3325}\u{3326}\u{3327}\u{3328}\u{3329}\u{332A}\u{332B}\u{332C}\u{332D}\u{332E}\u{332F}\u{3330}\u{3331}\u{3332}\u{3333}\u{3334}\u{3335}\u{3336}\u{3337}\u{3338}\u{3339}\u{333A}\u{333B}\u{333C}\u{333D}\u{333E}\u{333F}\u{3340}\u{3341}\u{3342}\u{3343}\u{3344}\u{3345}\u{3346}\u{3347}\u{3348}\u{3349}\u{334A}\u{334B}\u{334C}\u{334D}\u{334E}\u{334F}\u{3350}\u{3351}\u{3352}\u{3353}\u{3354}\u{3355}\u{3356}\u{3357}\u{337B}\u{337C}\u{337D}\u{337E}\u{337F}\u{FE50}\u{FE51}\u{FE52}\u{FE59}\u{FE5A}\u{FE5B}\u{FE5C}\u{FE5D}\u{FE5E}\u{FF01}\u{FF08}\u{FF09}\u{FF0C}\u{FF0E}\u{FF1A}\u{FF1B}\u{FF1F}\u{FF3B}\u{FF3D}\u{FF3F}\u{FF5B}\u{FF5C}\u{FF5D}\u{FF5E}\u{FF5F}\u{FF60}\u{FFE3}\u{1F200}\u{1F201}]/u, I = /[\s\n\t\u200B\u200C\u200D\u200E\u200F.,?!:;"'(){}\[\]<>\/\\|~#\$%\*\+=&^,。?!:;“”‘’()【】《》……——]/u, K = /[\r\n]/;
|
|
113
113
|
class R {
|
|
114
114
|
constructor(t, e) {
|
|
115
|
-
this.content = t, this.parent = e, this.contentBox = new
|
|
115
|
+
this.content = t, this.parent = e, this.contentBox = new A(), this.glyphBox = new A(), this.baseline = 0, this.verticalOrientation = "U", this.isPunctuation = !1, this.isEOL = !1, this.update();
|
|
116
116
|
}
|
|
117
117
|
get computedStyle() {
|
|
118
118
|
return this.parent.computedStyle;
|
|
@@ -138,10 +138,10 @@ class R {
|
|
|
138
138
|
width: e,
|
|
139
139
|
height: n,
|
|
140
140
|
glyphAscent: o,
|
|
141
|
-
glyphLeft:
|
|
141
|
+
glyphLeft: r,
|
|
142
142
|
glyphWidth: i,
|
|
143
143
|
glyphHeight: B,
|
|
144
|
-
lineHeight:
|
|
144
|
+
lineHeight: E,
|
|
145
145
|
baseline: D,
|
|
146
146
|
centerX: g
|
|
147
147
|
} = $(this.content, {
|
|
@@ -166,13 +166,13 @@ class R {
|
|
|
166
166
|
break;
|
|
167
167
|
}
|
|
168
168
|
case "Tu":
|
|
169
|
-
this.contentBox.x = (d - e) / 2, this.contentBox.y = 0, this.glyphBox.x = this.contentBox.x + g -
|
|
169
|
+
this.contentBox.x = (d - e) / 2, this.contentBox.y = 0, this.glyphBox.x = this.contentBox.x + g - r, this.glyphBox.y = n - B;
|
|
170
170
|
break;
|
|
171
171
|
}
|
|
172
172
|
break;
|
|
173
173
|
}
|
|
174
174
|
case "horizontal-tb":
|
|
175
|
-
this.contentBox.x = 0, this.contentBox.y = (
|
|
175
|
+
this.contentBox.x = 0, this.contentBox.y = (E - n) / 2, this.glyphBox.x = g - r, this.glyphBox.y = D - o;
|
|
176
176
|
break;
|
|
177
177
|
}
|
|
178
178
|
return this;
|
|
@@ -184,7 +184,7 @@ class R {
|
|
|
184
184
|
}
|
|
185
185
|
class T {
|
|
186
186
|
constructor(t, e, n) {
|
|
187
|
-
this.content = t, this.style = e, this.parent = n, this.contentBox = new
|
|
187
|
+
this.content = t, this.style = e, this.parent = n, this.contentBox = new A(), this.inlineBox = new A(), this.glyphBox = new A(), this.centerX = 0, this.baseline = 0, this.update();
|
|
188
188
|
}
|
|
189
189
|
update() {
|
|
190
190
|
var n;
|
|
@@ -205,17 +205,17 @@ class T {
|
|
|
205
205
|
switch (t.writingMode) {
|
|
206
206
|
case "vertical-lr":
|
|
207
207
|
case "vertical-rl": {
|
|
208
|
-
let n = 0, o = 0,
|
|
208
|
+
let n = 0, o = 0, r = 0;
|
|
209
209
|
this.characters.forEach((i, B) => {
|
|
210
|
-
i.update().measure(), o = Math.max(o, i.contentBox.width),
|
|
211
|
-
}), this.inlineBox.width = t.fontSize * t.lineHeight, this.inlineBox.height = n, this.contentBox.width = o, this.contentBox.height = n, this.glyphBox.width =
|
|
210
|
+
i.update().measure(), o = Math.max(o, i.contentBox.width), r = Math.max(r, i.glyphBox.width), n += i.contentBox.y + i.contentBox.height, B !== this.characters.length - 1 && (n += t.letterSpacing);
|
|
211
|
+
}), this.inlineBox.width = t.fontSize * t.lineHeight, this.inlineBox.height = n, this.contentBox.width = o, this.contentBox.height = n, this.glyphBox.width = r, this.glyphBox.height = n, this.baseline = ((e = this.characters[0]) == null ? void 0 : e.baseline) ?? 0, this.centerX = n / 2;
|
|
212
212
|
break;
|
|
213
213
|
}
|
|
214
214
|
case "horizontal-tb": {
|
|
215
|
-
let n = 0, o = 0,
|
|
216
|
-
this.characters.forEach((B,
|
|
217
|
-
B.update().measure(), o = Math.max(o, B.contentBox.height),
|
|
218
|
-
}), this.inlineBox.width = n, this.inlineBox.height = t.fontSize * t.lineHeight, this.contentBox.width = n, this.contentBox.height = o, this.glyphBox.width = n, this.glyphBox.height =
|
|
215
|
+
let n = 0, o = 0, r = 0;
|
|
216
|
+
this.characters.forEach((B, E) => {
|
|
217
|
+
B.update().measure(), o = Math.max(o, B.contentBox.height), r = Math.max(r, B.glyphBox.height), n += B.contentBox.x + B.contentBox.width, E !== this.characters.length - 1 && (n += t.letterSpacing);
|
|
218
|
+
}), this.inlineBox.width = n, this.inlineBox.height = t.fontSize * t.lineHeight, this.contentBox.width = n, this.contentBox.height = o, this.glyphBox.width = n, this.glyphBox.height = r, this.centerX = n / 2, this.inlineBox.x = 0, this.inlineBox.y = 0;
|
|
219
219
|
const i = this.characters[0];
|
|
220
220
|
i && (this.baseline = i.baseline, this.contentBox.x = i.contentBox.x, this.glyphBox.x = i.glyphBox.x), this.contentBox.y = (this.inlineBox.height - this.contentBox.height) / 2, this.glyphBox.y = (this.inlineBox.height - this.glyphBox.height) / 2;
|
|
221
221
|
break;
|
|
@@ -233,7 +233,7 @@ class T {
|
|
|
233
233
|
}
|
|
234
234
|
class v {
|
|
235
235
|
constructor(t, e) {
|
|
236
|
-
this.style = t, this.parent = e, this.contentBox = new
|
|
236
|
+
this.style = t, this.parent = e, this.contentBox = new A(), this.lineBox = new A(), this.glyphBox = new A(), this.baseline = 0, this.xHeight = 0, this.fragments = [], this.update();
|
|
237
237
|
}
|
|
238
238
|
update() {
|
|
239
239
|
this.computedStyle = {
|
|
@@ -249,82 +249,81 @@ class v {
|
|
|
249
249
|
return e.contentBox = this.contentBox.clone(), e.lineBox = this.lineBox.clone(), e.glyphBox = this.glyphBox.clone(), e.baseline = this.baseline, e.xHeight = this.xHeight, e.fragments = t ?? this.fragments.map((n) => n.clone()), e;
|
|
250
250
|
}
|
|
251
251
|
}
|
|
252
|
-
function _(
|
|
252
|
+
function _(h, t) {
|
|
253
253
|
const e = [];
|
|
254
|
-
if (typeof
|
|
255
|
-
e.push(new v(void 0, t).addFragment(
|
|
254
|
+
if (typeof h == "string")
|
|
255
|
+
e.push(new v(void 0, t).addFragment(h));
|
|
256
256
|
else {
|
|
257
|
-
|
|
258
|
-
for (const n of
|
|
257
|
+
h = Array.isArray(h) ? h : [h];
|
|
258
|
+
for (const n of h)
|
|
259
259
|
if (typeof n == "string")
|
|
260
260
|
e.push(new v(void 0, t).addFragment(n));
|
|
261
261
|
else if (Array.isArray(n)) {
|
|
262
262
|
const o = new v(void 0, t);
|
|
263
|
-
n.forEach((
|
|
264
|
-
if (typeof
|
|
265
|
-
o.addFragment(
|
|
263
|
+
n.forEach((r) => {
|
|
264
|
+
if (typeof r == "string")
|
|
265
|
+
o.addFragment(r);
|
|
266
266
|
else {
|
|
267
|
-
const { content: i, ...B } =
|
|
267
|
+
const { content: i, ...B } = r;
|
|
268
268
|
o.addFragment(i, B);
|
|
269
269
|
}
|
|
270
270
|
}), e.push(o);
|
|
271
271
|
} else if ("fragments" in n) {
|
|
272
|
-
const { fragments: o, ...
|
|
272
|
+
const { fragments: o, ...r } = n, i = new v(r, t);
|
|
273
273
|
o.forEach((B) => {
|
|
274
|
-
const { content:
|
|
275
|
-
i.addFragment(
|
|
274
|
+
const { content: E, ...D } = B;
|
|
275
|
+
i.addFragment(E, D);
|
|
276
276
|
}), e.push(i);
|
|
277
277
|
} else if ("content" in n) {
|
|
278
|
-
const { content: o, ...
|
|
279
|
-
e.push(new v(
|
|
278
|
+
const { content: o, ...r } = n;
|
|
279
|
+
e.push(new v(r, t).addFragment(o));
|
|
280
280
|
}
|
|
281
281
|
}
|
|
282
282
|
return e;
|
|
283
283
|
}
|
|
284
|
-
function G(
|
|
284
|
+
function G(h, t, e) {
|
|
285
285
|
var B;
|
|
286
|
-
const n = [], o =
|
|
287
|
-
let
|
|
288
|
-
for (;
|
|
289
|
-
const
|
|
286
|
+
const n = [], o = h.slice();
|
|
287
|
+
let r, i;
|
|
288
|
+
for (; r = o.shift(); ) {
|
|
289
|
+
const E = r.fragments.slice();
|
|
290
290
|
let D = 0;
|
|
291
291
|
const g = [];
|
|
292
|
-
for (; i =
|
|
292
|
+
for (; i = E.shift(); ) {
|
|
293
293
|
const d = i.computedStyle;
|
|
294
294
|
let a = "", S = !1, k = 0;
|
|
295
295
|
const u = new T("", i.style, i.parent);
|
|
296
|
-
for (const
|
|
297
|
-
if (u.content +=
|
|
296
|
+
for (const x of i.characters) {
|
|
297
|
+
if (u.content += x.content, (B = i.characters[++k]) != null && B.isPunctuation)
|
|
298
298
|
continue;
|
|
299
|
-
|
|
300
|
-
let p, F;
|
|
299
|
+
let y, p;
|
|
301
300
|
switch (d.writingMode) {
|
|
302
301
|
case "vertical-lr":
|
|
303
302
|
case "vertical-rl":
|
|
304
|
-
|
|
303
|
+
y = e, p = u.update().measure().contentBox.height;
|
|
305
304
|
break;
|
|
306
305
|
case "horizontal-tb":
|
|
307
306
|
default:
|
|
308
|
-
|
|
307
|
+
y = t, p = u.update().measure().contentBox.width;
|
|
309
308
|
break;
|
|
310
309
|
}
|
|
311
|
-
if (
|
|
312
|
-
let
|
|
313
|
-
!D && !
|
|
314
|
-
const
|
|
315
|
-
(
|
|
316
|
-
|
|
317
|
-
(
|
|
310
|
+
if (p += d.letterSpacing, x.isEOL || y && D + p > y) {
|
|
311
|
+
let s = x.isEOL ? a.length + 1 : a.length;
|
|
312
|
+
!D && !s && (a += u.computedContent, s += u.computedContent.length), a.length && g.push(i.clone(a)), g.length && (n.push(r.clone(g.slice())), g.length = 0);
|
|
313
|
+
const l = i.computedContent.substring(s);
|
|
314
|
+
(l.length || E.length) && o.unshift(
|
|
315
|
+
r.clone(
|
|
316
|
+
(l.length ? [i.clone(l)] : []).concat(E.slice())
|
|
318
317
|
)
|
|
319
|
-
),
|
|
318
|
+
), E.length = 0, S = !0;
|
|
320
319
|
break;
|
|
321
320
|
} else
|
|
322
|
-
D +=
|
|
321
|
+
D += p;
|
|
323
322
|
a += u.computedContent, u.content = "";
|
|
324
323
|
}
|
|
325
324
|
S || g.push(i.clone());
|
|
326
325
|
}
|
|
327
|
-
g.length && n.push(
|
|
326
|
+
g.length && n.push(r.clone(g));
|
|
328
327
|
}
|
|
329
328
|
return n;
|
|
330
329
|
}
|
|
@@ -354,64 +353,64 @@ const j = {
|
|
|
354
353
|
writingMode: "horizontal-tb",
|
|
355
354
|
textOrientation: "mixed"
|
|
356
355
|
};
|
|
357
|
-
function V(
|
|
356
|
+
function V(h) {
|
|
358
357
|
return {
|
|
359
358
|
...j,
|
|
360
|
-
...
|
|
359
|
+
...h
|
|
361
360
|
};
|
|
362
361
|
}
|
|
363
|
-
function q(
|
|
364
|
-
const { content: t, effects: e = [{}] } =
|
|
365
|
-
let i = _(t,
|
|
362
|
+
function q(h) {
|
|
363
|
+
const { content: t, effects: e = [{}] } = h, { width: n, height: o, ...r } = V(h.style);
|
|
364
|
+
let i = _(t, r);
|
|
366
365
|
i = G(i, n, o);
|
|
367
|
-
let B = 0,
|
|
366
|
+
let B = 0, E = 0;
|
|
368
367
|
i.forEach((u) => {
|
|
369
|
-
let
|
|
370
|
-
u.fragments.forEach((
|
|
371
|
-
|
|
368
|
+
let x = null;
|
|
369
|
+
u.fragments.forEach((F) => {
|
|
370
|
+
F.update().measure(), (!x || x.contentBox.height < F.contentBox.height) && (x = F);
|
|
372
371
|
});
|
|
373
372
|
const {
|
|
374
|
-
glyphHeight:
|
|
373
|
+
glyphHeight: y,
|
|
375
374
|
baseline: p
|
|
376
|
-
} = $("x", (
|
|
377
|
-
u.xHeight =
|
|
378
|
-
const
|
|
379
|
-
let l = B,
|
|
380
|
-
u.fragments.forEach((
|
|
381
|
-
const
|
|
382
|
-
switch (
|
|
375
|
+
} = $("x", (x ?? u).computedStyle);
|
|
376
|
+
u.xHeight = y, u.baseline = p;
|
|
377
|
+
const s = u.computedStyle;
|
|
378
|
+
let l = B, c = E, m = 0;
|
|
379
|
+
u.fragments.forEach((F, f) => {
|
|
380
|
+
const C = F.computedStyle;
|
|
381
|
+
switch (s.writingMode) {
|
|
383
382
|
case "vertical-rl":
|
|
384
383
|
case "vertical-lr": {
|
|
385
|
-
f || (
|
|
386
|
-
let w =
|
|
387
|
-
|
|
384
|
+
f || (c = 0), F.inlineBox.translate(l, c), F.contentBox.translate(l, c), F.glyphBox.translate(l, c);
|
|
385
|
+
let w = c;
|
|
386
|
+
F.characters.forEach((b, O) => {
|
|
388
387
|
const z = b.contentBox.y + b.contentBox.height;
|
|
389
|
-
b.contentBox.translate(l, w), b.glyphBox.translate(l, w), w += z, O !==
|
|
390
|
-
}),
|
|
388
|
+
b.contentBox.translate(l, w), b.glyphBox.translate(l, w), w += z, O !== F.characters.length - 1 && (w += C.letterSpacing);
|
|
389
|
+
}), c += F.inlineBox.height, f === u.fragments.length - 1 && (l += F.inlineBox.width);
|
|
391
390
|
break;
|
|
392
391
|
}
|
|
393
392
|
case "horizontal-tb": {
|
|
394
|
-
f || (l = 0),
|
|
393
|
+
f || (l = 0), F.inlineBox.translate(l, c), F.contentBox.translate(l, c), F.glyphBox.translate(l, c);
|
|
395
394
|
let w = l;
|
|
396
|
-
|
|
395
|
+
F.characters.forEach((b, O) => {
|
|
397
396
|
const z = b.contentBox.x + b.contentBox.width;
|
|
398
|
-
b.contentBox.translate(w,
|
|
399
|
-
}), l +=
|
|
397
|
+
b.contentBox.translate(w, c), b.glyphBox.translate(w, c), w += z, O !== F.characters.length - 1 && (w += C.letterSpacing);
|
|
398
|
+
}), l += F.inlineBox.width, m = Math.max(m, F.inlineBox.height), f === u.fragments.length - 1 && (c += m);
|
|
400
399
|
break;
|
|
401
400
|
}
|
|
402
401
|
}
|
|
403
|
-
}), B = l,
|
|
402
|
+
}), B = l, E = c, u.lineBox = A.from(...u.fragments.map((F) => F.inlineBox));
|
|
404
403
|
});
|
|
405
|
-
const D =
|
|
404
|
+
const D = A.from(
|
|
406
405
|
...i.map((u) => u.lineBox),
|
|
407
|
-
new
|
|
406
|
+
new A(0, 0, n, o)
|
|
408
407
|
), { width: g, height: d } = D;
|
|
409
408
|
i.forEach((u) => {
|
|
410
|
-
let
|
|
411
|
-
const
|
|
409
|
+
let x = 0;
|
|
410
|
+
const y = 0, p = u.computedStyle;
|
|
412
411
|
switch (p.writingMode) {
|
|
413
412
|
case "vertical-rl":
|
|
414
|
-
|
|
413
|
+
x += g - (u.lineBox.x * 2 + u.lineBox.width);
|
|
415
414
|
case "vertical-lr":
|
|
416
415
|
u.lineBox.height = Math.max(u.lineBox.height, d);
|
|
417
416
|
break;
|
|
@@ -419,24 +418,24 @@ function q(r) {
|
|
|
419
418
|
u.lineBox.width = Math.max(u.lineBox.width, g);
|
|
420
419
|
break;
|
|
421
420
|
}
|
|
422
|
-
u.contentBox =
|
|
423
|
-
let l =
|
|
424
|
-
const m =
|
|
421
|
+
u.contentBox = A.from(...u.fragments.map((s) => s.contentBox)), u.glyphBox = A.from(...u.fragments.map((s) => s.glyphBox)), u.fragments.forEach((s) => {
|
|
422
|
+
let l = x, c = y;
|
|
423
|
+
const m = s.computedStyle;
|
|
425
424
|
switch (p.writingMode) {
|
|
426
425
|
case "vertical-rl":
|
|
427
426
|
case "vertical-lr": {
|
|
428
427
|
switch (m.textAlign) {
|
|
429
428
|
case "end":
|
|
430
429
|
case "right":
|
|
431
|
-
|
|
430
|
+
c += d - u.contentBox.height;
|
|
432
431
|
break;
|
|
433
432
|
case "center":
|
|
434
|
-
|
|
433
|
+
c += (d - u.contentBox.height) / 2;
|
|
435
434
|
break;
|
|
436
435
|
}
|
|
437
|
-
|
|
436
|
+
s.characters.forEach((F) => {
|
|
438
437
|
let f = l;
|
|
439
|
-
const
|
|
438
|
+
const C = c;
|
|
440
439
|
switch (m.verticalAlign) {
|
|
441
440
|
case "top":
|
|
442
441
|
case "middle":
|
|
@@ -447,10 +446,10 @@ function q(r) {
|
|
|
447
446
|
case "text-bottom":
|
|
448
447
|
case "baseline":
|
|
449
448
|
default:
|
|
450
|
-
f += u.baseline -
|
|
449
|
+
f += u.baseline - F.baseline;
|
|
451
450
|
break;
|
|
452
451
|
}
|
|
453
|
-
|
|
452
|
+
F.contentBox.translate(f, C), F.glyphBox.translate(f, C);
|
|
454
453
|
});
|
|
455
454
|
break;
|
|
456
455
|
}
|
|
@@ -466,51 +465,52 @@ function q(r) {
|
|
|
466
465
|
}
|
|
467
466
|
switch (m.verticalAlign) {
|
|
468
467
|
case "top":
|
|
469
|
-
|
|
468
|
+
c = u.lineBox.y - s.inlineBox.y;
|
|
470
469
|
break;
|
|
471
470
|
case "middle":
|
|
472
|
-
|
|
471
|
+
c = s.inlineBox.y - (u.baseline - u.xHeight / 2 - s.inlineBox.height / 2);
|
|
473
472
|
break;
|
|
474
473
|
case "bottom":
|
|
475
|
-
|
|
474
|
+
c = u.lineBox.bottom - s.inlineBox.bottom;
|
|
476
475
|
break;
|
|
477
476
|
case "sub":
|
|
478
|
-
|
|
477
|
+
c = u.lineBox.y + u.baseline - s.glyphBox.bottom;
|
|
479
478
|
break;
|
|
480
479
|
case "super":
|
|
481
|
-
|
|
480
|
+
c = u.lineBox.y + u.baseline - s.glyphBox.y;
|
|
482
481
|
break;
|
|
483
482
|
case "text-top":
|
|
484
|
-
|
|
483
|
+
c = u.glyphBox.y - s.inlineBox.y;
|
|
485
484
|
break;
|
|
486
485
|
case "text-bottom":
|
|
487
|
-
|
|
486
|
+
c = u.glyphBox.bottom - s.inlineBox.bottom;
|
|
488
487
|
break;
|
|
489
488
|
case "baseline":
|
|
490
489
|
default:
|
|
491
|
-
|
|
490
|
+
s.inlineBox.height < u.lineBox.height && (c = u.baseline - s.baseline);
|
|
492
491
|
break;
|
|
493
492
|
}
|
|
493
|
+
s.characters.forEach((F) => {
|
|
494
|
+
F.contentBox.translate(l, c), F.glyphBox.translate(l, c);
|
|
495
|
+
});
|
|
494
496
|
break;
|
|
495
497
|
}
|
|
496
498
|
}
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
}), F.inlineBox.translate(l, h), F.contentBox.translate(l, h), F.glyphBox.translate(l, h);
|
|
500
|
-
}), u.lineBox = x.from(u.lineBox, ...u.fragments.map((F) => F.inlineBox)), u.contentBox = x.from(...u.fragments.map((F) => F.contentBox)), u.glyphBox = x.from(...u.fragments.map((F) => F.glyphBox));
|
|
499
|
+
s.inlineBox.translate(l, c), s.contentBox.translate(l, c), s.glyphBox.translate(l, c);
|
|
500
|
+
}), u.lineBox = A.from(u.lineBox, ...u.fragments.map((s) => s.inlineBox)), u.contentBox = A.from(...u.fragments.map((s) => s.contentBox)), u.glyphBox = A.from(...u.fragments.map((s) => s.glyphBox));
|
|
501
501
|
});
|
|
502
|
-
const a =
|
|
502
|
+
const a = A.from(...i.map((u) => u.contentBox)), S = A.from(...i.map((u) => u.glyphBox)), k = [];
|
|
503
503
|
return i.forEach((u) => {
|
|
504
|
-
u.fragments.forEach((
|
|
505
|
-
const
|
|
504
|
+
u.fragments.forEach((x) => {
|
|
505
|
+
const y = x.computedStyle;
|
|
506
506
|
e.forEach((p) => {
|
|
507
|
-
const
|
|
508
|
-
if (l ||
|
|
509
|
-
const { x:
|
|
510
|
-
k.push(new
|
|
511
|
-
Math.min(
|
|
507
|
+
const s = { ...y, ...p }, { textStrokeWidth: l = 0, offsetX: c = 0, offsetY: m = 0 } = s;
|
|
508
|
+
if (l || c || m) {
|
|
509
|
+
const { x: F, y: f, width: C, height: w } = x.contentBox;
|
|
510
|
+
k.push(new A(
|
|
511
|
+
Math.min(F, F + c - l / 2),
|
|
512
512
|
Math.min(f, f + m - l / 2),
|
|
513
|
-
Math.max(
|
|
513
|
+
Math.max(C, C + c + l),
|
|
514
514
|
Math.max(w, w + m + l)
|
|
515
515
|
));
|
|
516
516
|
}
|
|
@@ -521,25 +521,25 @@ function q(r) {
|
|
|
521
521
|
contentBox: a,
|
|
522
522
|
glyphBox: S,
|
|
523
523
|
paragraphs: i,
|
|
524
|
-
viewBox:
|
|
524
|
+
viewBox: A.from(D, S, ...k)
|
|
525
525
|
};
|
|
526
526
|
}
|
|
527
|
-
function H(
|
|
527
|
+
function H(h, t, e) {
|
|
528
528
|
if (typeof t == "string" && t.startsWith("linear-gradient")) {
|
|
529
|
-
const { x0: n, y0: o, x1:
|
|
530
|
-
return B.forEach((D) =>
|
|
529
|
+
const { x0: n, y0: o, x1: r, y1: i, stops: B } = J(t, e.left, e.top, e.width, e.height), E = h.createLinearGradient(n, o, r, i);
|
|
530
|
+
return B.forEach((D) => E.addColorStop(D.offset, D.color)), E;
|
|
531
531
|
}
|
|
532
532
|
return t;
|
|
533
533
|
}
|
|
534
|
-
function J(
|
|
534
|
+
function J(h, t, e, n, o) {
|
|
535
535
|
var S;
|
|
536
|
-
const
|
|
536
|
+
const r = ((S = h.match(/linear-gradient\((.+)\)$/)) == null ? void 0 : S[1]) ?? "", i = r.split(",")[0], B = i.includes("deg") ? i : "0deg", E = r.replace(B, "").matchAll(/(#|rgba|rgb)(.+?) ([\d.]+?%)/gi), g = (Number(B.replace("deg", "")) || 0) * Math.PI / 180, d = n * Math.sin(g), a = o * Math.cos(g);
|
|
537
537
|
return {
|
|
538
538
|
x0: t + n / 2 - d,
|
|
539
539
|
y0: e + o / 2 + a,
|
|
540
540
|
x1: t + n / 2 + d,
|
|
541
541
|
y1: e + o / 2 - a,
|
|
542
|
-
stops: Array.from(
|
|
542
|
+
stops: Array.from(E).map((k) => {
|
|
543
543
|
let u = k[2];
|
|
544
544
|
return u.startsWith("(") ? u = u.split(",").length > 3 ? `rgba${u}` : `rgb${u}` : u = `#${u}`, {
|
|
545
545
|
offset: Number(k[3].replace("%", "")) / 100,
|
|
@@ -548,72 +548,72 @@ function J(r, t, e, n, o) {
|
|
|
548
548
|
})
|
|
549
549
|
};
|
|
550
550
|
}
|
|
551
|
-
function M(
|
|
552
|
-
e != null && e.color && (e.color = H(
|
|
551
|
+
function M(h, t, e) {
|
|
552
|
+
e != null && e.color && (e.color = H(h, e.color, t)), e != null && e.backgroundColor && (e.backgroundColor = H(h, e.backgroundColor, t)), e != null && e.textStrokeColor && (e.textStrokeColor = H(h, e.textStrokeColor, t));
|
|
553
553
|
}
|
|
554
|
-
function Q(
|
|
554
|
+
function Q(h) {
|
|
555
555
|
const {
|
|
556
556
|
view: t = document.createElement("canvas"),
|
|
557
557
|
style: e,
|
|
558
558
|
effects: n = [],
|
|
559
559
|
pixelRatio: o = 1
|
|
560
|
-
} =
|
|
561
|
-
t.style.width = `${g}px`, t.style.height = `${d}px`, t.dataset.viewbox = `${
|
|
562
|
-
const S = (u,
|
|
563
|
-
a.fillStyle = u, a.fillRect(-i.x +
|
|
560
|
+
} = h, r = n.length > 0 ? n : [{}], { viewBox: i, paragraphs: B } = q(h), { x: E, y: D, width: g, height: d } = i, a = t.getContext("2d");
|
|
561
|
+
t.style.width = `${g}px`, t.style.height = `${d}px`, t.dataset.viewbox = `${E} ${D} ${g} ${d}`, t.dataset.pixelRatio = String(o), t.width = Math.max(1, Math.floor(g * o)), t.height = Math.max(1, Math.floor(d * o)), a.scale(o, o), a.clearRect(0, 0, t.width, t.height);
|
|
562
|
+
const S = (u, x, y, p, s) => {
|
|
563
|
+
a.fillStyle = u, a.fillRect(-i.x + x, -i.y + y, p, s);
|
|
564
564
|
}, k = { ...e };
|
|
565
|
-
return M(a, new
|
|
566
|
-
M(a, u.contentBox, u.computedStyle), u.fragments.forEach((
|
|
567
|
-
M(a,
|
|
565
|
+
return M(a, new A(0, 0, g, d), k), B.forEach((u) => {
|
|
566
|
+
M(a, u.contentBox, u.computedStyle), u.fragments.forEach((x) => {
|
|
567
|
+
M(a, x.contentBox, x.computedStyle);
|
|
568
568
|
});
|
|
569
|
-
}),
|
|
570
|
-
const
|
|
571
|
-
M(a, new
|
|
572
|
-
const
|
|
573
|
-
|
|
574
|
-
var
|
|
575
|
-
(
|
|
576
|
-
var
|
|
577
|
-
(
|
|
569
|
+
}), r.forEach((u) => {
|
|
570
|
+
const x = { ...u };
|
|
571
|
+
M(a, new A(0, 0, g, d), x);
|
|
572
|
+
const y = { ...k, ...x };
|
|
573
|
+
y != null && y.backgroundColor && S(y.backgroundColor, 0, 0, t.width, t.height), B.forEach((p) => {
|
|
574
|
+
var s;
|
|
575
|
+
(s = p.style) != null && s.backgroundColor && S(p.computedStyle.backgroundColor, ...p.lineBox.toArray()), p.fragments.forEach((l) => {
|
|
576
|
+
var c;
|
|
577
|
+
(c = l.style) != null && c.backgroundColor && S(l.computedStyle.backgroundColor, ...l.inlineBox.toArray());
|
|
578
578
|
});
|
|
579
579
|
}), B.forEach((p) => {
|
|
580
|
-
p.fragments.forEach((
|
|
581
|
-
const l = -i.x + (
|
|
580
|
+
p.fragments.forEach((s) => {
|
|
581
|
+
const l = -i.x + (x.offsetX ?? 0), c = -i.y + (x.offsetY ?? 0), m = { ...s.computedStyle, ...x };
|
|
582
582
|
switch (P(a, {
|
|
583
583
|
...m,
|
|
584
584
|
textAlign: "left"
|
|
585
585
|
}), m.writingMode) {
|
|
586
586
|
case "vertical-rl":
|
|
587
587
|
case "vertical-lr": {
|
|
588
|
-
|
|
589
|
-
let f = 0,
|
|
590
|
-
switch (
|
|
588
|
+
s.characters.forEach((F) => {
|
|
589
|
+
let f = 0, C = 0;
|
|
590
|
+
switch (F.verticalOrientation) {
|
|
591
591
|
case "Tr":
|
|
592
592
|
case "R": {
|
|
593
|
-
a.rotate(Math.PI / 2), a.textBaseline = "alphabetic",
|
|
593
|
+
a.rotate(Math.PI / 2), a.textBaseline = "alphabetic", C = -(l + s.inlineBox.x + s.inlineBox.width - F.baseline), f = c + F.contentBox.y;
|
|
594
594
|
break;
|
|
595
595
|
}
|
|
596
596
|
case "Tu":
|
|
597
|
-
a.textBaseline = "top", f = l +
|
|
597
|
+
a.textBaseline = "top", f = l + F.contentBox.x + F.contentBox.right - F.glyphBox.right, C = c + F.contentBox.y + F.contentBox.y - F.glyphBox.y;
|
|
598
598
|
break;
|
|
599
599
|
case "U":
|
|
600
|
-
f = l +
|
|
600
|
+
f = l + F.contentBox.x, C = c + F.contentBox.y, a.textBaseline = "top";
|
|
601
601
|
break;
|
|
602
602
|
}
|
|
603
|
-
a.fillText(
|
|
603
|
+
a.fillText(F.content, f, C), m.textStrokeWidth && a.strokeText(F.content, f, C), a.setTransform(1, 0, 0, 1, 0, 0), a.scale(o, o);
|
|
604
604
|
});
|
|
605
605
|
break;
|
|
606
606
|
}
|
|
607
607
|
case "horizontal-tb": {
|
|
608
|
-
const
|
|
609
|
-
a.textBaseline = "alphabetic", a.fillText(
|
|
610
|
-
const { width: w, height: b } =
|
|
608
|
+
const F = l + s.contentBox.x, f = c + s.contentBox.y, C = c + s.inlineBox.y + s.baseline;
|
|
609
|
+
a.textBaseline = "alphabetic", a.fillText(s.computedContent, F, C), m.textStrokeWidth && a.strokeText(s.computedContent, F, C);
|
|
610
|
+
const { width: w, height: b } = s.contentBox;
|
|
611
611
|
switch (m.textDecoration) {
|
|
612
612
|
case "underline":
|
|
613
|
-
a.strokeStyle = a.fillStyle, a.lineWidth = m.fontSize / 15, a.beginPath(), a.moveTo(
|
|
613
|
+
a.strokeStyle = a.fillStyle, a.lineWidth = m.fontSize / 15, a.beginPath(), a.moveTo(F, f + b), a.lineTo(F + w, f + b), a.stroke();
|
|
614
614
|
break;
|
|
615
615
|
case "line-through":
|
|
616
|
-
a.strokeStyle = a.fillStyle, a.lineWidth = m.fontSize / 15, a.beginPath(), a.moveTo(
|
|
616
|
+
a.strokeStyle = a.fillStyle, a.lineWidth = m.fontSize / 15, a.beginPath(), a.moveTo(F, f + b / 2), a.lineTo(F + w, f + b / 2), a.stroke();
|
|
617
617
|
break;
|
|
618
618
|
}
|
|
619
619
|
break;
|