TextMetrics
class TextMetrics extends Bounds
a Text Metrics object that contains helper for text manipulation
Constructor
new TextMetrics(ancestor: Text | BitmapText) → {}
Name | Type | Description |
---|---|---|
ancestor | Text | BitmapText |
the parent object that contains this TextMetrics object |
Summary
Properties from TextMetrics
Methods from TextMetrics
Properties inherited from Bounds
Methods inherited from Bounds
|
|
|
|
|
|
|
|
|
|
reset the bound |
|
Bounds |
|
boolean |
|
boolean |
|
boolean |
|
|
|
|
|
Polygon |
|
|
|
|
Public Properties
ancestor: Renderable = undefined
Renderable
a reference to the parent object that contains this TextMetrics object
Public Methods
lineHeight() → {number}
Returns the height of a segment of inline text in CSS pixels.
Type | Description |
---|---|
number |
the height of a segment of inline text in CSS pixels. |
lineWidth(text: string, context: CanvasRenderingContext2D) → {number}
Returns the width of the given segment of inline text in CSS pixels.
Name | Type | Attributes | Description |
---|---|---|---|
text | string |
the text to be measured |
|
context | CanvasRenderingContext2D |
<optional> |
reference to an active 2d context for canvas rendering |
Type | Description |
---|---|
number |
the width of the given segment of inline text in CSS pixels. |
measureText(text: string, context: CanvasRenderingContext2D) → {TextMetrics}
measure the given text size in CSS pixels
Name | Type | Attributes | Description |
---|---|---|---|
text | string |
the text to be measured |
|
context | CanvasRenderingContext2D |
<optional> |
reference to an active 2d context for canvas rendering |
Type | Description |
---|---|
TextMetrics |
this |
wordWrap(text: string | Array<string>, width: number, context: CanvasRenderingContext2D) → {Array<string>}
wrap the given text based on the given width
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 |
Type | Description |
---|---|
Array<string> |
an array of string representing wrapped text |