UNPKG

@arcgis/core

Version:

ArcGIS Maps SDK for JavaScript: A complete 2D and 3D mapping and data visualization API

6 lines (5 loc) 1.09 kB
/* All material copyright ESRI, All Rights Reserved, unless otherwise specified. See https://js.arcgis.com/4.33/esri/copyright.txt for details. */ import{pt2px as e}from"../../../core/screenUtils.js";import{glyphSize as t,magicLabelLineHeight as n}from"../engine/webgl/definitions.js";import{shapeGlyphs as i}from"../engine/webgl/mesh/templates/shapingUtils.js";async function o(o,r,a){const s={type:"cim-rasterization-info",resource:{type:"text",textString:o.text,font:o.font}},f=r.textureManager.rasterizeItem(s,a),l=await f;return i(l,{angle:o.angle??0,xOffset:e(o.xoffset??0),yOffset:e(o.yoffset??0),lineHeight:n*Math.max(.25,o.lineHeight),maxLineWidth:Math.max(32,Math.min(e(o.lineWidth),512)),decoration:o.font.decoration,scale:Math.min(Math.round(e(o.font.size)),127)/t,horizontalAlignment:"center",verticalAlignment:"middle",useCIMAngleBehavior:!1,hasBackground:!!o.backgroundColor,borderLineSizePx:e(o.borderLineSize)}).boundsT}let r=o;async function a(e,t,n){return r(e,t.stage,n)}const s={stubGetTextBounds:e=>r=e,restoreGetTextBounds:()=>r=o};export{a as getTextBounds,s as test};