TextMetrics

class TextMetrics extends Bounds

a Text Metrics object that contains helper for text manipulation

Constructor


new TextMetrics(ancestor: Text | BitmapText) → {}
Parameters:
Name Type Description
ancestor Text | BitmapText

the parent object that contains this TextMetrics object

Public Properties


ancestor textmetrics.js:20
ancestor: Renderable = undefined

Renderable

a reference to the parent object that contains this TextMetrics object

Public Methods


lineHeight textmetrics.js:31
lineHeight() → {number}

Returns the height of a segment of inline text in CSS pixels.

Returns:
Type Description
number

the height of a segment of inline text in CSS pixels.

lineWidth textmetrics.js:43
lineWidth(text: string, context: CanvasRenderingContext2D) → {number}

Returns the width of the given segment of inline text in CSS pixels.

Parameters:
Name Type Attributes Description
text string

the text to be measured

context CanvasRenderingContext2D

<optional>

reference to an active 2d context for canvas rendering

Returns:
Type Description
number

the width of the given segment of inline text in CSS pixels.

measureText textmetrics.js:70
measureText(text: string, context: CanvasRenderingContext2D) → {TextMetrics}

measure the given text size in CSS pixels

Parameters:
Name Type Attributes Description
text string

the text to be measured

context CanvasRenderingContext2D

<optional>

reference to an active 2d context for canvas rendering

Returns:
Type Description
TextMetrics

this

wordWrap textmetrics.js:119
wordWrap(text: string | Array<string>, width: number, context: CanvasRenderingContext2D) → {Array<string>}

wrap the given text based on the given width

Parameters:
Name Type Attributes Description
text string | Array<string>

the text to be wrapped

width number

maximum width of one segment of text in css pixel

context CanvasRenderingContext2D

<optional>

reference to an active 2d context for canvas rendering

Returns:
Type Description
Array<string>

an array of string representing wrapped text


Powered by webdoc!