TextService.d.ts 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. import { CanvasLike, GlobalRuntime } from '..';
  2. import type { ParsedTextStyleProps } from '../display-objects';
  3. import { Rectangle } from '../shapes';
  4. export 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. }
  15. interface IFontMetrics {
  16. ascent: number;
  17. descent: number;
  18. fontSize: number;
  19. }
  20. /**
  21. * Borrow from pixi/packages/text/src/TextMetrics.ts
  22. */
  23. export declare class TextService {
  24. private runtime;
  25. constructor(runtime: GlobalRuntime);
  26. /**
  27. * font metrics cache
  28. */
  29. private fontMetricsCache;
  30. /**
  31. * Calculates the ascent, descent and fontSize of a given font-style.
  32. */
  33. measureFont(font: string, offscreenCanvas: CanvasLike): IFontMetrics;
  34. measureText(text: string, parsedStyle: ParsedTextStyleProps, offscreenCanvas: CanvasLike): TextMetrics;
  35. private setGraphemeOnPath;
  36. private wordWrap;
  37. private isBreakingSpace;
  38. private isNewline;
  39. private trimToBreakable;
  40. private shouldBreakByKinsokuShorui;
  41. private trimByKinsokuShorui;
  42. private canBreakInLastChar;
  43. private sumTextWidthByCache;
  44. private findBreakableIndex;
  45. private getFromCache;
  46. }
  47. export {};
  48. //# sourceMappingURL=TextService.d.ts.map