text.d.ts 1.3 KB

1234567891011121314151617181920212223
  1. import BoundingRect, { RectLike } from '../core/BoundingRect';
  2. import { TextAlign, TextVerticalAlign, BuiltinTextPosition } from '../core/types';
  3. export declare function getWidth(text: string, font: string): number;
  4. export declare function innerGetBoundingRect(text: string, font: string, textAlign?: TextAlign, textBaseline?: TextVerticalAlign): BoundingRect;
  5. export declare function getBoundingRect(text: string, font: string, textAlign?: TextAlign, textBaseline?: TextVerticalAlign): BoundingRect;
  6. export declare function adjustTextX(x: number, width: number, textAlign: TextAlign): number;
  7. export declare function adjustTextY(y: number, height: number, verticalAlign: TextVerticalAlign): number;
  8. export declare function getLineHeight(font?: string): number;
  9. export declare function measureText(text: string, font?: string): {
  10. width: number;
  11. };
  12. export declare function parsePercent(value: number | string, maxValue: number): number;
  13. export interface TextPositionCalculationResult {
  14. x: number;
  15. y: number;
  16. align: TextAlign;
  17. verticalAlign: TextVerticalAlign;
  18. }
  19. export declare function calculateTextPosition(out: TextPositionCalculationResult, opts: {
  20. position?: BuiltinTextPosition | (number | string)[];
  21. distance?: number;
  22. global?: boolean;
  23. }, rect: RectLike): TextPositionCalculationResult;