1 line
21 KiB
Plaintext
1 line
21 KiB
Plaintext
|
|
{"version":3,"file":"HTMLTextStyle.mjs","sources":["../src/HTMLTextStyle.ts"],"sourcesContent":["import { settings, utils } from '@pixi/core';\nimport { TextStyle } from '@pixi/text';\n\nimport type {\n ITextStyle,\n TextStyleFontStyle,\n TextStyleFontWeight,\n TextStyleLineJoin,\n TextStyleTextBaseline\n} from '@pixi/text';\n\n/**\n * HTMLText support more white-space options.\n * @memberof PIXI\n * @since 7.2.0\n * @see PIXI.IHTMLTextStyle\n */\nexport type HTMLTextStyleWhiteSpace = 'normal' | 'pre' | 'pre-line' | 'nowrap' | 'pre-wrap';\n\n/**\n * FontFace display options.\n * @memberof PIXI\n * @since 7.3.0\n */\nexport type FontDisplay = 'auto' | 'block' | 'swap' | 'fallback' | 'optional';\n\n// Subset of ITextStyle\ntype ITextStyleIgnore = 'whiteSpace'\n| 'fillGradientStops'\n| 'fillGradientType'\n| 'miterLimit'\n| 'textBaseline'\n| 'trim'\n| 'leading'\n| 'lineJoin';\n\n/**\n * Modifed versions from ITextStyle.\n * @memberof PIXI\n * @extends PIXI.ITextStyle\n * @since 7.2.0\n */\nexport interface IHTMLTextStyle extends Omit<ITextStyle, ITextStyleIgnore>\n{\n /** White-space with expanded options. */\n whiteSpace: HTMLTextStyleWhiteSpace;\n}\n\nexport interface IHTMLTextFontOptions extends Pick<IHTMLFont, 'weight' | 'style' | 'family'>\n{\n /** font-display property */\n display: FontDisplay;\n}\n\n/**\n * Font information for HTMLText\n * @memberof PIXI\n * @since 7.2.0\n */\nexport interface IHTMLFont\n{\n /** User-supplied URL request */\n originalUrl: string;\n /** Base64 string for font */\n dataSrc: string;\n /** FontFace installed in the document */\n fontFace: FontFace | null;\n /** Blob-based URL for font */\n src: string;\n /** Family name of font */\n family: string;\n /** Weight of the font */\n weight: TextStyleFontWeight;\n /** Style of the font */\n style: TextStyleFontStyle;\n /** Display property of the font */\n display: FontDisplay;\n /** Reference counter */\n refs: number;\n}\n\n/**\n * Used internally to restrict text style usage and convert easily to CSS.\n * @class\n * @memberof PIXI\n * @param {PIXI.ITextStyle|PIXI.IHTMLTextStyle} [style] - Style to copy.\n * @since 7.2.0\n */\nexport class HTMLTextStyle extends TextStyle\n{\n /** The collection of installed fonts */\n public static availableFonts: Record<string, IHTMLFont> = {};\n\n /**\n * List of default options, these are largely the same as TextStyle,\n * with the exception of whiteSpace, which is set to 'normal' by default.\n */\n public static readonly defaultOptions: IHTMLTextStyle = {\n /** Align */\n align: 'left',\n /** Break words */\n breakWords: false,\n /** Drop shadow */\n dropShadow: false,\n /** Drop shadow alpha */\n dropShadowAlpha: 1,\n /**\n * Drop shadow angle\n * @type {number}\n * @default Math.PI / 6\n */\n dropShadowAngle: Math.PI / 6,\n /** Drop shadow blur */\n dropShadowBlur: 0,\n /** Drop shadow color */\n dropShadowColor: 'black',\n /** Drop shadow distance */\n dropShadowDistance: 5,\n /** Fill */\n fill: 'black',\n /** Font family */\n fontFamily: 'Arial',\n /** Font size */\n fontSize: 26,\n /** Font style */\n fontStyle: 'normal',\n /** Font variant */\n fontVariant: 'normal',\n /** Font weight */\n fontWeight: 'normal',\n /** Letter spacing */\n letterSpacing: 0,\n /** Line height */\n lineHeight: 0,\n /** Padding */\n padding: 0,\n /** Stroke */\n stroke: 'black',\n /** Stroke thickness */\n strokeThickness: 0,\n /** White space */\n whiteSpace: 'normal',\n /** Word wrap */\n wordWrap: false,\n /** Word wrap width */\n wordWrapWidth: 100,\n };\n\n /** For using custom fonts */\n private _fonts: IHTMLFont[] = [];\n\n /** List of internal style rules */\n
|