algonim
    Preparing search index...
    Index

    Constructors

    Properties

    drawer: Drawer
    textHeightFactor: number = 0.8

    Scales strings' measured heights by this. Values <1 make lines condensed, and values >1 make them sparse.

    hyphen: string = '‐'

    String inserted at the end of a line when two non-whitespace characters are separated.

    defaultLineBreakFn: LineBreakFn = ...

    Breaks on the common '\n' and the abomination known as '\r\n'.

    neverLineBreakFn: LineBreakFn = ...

    Never breaks.

    Methods

    • Splits text into discrete lines based on line breaks and, optionally, width. The resulting lines come with size information.

      Parameters

      • sourceText: Text
      • maxWidth: number = Infinity

        Optional maximum width to wrap lines at. When left at its default value of Infinity, lines will only be split at line breaks.

      • style: Partial<FontStyle> = {}

        Style used to measure the text. Has no effect if maxWidth is Infinity.

      • explicitBreakFn: LineBreakFn = TextWrapper.defaultLineBreakFn

        Function that will be used to identify explicit line breaks, like '\n' in strings. The default implementation is TextWrapper.defaultLineBreakFn.

      Returns { parts: { piece: TextPiece; size: Size }[]; size: Size }[]

    • Creates a line break function that just looks for the specified substrings. Note that substrings are checked one after the other, so if it returns 'a' before 'ab', the latter pattern will never be matched.

      Parameters

      • substrings: Iterable<string>

        Substrings that are considered line breaks. Be careful, this is captured by the returned function!

      • keepSeparators: boolean = false

        Whether to include the matched substring in the result when breaking.

      Returns LineBreakFn

      LineBreakFn