1 line
36 KiB
Plaintext
1 line
36 KiB
Plaintext
|
|
{"version":3,"file":"Text.mjs","sources":["../src/Text.ts"],"sourcesContent":["/* eslint max-depth: [2, 8] */\nimport { Color, Rectangle, settings, Texture, utils } from '@pixi/core';\nimport { Sprite } from '@pixi/sprite';\nimport { TEXT_GRADIENT } from './const';\nimport { TextMetrics } from './TextMetrics';\nimport { TextStyle } from './TextStyle';\n\nimport type { ICanvas, ICanvasRenderingContext2D, Renderer } from '@pixi/core';\nimport type { IDestroyOptions } from '@pixi/display';\nimport type { ITextStyle } from './TextStyle';\n\nconst defaultDestroyOptions: IDestroyOptions = {\n texture: true,\n children: false,\n baseTexture: true,\n};\n\n/**\n * A Text Object will create a line or multiple lines of text.\n *\n * The text is created using the [Canvas API](https://developer.mozilla.org/en-US/docs/Web/API/Canvas_API).\n *\n * The primary advantage of this class over BitmapText is that you have great control over the style of the text,\n * which you can change at runtime.\n *\n * The primary disadvantages is that each piece of text has it's own texture, which can use more memory.\n * When text changes, this texture has to be re-generated and re-uploaded to the GPU, taking up time.\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 * A Text can be created directly from a string and a style object,\n * which can be generated [here](https://pixijs.io/pixi-text-style).\n * @example\n * import { Text } from 'pixi.js';\n *\n * const text = new Text('This is a PixiJS text', {\n * fontFamily: 'Arial',\n * fontSize: 24,\n * fill: 0xff1010,\n * align: 'center',\n * });\n * @memberof PIXI\n */\nexport class Text extends Sprite\n{\n /**\n * Override whether or not the resolution of the text is automatically adjusted to match the resolution of the renderer.\n * Setting this to false can allow you to get crisper text at lower render resolutions.\n * @example\n * // renderer has a resolution of 1\n * const app = new Application();\n *\n * Text.defaultResolution = 2;\n * Text.defaultAutoResolution = false;\n * // text has a resolution of 2\n * const text = new Text('This is a PixiJS text');\n */\n public static defaultAutoResolution = true;\n\n /**\n * If {@link PIXI.Text.defaultAutoResolution} is false, this will be the default resolution of the text.\n * If not set it will default to {@link PIXI.settings.RESOLUTION}.\n * @example\n * Text.defaultResolution = 2;\n * Text.defaultAutoResolution = false;\n *\n * // text has a resolution of 2\n * const text = new Text('This is a PixiJS text');\n */\n public static defaultResolution: number;\n\n /**\n * @see PIXI.TextMetrics.experimentalLetterSpacing\n * @deprecated since 7.1.0\n */\n public static get experimentalLetterSpacing()\n {\n return TextMetrics.experimentalLetterSpacing;\n }\n public static set experimentalLetterSpacing(value)\n {\n if (process.env.DEBUG)\n {\n utils.deprecation('7.1.0',\n 'Text.experimentalLetterSpacing is deprecated, use TextMetrics.experimentalLetterSpacing');\n }\n\n TextMetrics.experimentalLetterSpacing = value;\n }\n\n /** The canvas element that everything is drawn to. */\n public canvas: ICanvas;\n /** The canvas 2d context that everything is drawn with. */\n public context: ICanvasRenderingContext2D;\n public localStyleID: number;\n public dirty: boolean;\n\n /**\n * The resolution / device pixel ratio of the canvas.\n *\n * This is set to automatically match the renderer resolution by default, but can be overridden by setting manually.\n * @default PIXI.settings.RESOLUTION\n */\n _resolution: number;\n _autoResolution: boolean;\n\n /**\n * Private tracker for the current text.\n * @private\n */\n protected _text: string;\n\n /**\n *
|