UNPKG

@doegis/core

Version:

DOE GIS API

3 lines (1 loc) 1.06 kB
import{bidiText as e}from"../../../core/BidiText.js";import{pt2px as t}from"../../../core/screenUtils.js";import{getXAnchorDirection as i,getYAnchorDirection as n}from"../engine/webgl/alignmentUtils.js";import{MAGIC_LABEL_LINE_HEIGHT as o,GLYPH_SIZE as r}from"../engine/webgl/definitions.js";import{shapeGlyphs as s}from"../engine/webgl/mesh/templates/shapingUtils.js";async function a(a,l,m){const d=i("center"),f=n("middle"),g=l.textureManager.rasterizeItem(a.toJSON(),window.devicePixelRatio||1,void 0,m),[,c]=e(a.text),h=(await g).glyphMosaicItems;return s(h??[],c,{angle:a.angle??0,xOffset:t(a.xoffset??0),yOffset:t(a.yoffset??0),lineHeight:o*Math.max(.25,a.lineHeight),maxLineWidth:Math.max(32,Math.min(t(a.lineWidth),512)),decoration:a.font.decoration,scale:Math.min(Math.round(t(a.font.size)),127)/r,hAlign:d,vAlign:f,isCIM:!1,hasBackground:!!a.backgroundColor,borderLineSize:a.borderLineSize}).boundsT}let l=a;async function m(e,t,i){return l(e,t,i)}const d={stubGetTextBounds:e=>l=e,restoreGetTextBounds:()=>l=a};export{m as getTextBounds,d as test};