Files
il/resources/public/js/cljs-runtime/module$node_modules$pixi_DOT_js$lib$scene$text_html$utils$measureHtmlText.js
2026-07-01 22:38:29 -06:00

27 lines
1.4 KiB
JavaScript

shadow$provide.module$node_modules$pixi_DOT_js$lib$scene$text_html$utils$measureHtmlText = function(global, require, module, exports) {
var HTMLTextRenderData = require("module$node_modules$pixi_DOT_js$lib$scene$text_html$HTMLTextRenderData");
"use strict";
let tempHTMLTextRenderData;
exports.measureHtmlText = function(text, style, fontStyleCSS, htmlTextRenderData) {
htmlTextRenderData || (htmlTextRenderData = tempHTMLTextRenderData || (tempHTMLTextRenderData = new HTMLTextRenderData.HTMLTextRenderData()));
const {domElement, styleElement, svgRoot} = htmlTextRenderData;
domElement.innerHTML = `<style>${style.cssStyle};</style><div style='padding:0'>${text}</div>`;
domElement.setAttribute("style", "transform-origin: top left; display: inline-block");
fontStyleCSS && (styleElement.textContent = fontStyleCSS);
document.body.appendChild(svgRoot);
text = domElement.scrollWidth;
fontStyleCSS = domElement.scrollHeight;
svgRoot.remove();
if (style.dropShadow) {
const {distance, angle, blur} = style.dropShadow;
htmlTextRenderData = Math.abs(Math.round(Math.sin(angle) * distance));
text += Math.abs(Math.round(Math.cos(angle) * distance)) + blur;
fontStyleCSS += htmlTextRenderData + blur;
}
style = 2 * style.padding;
return {width:text - style, height:fontStyleCSS - style};
};
};
//# sourceMappingURL=module$node_modules$pixi_DOT_js$lib$scene$text_html$utils$measureHtmlText.js.map