UNPKG

1.11 kBTypeScriptView Raw
1/// <reference types="offscreencanvas" />
2import type { ParsedTextStyleProps } from '../display-objects';
3import { Rectangle } from '../shapes';
4export interface TextMetrics {
5 font: string;
6 width: number;
7 height: number;
8 lines: string[];
9 lineWidths: number[];
10 lineHeight: number;
11 maxLineWidth: number;
12 fontProperties: IFontMetrics;
13 lineMetrics: Rectangle[];
14}
15interface IFontMetrics {
16 ascent: number;
17 descent: number;
18 fontSize: number;
19}
20export declare class TextService {
21 private cache;
22 private offscreenCanvas;
23 measureFont(font: string, offscreenCanvas: HTMLCanvasElement | OffscreenCanvas): IFontMetrics;
24 measureText(text: string, parsedStyle: ParsedTextStyleProps, offscreenCanvas: HTMLCanvasElement | OffscreenCanvas): TextMetrics;
25 private wordWrap;
26 private isBreakingSpace;
27 private isNewline;
28 private trimToBreakable;
29 private shouldBreakByKinsokuShorui;
30 private trimByKinsokuShorui;
31 private canBreakInLastChar;
32 private sumTextWidthByCache;
33 private findBreakableIndex;
34 private getFromCache;
35}
36export {};