iink-ts - v5.0.0
    Preparing search index...

    Class TextUtil

    Hierarchy (View Summary)

    Index
    • Moves, turns or scales this symbol by composing the matrix onto the one it already carries.

      One implementation for every type, where there used to be one per type per operation. A symbol's coordinates are not touched: the matrix is the whole of what a transform changes, so there is no per-type geometry to update and nothing derived left to refresh.

      Override only for a type whose transform is not affine — DecoratorUtil overrides it to a no-op because a decorator follows its targets rather than moving on its own.

      Parameters

      Returns void

    • One text element on the baseline, one tspan per character.

      Parameters

      Returns SVGElement[]

    • Parameters

      Returns boolean

    • Parameters

      Returns boolean

    • Parameters

      Returns boolean

    • Parameters

      • partial: {
            bounds?: {
                angle?: number;
                center?: { x?: number; y?: number };
                height?: number;
                width?: number;
            };
            chars?: (
                | {
                    bounds?: { height?: number; width?: number; x?: number; y?: number };
                    color?: string;
                    fontSize?: number;
                    fontWeight?: "normal" | "bold";
                    id?: string;
                    label?: string;
                }
                | undefined
            )[];
            creationTime?: number;
            decorators?: (
                | {
                    baseline?: number;
                    creationTime?: number;
                    id?: string;
                    kind?: DecoratorKind;
                    modificationDate?: number;
                    style?: {
                        color?: string;
                        fill?: string;
                        opacity?: number;
                        pen?: TPenNib;
                        penAngle?: number;
                        penSmoothing?: number;
                        penSpeed?: number;
                        width?: number;
                        [key: string]: string
                        | number
                        | undefined;
                    };
                    targetBounds?: {
                        angle?: number;
                        center?: { x?: number; y?: number };
                        height?: number;
                        width?: number;
                    };
                    targetIds?: (string | undefined)[];
                    transform?: {
                        tx?: number;
                        ty?: number;
                        xx?: number;
                        xy?: number;
                        yx?: number;
                        yy?: number;
                    };
                    type?: Decorator;
                    xHeight?: number;
                }
                | undefined
            )[];
            id?: string;
            modificationDate?: number;
            point?: { x?: number; y?: number };
            style?: {
                color?: string;
                fill?: string;
                opacity?: number;
                pen?: TPenNib;
                penAngle?: number;
                penSmoothing?: number;
                penSpeed?: number;
                width?: number;
                [key: string]: string | number | undefined;
            };
            transform?: {
                tx?: number;
                ty?: number;
                xx?: number;
                xy?: number;
                yx?: number;
                yy?: number;
            };
            type?: Text;
        }
        • Optionalbounds?: {
              angle?: number;
              center?: { x?: number; y?: number };
              height?: number;
              width?: number;
          }
        • Optionalchars?: (
              | {
                  bounds?: { height?: number; width?: number; x?: number; y?: number };
                  color?: string;
                  fontSize?: number;
                  fontWeight?: "normal" | "bold";
                  id?: string;
                  label?: string;
              }
              | undefined
          )[]
        • OptionalcreationTime?: number
        • Optionaldecorators?: (
              | {
                  baseline?: number;
                  creationTime?: number;
                  id?: string;
                  kind?: DecoratorKind;
                  modificationDate?: number;
                  style?: {
                      color?: string;
                      fill?: string;
                      opacity?: number;
                      pen?: TPenNib;
                      penAngle?: number;
                      penSmoothing?: number;
                      penSpeed?: number;
                      width?: number;
                      [key: string]: string
                      | number
                      | undefined;
                  };
                  targetBounds?: {
                      angle?: number;
                      center?: { x?: number; y?: number };
                      height?: number;
                      width?: number;
                  };
                  targetIds?: (string | undefined)[];
                  transform?: {
                      tx?: number;
                      ty?: number;
                      xx?: number;
                      xy?: number;
                      yx?: number;
                      yy?: number;
                  };
                  type?: Decorator;
                  xHeight?: number;
              }
              | undefined
          )[]
        • Optionalid?: string
        • OptionalmodificationDate?: number
        • Optionalpoint?: { x?: number; y?: number }
        • Optionalstyle?: {
              color?: string;
              fill?: string;
              opacity?: number;
              pen?: TPenNib;
              penAngle?: number;
              penSmoothing?: number;
              penSpeed?: number;
              width?: number;
              [key: string]: string | number | undefined;
          }
        • Optionaltransform?: { tx?: number; ty?: number; xx?: number; xy?: number; yx?: number; yy?: number }

          Where this symbol sits, relative to the coordinates it stores.

          A transform writes here and nowhere else: the raw coordinates are what the symbol was created with and never move again. That is what lets the renderer apply a change by rewriting one attribute instead of rebuilding the element, and what keeps undo exact — re-applying an inverse matrix restores the value bit for bit, where re-transforming coordinates accumulated rounding.

          • Optionaltx?: number

            translation x

          • Optionalty?: number

            translation y

          • Optionalxx?: number

            scaling x

          • Optionalxy?: number

            shearing y

          • Optionalyx?: number

            shearing x

          • Optionalyy?: number

            scaling y

        • Optionaltype?: Text

      Returns TText

    • Parameters

      • partial: {
            bounds?: {
                angle?: number;
                center?: { x?: number; y?: number };
                height?: number;
                width?: number;
            };
            chars?: (
                | {
                    bounds?: { height?: number; width?: number; x?: number; y?: number };
                    color?: string;
                    fontSize?: number;
                    fontWeight?: "normal" | "bold";
                    id?: string;
                    label?: string;
                }
                | undefined
            )[];
            creationTime?: number;
            decorators?: (
                | {
                    baseline?: number;
                    creationTime?: number;
                    id?: string;
                    kind?: DecoratorKind;
                    modificationDate?: number;
                    style?: {
                        color?: string;
                        fill?: string;
                        opacity?: number;
                        pen?: TPenNib;
                        penAngle?: number;
                        penSmoothing?: number;
                        penSpeed?: number;
                        width?: number;
                        [key: string]: string
                        | number
                        | undefined;
                    };
                    targetBounds?: {
                        angle?: number;
                        center?: { x?: number; y?: number };
                        height?: number;
                        width?: number;
                    };
                    targetIds?: (string | undefined)[];
                    transform?: {
                        tx?: number;
                        ty?: number;
                        xx?: number;
                        xy?: number;
                        yx?: number;
                        yy?: number;
                    };
                    type?: Decorator;
                    xHeight?: number;
                }
                | undefined
            )[];
            id?: string;
            modificationDate?: number;
            point?: { x?: number; y?: number };
            style?: {
                color?: string;
                fill?: string;
                opacity?: number;
                pen?: TPenNib;
                penAngle?: number;
                penSmoothing?: number;
                penSpeed?: number;
                width?: number;
                [key: string]: string | number | undefined;
            };
            transform?: {
                tx?: number;
                ty?: number;
                xx?: number;
                xy?: number;
                yx?: number;
                yy?: number;
            };
            type?: Text;
        }
        • Optionalbounds?: {
              angle?: number;
              center?: { x?: number; y?: number };
              height?: number;
              width?: number;
          }
        • Optionalchars?: (
              | {
                  bounds?: { height?: number; width?: number; x?: number; y?: number };
                  color?: string;
                  fontSize?: number;
                  fontWeight?: "normal" | "bold";
                  id?: string;
                  label?: string;
              }
              | undefined
          )[]
        • OptionalcreationTime?: number
        • Optionaldecorators?: (
              | {
                  baseline?: number;
                  creationTime?: number;
                  id?: string;
                  kind?: DecoratorKind;
                  modificationDate?: number;
                  style?: {
                      color?: string;
                      fill?: string;
                      opacity?: number;
                      pen?: TPenNib;
                      penAngle?: number;
                      penSmoothing?: number;
                      penSpeed?: number;
                      width?: number;
                      [key: string]: string
                      | number
                      | undefined;
                  };
                  targetBounds?: {
                      angle?: number;
                      center?: { x?: number; y?: number };
                      height?: number;
                      width?: number;
                  };
                  targetIds?: (string | undefined)[];
                  transform?: {
                      tx?: number;
                      ty?: number;
                      xx?: number;
                      xy?: number;
                      yx?: number;
                      yy?: number;
                  };
                  type?: Decorator;
                  xHeight?: number;
              }
              | undefined
          )[]
        • Optionalid?: string
        • OptionalmodificationDate?: number
        • Optionalpoint?: { x?: number; y?: number }
        • Optionalstyle?: {
              color?: string;
              fill?: string;
              opacity?: number;
              pen?: TPenNib;
              penAngle?: number;
              penSmoothing?: number;
              penSpeed?: number;
              width?: number;
              [key: string]: string | number | undefined;
          }
        • Optionaltransform?: { tx?: number; ty?: number; xx?: number; xy?: number; yx?: number; yy?: number }

          Where this symbol sits, relative to the coordinates it stores.

          A transform writes here and nowhere else: the raw coordinates are what the symbol was created with and never move again. That is what lets the renderer apply a change by rewriting one attribute instead of rebuilding the element, and what keeps undo exact — re-applying an inverse matrix restores the value bit for bit, where re-transforming coordinates accumulated rounding.

          • Optionaltx?: number

            translation x

          • Optionalty?: number

            translation y

          • Optionalxx?: number

            scaling x

          • Optionalxy?: number

            shearing y

          • Optionalyx?: number

            shearing x

          • Optionalyy?: number

            scaling y

        • Optionaltype?: Text

      Returns TText

    • Parameters

      • chars: TTypesetChild[]
      • point: TPoint
      • boundsBox: TBox
      • Optionalstyle: {
            color?: string;
            fill?: string;
            opacity?: number;
            pen?: TPenNib;
            penAngle?: number;
            penSmoothing?: number;
            penSpeed?: number;
            width?: number;
            [key: string]: string | number | undefined;
        }

      Returns TText

    • The box the symbol was measured at, as a shape.

      An outline rather than a filled one, and that is the behaviour it had: typesetOverlapsBox asked "a corner inside the query, or a side crossing one of its sides", both about the boundary. A query landing wholly inside a word therefore did not select it, and still does not.

      symbol.bounds is the raw box, always measured unrotated and unscaled — turning and scaling are the matrix's job — so its corners are the shape, and a frame angle would have nothing to carry.

      Parameters

      Returns Polygon2d

    • A rendered word carries what a path does not: style: noSelection, so a drag over it moves the symbol instead of selecting its letters as text, and its opacity — which for a path symbol goes on the path, and here has no path to go on.

      Parameters

      Returns Record<string, string>

    • Parameters

      Returns string

    • Handles for dragging one vertex of this symbol. Empty by default: most symbols resize by their bounding box alone, and only the edge kinds offer per-vertex handles today.

      Parameters

      Returns TResizePoint[]

    • Shared by text and math, which had the same one line each.

      Parameters

      Returns TPoint[]

    • The group, the glyphs, then the decorators — highlights underneath, everything else on top.

      That layering is why decorators are appended here rather than by each subclass: a highlight drawn after the text would paint over it, and the two utils had the same ten lines to avoid it.

      Parameters

      Returns SVGGraphicsElement

    • Whether every char of the text is bold. An empty text is not.

      Parameters

      Returns boolean

    • Always. A typeset symbol is drawn from glyphs at a font size, and a font size is one number — scaling the axes unequally would ask for glyphs that do not exist.

      Parameters

      Returns boolean

    • points, carried through symbol.transform the same way a transform manager moves the symbol itself — used by getSnapPoints/getResizePoints overrides, which compute in the symbol's raw frame and hand the result through this once, forward, rather than every symbol type mapping its own points individually.

      Forward, and exact: a point maps to a point however the matrix turns or scales, so points are already the symbol's own geometry, and mapping a point through a matrix is always exact, however that matrix turns or scales.

      Parameters

      Returns TPoint[]

    • Whether a query box touches this symbol — the question selection and erasing both ask.

      Answered by the shape getGeometry returns, so a type describes what it is once and inherits this. Every built-in used to write the same one line here. Override it only for a type whose hit test is not a question about its outline.

      Parameters

      Returns boolean

    • Where a typeset symbol offers to snap, before its matrix: the corners of its box lifted onto the baseline, and its centre. Not the box's own corners — a word is read from its baseline, and lining two words up by their descenders would look wrong.

      Parameters

      Returns TPoint[]

    • Parameters

      Returns {
          bounds?: {
              angle?: number;
              center?: { x?: number; y?: number };
              height?: number;
              width?: number;
          };
          chars?: (
              | {
                  bounds?: { height?: number; width?: number; x?: number; y?: number };
                  color?: string;
                  fontSize?: number;
                  fontWeight?: "normal" | "bold";
                  id?: string;
                  label?: string;
              }
              | undefined
          )[];
          creationTime?: number;
          decorators?: (
              | {
                  baseline?: number;
                  creationTime?: number;
                  id?: string;
                  kind?: DecoratorKind;
                  modificationDate?: number;
                  style?: {
                      color?: string;
                      fill?: string;
                      opacity?: number;
                      pen?: TPenNib;
                      penAngle?: number;
                      penSmoothing?: number;
                      penSpeed?: number;
                      width?: number;
                      [key: string]: string
                      | number
                      | undefined;
                  };
                  targetBounds?: {
                      angle?: number;
                      center?: { x?: number; y?: number };
                      height?: number;
                      width?: number;
                  };
                  targetIds?: (string | undefined)[];
                  transform?: {
                      tx?: number;
                      ty?: number;
                      xx?: number;
                      xy?: number;
                      yx?: number;
                      yy?: number;
                  };
                  type?: Decorator;
                  xHeight?: number;
              }
              | undefined
          )[];
          id?: string;
          modificationDate?: number;
          point?: { x?: number; y?: number };
          style?: {
              color?: string;
              fill?: string;
              opacity?: number;
              pen?: TPenNib;
              penAngle?: number;
              penSmoothing?: number;
              penSpeed?: number;
              width?: number;
              [key: string]: string | number | undefined;
          };
          transform?: {
              tx?: number;
              ty?: number;
              xx?: number;
              xy?: number;
              yx?: number;
              yy?: number;
          };
          type?: Text;
      }

      • Optionalbounds?: {
            angle?: number;
            center?: { x?: number; y?: number };
            height?: number;
            width?: number;
        }
      • Optionalchars?: (
            | {
                bounds?: { height?: number; width?: number; x?: number; y?: number };
                color?: string;
                fontSize?: number;
                fontWeight?: "normal" | "bold";
                id?: string;
                label?: string;
            }
            | undefined
        )[]
      • OptionalcreationTime?: number
      • Optionaldecorators?: (
            | {
                baseline?: number;
                creationTime?: number;
                id?: string;
                kind?: DecoratorKind;
                modificationDate?: number;
                style?: {
                    color?: string;
                    fill?: string;
                    opacity?: number;
                    pen?: TPenNib;
                    penAngle?: number;
                    penSmoothing?: number;
                    penSpeed?: number;
                    width?: number;
                    [key: string]: string
                    | number
                    | undefined;
                };
                targetBounds?: {
                    angle?: number;
                    center?: { x?: number; y?: number };
                    height?: number;
                    width?: number;
                };
                targetIds?: (string | undefined)[];
                transform?: {
                    tx?: number;
                    ty?: number;
                    xx?: number;
                    xy?: number;
                    yx?: number;
                    yy?: number;
                };
                type?: Decorator;
                xHeight?: number;
            }
            | undefined
        )[]
      • Optionalid?: string
      • OptionalmodificationDate?: number
      • Optionalpoint?: { x?: number; y?: number }
      • Optionalstyle?: {
            color?: string;
            fill?: string;
            opacity?: number;
            pen?: TPenNib;
            penAngle?: number;
            penSmoothing?: number;
            penSpeed?: number;
            width?: number;
            [key: string]: string | number | undefined;
        }
      • Optionaltransform?: { tx?: number; ty?: number; xx?: number; xy?: number; yx?: number; yy?: number }

        Where this symbol sits, relative to the coordinates it stores.

        A transform writes here and nowhere else: the raw coordinates are what the symbol was created with and never move again. That is what lets the renderer apply a change by rewriting one attribute instead of rebuilding the element, and what keeps undo exact — re-applying an inverse matrix restores the value bit for bit, where re-transforming coordinates accumulated rounding.

        • Optionaltx?: number

          translation x

        • Optionalty?: number

          translation y

        • Optionalxx?: number

          scaling x

        • Optionalxy?: number

          shearing y

        • Optionalyx?: number

          shearing x

        • Optionalyy?: number

          scaling y

      • Optionaltype?: Text
    • Moves this symbol by a matrix.

      Concrete rather than abstract: every built-in type composes the matrix the same way, through applyTransform, and none of the six overrides this. A custom util only needs its own body if it stores something a matrix cannot express.

      Parameters

      Returns void

    • Parameters

      • text: TText
      • __namedParameters: { fontSize?: number; fontWeight?: "normal" | "bold" }

      Returns void

    • Parameters

      Returns void

    type: Text = SymbolType.Text