/
githubmirror
/
pixijs
Обзор
Документация
Войти
/
githubmirror
/
pixijs
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
dev
src/scene/text-html/utils/getSVGUrl.ts
34 строки
1 KB
Zyie
chore: documentation overhaul with typedoc (#11423)
19 май 2025, 11:44
Не верифицирован
19 май 2025, 11:44
34926f0
Код
Авторство
О чём код?
import type { HTMLTextRenderData } from '../HTMLTextRenderData'; import type { HTMLTextStyle } from '../HTMLTextStyle'; /** * takes all the data and returns a svg url string can be loaded by an image element * @param text - The text to measure * @param style - The style to use * @param resolution - The resolution to use * @param fontCSS - The font css to use * @param htmlTextData - The HTMLTextRenderData to write the SVG to * @returns - The SVG as a url string * @internal */ export function getSVGUrl( text: string, style: HTMLTextStyle, resolution: number, fontCSS: string, htmlTextData: HTMLTextRenderData ) { const { domElement, styleElement, svgRoot } = htmlTextData; domElement.innerHTML = `<style>${style.cssStyle}</style><div style='padding:0;'>${text}</div>`; domElement.setAttribute('style', `transform: scale(${resolution});transform-origin: top left; display: inline-block`); styleElement.textContent = fontCSS; const { width, height } = htmlTextData.image; svgRoot.setAttribute('width', width.toString()); svgRoot.setAttribute('height', height.toString()); return new XMLSerializer().serializeToString(svgRoot); }