Class TextUtil

This class handling text rendering on html view port

Hierarchy

  • TextUtil

Index

Constructors

constructor

  • description

    Constructs a new object.

    Parameters

    • context: any

      context fetched from canvas

    • Default value font: Font = null

      font instance reference

    Returns TextUtil

    Returns the newly created instance TextUtil

Properties

Private allowedMarkups

allowedMarkups: string[] = ['b', 'strong', 'i', 'em', 'sup', 'sub']

Private context

context: any

Private currentMarkup

currentMarkup: string = ""

Private dx

dx: number

Private font

font: Font = new Fovia.Util.Font()

Private hasHTMLMarkup

hasHTMLMarkup: boolean = false

Private isBold

isBold: boolean = false

Private isEnd

isEnd: boolean = false

Private isItalic

isItalic: boolean = false

Private isSub

isSub: boolean = false

Private isSup

isSup: boolean = false

Private line

line: any[] = []

Private lineChuck

lineChuck: string = ""

Private lines

lines: any[] = []

Private xCoord

xCoord: number = 0

Private yCoord

yCoord: number = 0

Methods

Private addLine

  • addLine(): void
  • description

    Add text lines in context

    Returns void

Private endLine

  • endLine(): void
  • description

    clear the line object

    Returns void

Private format

  • format(text: string, lineWidth: number): void
  • description

    Format the given text to renderable html text

    Parameters

    • text: string

      Text to be processed

    • lineWidth: number

      Line width on the output

    Returns void

Private processMarkup

  • processMarkup(): void
  • description

    convert the line chunk to markup

    Returns void

render

  • description

    Render the given text on canvas

    Parameters

    • text: string

      Text to be rendered

    • anchorPoint: Point

      Anchor point where to start render the text on viewport

    • lineWidth: number

      Specifies the line width after the width reaming text rendered in new line

    • Default value alignment: HorizontalJustification = Fovia.HorizontalJustification.left

      Specifies the alignment of the text to be rendered

    Returns void

Private reset

  • reset(): void
  • description

    reset all the members

    Returns void

setFont

  • setFont(font: Font): void
  • description

    set the font instance to be applied for text annotation

    Parameters

    • font: Font

      Specifies the font instance

    Returns void

Private updateMarkup

  • updateMarkup(startIndex: number, text: string): boolean
  • description

    updates given text as markup

    Parameters

    • startIndex: number

      start index of the given text where to start markup

    • text: string

      text to be processed

    Returns boolean

    True will be returned in success case, false will be returned in failure case