1 line
4.0 KiB
Plaintext
1 line
4.0 KiB
Plaintext
{"version":3,"file":"HTMLText.mjs","sources":["../../../src/scene/text-html/HTMLText.ts"],"sourcesContent":["import { AbstractText, ensureOptions } from '../text/AbstractText';\nimport { HTMLTextStyle } from './HtmlTextStyle';\nimport { measureHtmlText } from './utils/measureHtmlText';\n\nimport type { View } from '../../rendering/renderers/shared/view/View';\nimport type { TextOptions, TextString } from '../text/AbstractText';\nimport type { HTMLTextStyleOptions } from './HtmlTextStyle';\n\n/**\n * Constructor options used for `HTMLText` instances.\n * @property {string} [text=''] - The string that you would like the text to display.\n * @property {text.HTMLTextStyle | text.HTMLTextStyleOptions} [style] - The style of the text.\n * @memberof text\n */\nexport type HTMLTextOptions = TextOptions<HTMLTextStyle, HTMLTextStyleOptions>;\n\n/**\n * A HTMLText Object will create a line or multiple lines of text.\n *\n * To split a line you can use '\\n' in your text string, or, on the `style` object,\n * change its `wordWrap` property to true and and give the `wordWrapWidth` property a value.\n *\n * HTMLText uses an svg foreignObject to render HTML text.\n *\n *\n * The primary advantages of this render mode are:\n *\n * - Supports [HTML tags](https://developer.mozilla.org/en-US/docs/Learn/HTML/Introduction_to_HTML/HTML_text_fundamentals)\n * for styling such as `<strong>`, or `<em>`, as well as `<span style=\"\">`\n *\n * - Better support for emojis and other HTML layout features, better compatibility with CSS\n * line-height and letter-spacing.\n *\n *\n * The primary disadvantages are:\n * - Unlike `text`, `html` rendering will vary slightly between platforms and browsers.\n * `html` uses SVG/DOM to render text and not Context2D's fillText like `text`.\n *\n * - Performance and memory usage is on-par with `text` (that is to say, slow and heavy)\n *\n * - Only works with browsers that support <foreignObject>.\n * @example\n * import { HTMLText } from 'pixi.js';\n *\n * const text = new HTMLText({\n * text: 'Hello Pixi!',\n * style: {\n * fontFamily: 'Arial',\n * fontSize: 24,\n * fill: 0xff1010,\n * align: 'center',\n * }\n * });\n * @memberof scene\n */\nexport class HTMLText extends AbstractText<HTMLTextStyle, HTMLTextStyleOptions> implements View\n{\n public readonly renderPipeId: string = 'htmlText';\n\n /**\n * @param {text.HTMLTextOptions} options - The options of the html text.\n */\n constructor(options?: HTMLTextOptions);\n /** @deprecated since 8.0.0 */\n constructor(text?: TextString, options?: Partial<HTMLTextStyle>);\n constructor(...args: [HTMLTextOptions?] | [TextString, Partial<HTMLTextStyle>])\n {\n const options = ensureOptions<HTMLTextStyle, HTMLTextStyleOptions>(args, 'HtmlText');\n\n super(options, HTMLTextStyle);\n }\n\n protected _updateBounds()\n {\n const bounds = this._bounds;\n const anchor = this._anchor;\n\n const htmlMeasurement = measureHtmlText(this.text, this._style as HTMLTextStyle);\n\n const { width, height } = htmlMeasurement;\n\n bounds.minX = (-anchor._x * width);\n bounds.maxX = bounds.minX + width;\n bounds.minY = (-anchor._y * height);\n bounds.maxY = bounds.minY + height;\n }\n}\n"],"names":[],"mappings":";;;;;AAuDO,MAAM,iBAAiB,YAC9B,CAAA;AAAA,EASI,eAAe,IACf,EAAA;AACI,IAAM,MAAA,OAAA,GAAU,aAAmD,CAAA,IAAA,EAAM,UAAU,CAAA,CAAA;AAEnF,IAAA,KAAA,CAAM,SAAS,aAAa,CAAA,CAAA;AAZhC,IAAA,IAAA,CAAgB,YAAuB,GAAA,UAAA,CAAA;AAAA,GAavC;AAAA,EAEU,aACV,GAAA;AACI,IAAA,MAAM,SAAS,IAAK,CAAA,OAAA,CAAA;AACpB,IAAA,MAAM,SAAS,IAAK,CAAA,OAAA,CAAA;AAEpB,IAAA,MAAM,eAAkB,GAAA,eAAA,CAAgB,IAAK,CAAA,IAAA,EAAM,KAAK,MAAuB,CAAA,CAAA;AAE/E,IAAM,MAAA,EAAE,KAAO,EAAA,MAAA,EAAW,GAAA,eAAA,CAAA;AAE1B,IAAO,MAAA,CAAA,IAAA,GAAQ,CAAC,MAAA,CAAO,EAAK,GAAA,KAAA,CAAA;AAC5B,IAAO,MAAA,CAAA,IAAA,GAAO,OAAO,IAAO,GAAA,KAAA,CAAA;AAC5B,IAAO,MAAA,CAAA,IAAA,GAAQ,CAAC,MAAA,CAAO,EAAK,GAAA,MAAA,CAAA;AAC5B,IAAO,MAAA,CAAA,IAAA,GAAO,OAAO,IAAO,GAAA,MAAA,CAAA;AAAA,GAChC;AACJ;;;;"} |