UNPKG

playable.js

Version:

A lightweight HTML5 game engine.

82 lines (81 loc) 2.9 kB
import { Layer } from './Layer'; import { Rectangle } from '../geom/Rectangle'; export declare class Text extends Layer { static defaultFontSize: number; protected static readonly wordRe: RegExp; protected static readonly boundaryRe: RegExp; protected $text: string; protected $color: string; protected $fontSize: number; protected $fontStyle: FontStyle; protected $fontWeight: FontWeight; protected $textAlign: TextAlign; protected $verticalAlign: VerticalAlign; protected $lineHeight: number; protected $strokeSize: number; protected $strokeColor: string; protected $fontFamily: string; protected $multiline: boolean; protected $breakWord: boolean; protected $autoFitSize: boolean; protected $minFontSize: number; protected $explicitSize: number; protected $lines: Array<string>; constructor(text?: string, options?: TextOption); get text(): string; set text(text: string); get color(): string; set color(color: string); get fontSize(): number; set fontSize(fontSize: number); get fontStyle(): FontStyle; set fontStyle(fontStyle: FontStyle); get fontWeight(): FontWeight; set fontWeight(fontWeight: FontWeight); get textAlign(): TextAlign; set textAlign(textAlign: TextAlign); get verticalAlign(): VerticalAlign; set verticalAlign(verticalAlign: VerticalAlign); get lineHeight(): number; set lineHeight(lineHeight: number); get strokeSize(): number; set strokeSize(strokeSize: number); get strokeColor(): string; set strokeColor(strokeColor: string); get fontFamily(): string; set fontFamily(fontFamily: string); get multiline(): boolean; set multiline(multiline: boolean); get breakWord(): boolean; set breakWord(breakWord: boolean); get autoFitSize(): boolean; set autoFitSize(autoFitSize: boolean); get minFontSize(): number; set minFontSize(minFontSize: number); protected $updateContext(): void; protected $divideUnits(): Array<string>; protected $divideLines(): void; protected $resizeCanvas(): void; protected $getContentBounds(): Rectangle; protected $render(): number; } export type FontStyle = 'normal' | 'italic' | 'oblique'; export type FontWeight = 'normal' | 'bold' | 'bolder' | 'lighter' | 100 | 200 | 300 | 400 | 500 | 600 | 700 | 800 | 900; export type TextAlign = 'left' | 'right' | 'center'; export type VerticalAlign = 'top' | 'middle' | 'bottom'; export interface TextOption { color?: string; fontSize?: number; fontWeight?: FontWeight; fontStyle?: FontStyle; textAlign?: TextAlign; verticalAlign?: VerticalAlign; lineHeight?: number; strokeSize?: number; strokeColor?: string; fontFamily?: string; multiline?: boolean; breakWord?: boolean; autoFitSize?: boolean; minFontSize?: number; }