import { Rectangle } from '@pixi/math'; import { BitmapFont } from '../../utils'; import { AABB } from '../math'; import { DropShadow, Stroke } from '../renderable'; export type TextStyleWhiteSpace = 'normal' | 'pre' | 'pre-line'; /** * Draws a graphics element consisting of text. * @see https://developer.mozilla.org/en-US/docs/Web/SVG/Element/text */ export declare class Text { static getGeometryBounds(text: Partial, computed?: Partial): AABB; static getRenderBounds(text: Text, computed: ComputedTextMetrics, stroke?: Stroke, dropShadow?: DropShadow): AABB; /** * The x-axis coordinate of the point at which to begin drawing the text, in pixels. * @see https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/fillText#x */ anchorX: number; /** * The y-axis coordinate of the point at which to begin drawing the text, in pixels. * @see https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/fillText#y */ anchorY: number; /** * The text content. */ content: string; /** * Specifies a prioritized list of one or more font family names and/or generic family names for the selected element. * e.g. `'Arial, Helvetica, sans-serif'` * @see https://developer.mozilla.org/en-US/docs/Web/CSS/font-family */ fontFamily: string; /** * Sets the size of the font. * @see https://developer.mozilla.org/en-US/docs/Web/CSS/font-size */ fontSize: number | string; /** * Specifies the weight of the font. * @see https://developer.mozilla.org/en-US/docs/Web/CSS/font-weight */ fontWeight: number | string; /** * Sets whether a font should be styled with a normal, italic, or oblique face from its font-family. * @see https://developer.mozilla.org/en-US/docs/Web/CSS/font-style */ fontStyle: string; /** * Set all the font variants for a font. * @see https://developer.mozilla.org/en-US/docs/Web/CSS/font-variant */ fontVariant: string; /** * Specifies the spacing between letters when drawing text in px. * @see https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/letterSpacing */ letterSpacing: number; /** * Sets how white space inside an element is handled. * @see https://developer.mozilla.org/en-US/docs/Web/CSS/white-space */ whiteSpace: TextStyleWhiteSpace; /** * Text alignment used when drawing text. * @see https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/textAlign */ textAlign: CanvasTextAlign; /** * @see https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/textBaseline */ textBaseline: CanvasTextBaseline; /** * Sets the height of a line box in horizontal writing modes. In vertical writing modes, it sets the width of a line box. * @see https://developer.mozilla.org/en-US/docs/Web/CSS/line-height */ lineHeight: number; /** * Sets the distance between lines in px. */ leading: number; /** * MSDF * @see https://github.com/soimy/msdf-bmfont-xml * @see https://pixijs.com/8.x/examples/text/bitmap-text */ bitmapFont: BitmapFont; /** * Whether to use kerning in bitmap font. Default is `true`. */ bitmapFontKerning: boolean; /** * Whether to use esdt SDF generation. Default is `true`. */ esdt: boolean; /** * @see https://mattdesl.svbtle.com/material-design-on-the-gpu */ physical: boolean; /** * Whether to wrap the text. */ wordWrap: boolean; /** * The width of the text. */ wordWrapWidth: number; /** * @see https://developer.mozilla.org/en-US/docs/Web/CSS/text-overflow * @example * ```ts * new Text({ text: 'abcde...', textOverflow: TextOverflow.ELLIPSIS, wordWrapWidth: 100, maxLines: 3, }); */ textOverflow: 'ellipsis' | 'clip' | string; /** * CanvasKit ParagraphStyle * ```ts * export interface ParagraphStyle { ellipsis?: string; maxLines?: number; } * ``` */ maxLines: number; constructor(props?: Partial); } export declare class ComputedTextMetrics { /** * BiDi chars after doing metrics. */ bidiChars: string; /** * fontStyle + fontVariant + fontWeight + fontSize + fontFamily */ font: string; width: number; height: number; /** * Split text by new line. */ lines: string[]; /** * Width of each line. */ lineWidths: number[]; /** * Height of each line. */ lineHeight: number; /** * Max width of all lines. */ maxLineWidth: number; /** * FontSize. */ fontMetrics: globalThis.TextMetrics & { fontSize: number; }; /** * Detailed line metrics. */ lineMetrics: Rectangle[]; }