TextRenderer.d.ts 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. /**
  2. * Renders text and computes text bounding boxes.
  3. *
  4. */
  5. export default class TextRenderer {
  6. static $inject: string[];
  7. /**
  8. * @param config
  9. */
  10. constructor(config?: TextRendererConfig);
  11. /**
  12. * Get the new bounds of an externally rendered,
  13. * layouted label.
  14. *
  15. * @param bounds
  16. * @param text
  17. *
  18. * @return
  19. */
  20. getExternalLabelBounds: (bounds: Rect, text: string) => Rect;
  21. /**
  22. * Get the new bounds of text annotation.
  23. *
  24. * @param bounds
  25. * @param text
  26. *
  27. * @return
  28. */
  29. getTextAnnotationBounds: (bounds: Rect, text: string) => Rect;
  30. /**
  31. * Create a layouted text element.
  32. *
  33. * @param text
  34. * @param options
  35. *
  36. * @return rendered text
  37. */
  38. createText: (text: string, options?: TextLayoutConfig) => SVGElement;
  39. /**
  40. * Get default text style.
  41. */
  42. getDefaultStyle: () => {
  43. fontFamily: string;
  44. fontSize: number;
  45. fontWeight: string;
  46. lineHeight: number;
  47. } & Partial<TextRendererStyle>;
  48. /**
  49. * Get the external text style.
  50. */
  51. getExternalStyle: () => {
  52. fontFamily: string;
  53. fontSize: number;
  54. fontWeight: string;
  55. lineHeight: number;
  56. } & Partial<TextRendererStyle> & {
  57. fontSize: number;
  58. };
  59. }
  60. export type TextRendererStyle = {
  61. fontFamily: string;
  62. fontSize: number;
  63. fontWeight: string;
  64. lineHeight: number;
  65. };
  66. export type TextRendererConfig = {
  67. defaultStyle?: Partial<TextRendererStyle>;
  68. externalStyle?: Partial<TextRendererStyle>;
  69. };
  70. type TextLayoutConfig = import('diagram-js/lib/util/Text').TextLayoutConfig;
  71. type Rect = import('diagram-js/lib/util/Types').Rect;