API / geotoolkit / renderer / TextMetrics / TextMetrics
renderer.TextMetrics.TextMetrics
Defines text metrics
Constructors
| [new TextMetrics(width)](/solutions/geotoolkit/apis/classes/geotoolkit.renderer.textmetrics.textmetrics.md#new textmetrics(width)) | [new TextMetrics(width, height, fontMetrics)](/solutions/geotoolkit/apis/classes/geotoolkit.renderer.textmetrics.textmetrics.md#new textmetrics(width, height, fontmetrics)) |
|---|
Methods
Css Properties
| Name | Type | Description |
|---|---|---|
fontmetrics | FontMetrics | Font metrics |
fontmetrics-ascent | number | |
fontmetrics-descent | number | |
fontmetrics-height | number | |
height | number | Set the height |
width | number | Set the width |
Constructors
• new TextMetrics(width?)
| Name | Type |
|---|---|
Optional width | Options |
• new TextMetrics(width, height, fontMetrics?)
| Name | Type | Description |
|---|---|---|
width | number | width or properties object |
height | number | height |
Optional fontMetrics | FontMetrics | font metrics |
Methods
▸ clone(): TextMetrics
Return clone object.
clone a copy of this object
▸ getClassName(): string
string
▸ getFontMetrics(): FontMetrics
Return font metrics
font metrics
▸ getHeight(): number
return height
number
▸ getProperties(): Options
Gets all the properties pertaining to this object
properties
▸ getWidth(): number
return width
number
▸ setMetrics(width, height, fontMetrics?): TextMetrics
setMetrics
| Name | Type | Description |
|---|---|---|
width | number | width |
height | number | height |
Optional fontMetrics | FontMetrics | font metrics |
this
▸ setProperties(properties?): TextMetrics
Sets all the properties pertaining to this object
| Name | Type | Description |
|---|---|---|
Optional properties | Options | An object containing the properties to set |
▸ toRect(): Rect
Convert current instance TextMetrics to Rect
▸ Static clearCache(): void
clears the current cache
void
▸ Static getClassName(): string
string
▸ Static getMeasureTextStrategy(): TextMetricsMeasureStrategy
Returns the current text measure strategy
▸ Static measureText(text, textStyle?, useFontMetrics?): TextMetrics
Measure text size in device coordinates
| Name | Type | Description |
|---|---|---|
text | string | current text string |
Optional textStyle | TextStyle | the text style |
Optional useFontMetrics | boolean | flag to calculate font metrics |
text metrics
▸ Static parseFont(font): Font
Parse font weight, size and family based on font string follow w3 recommendation see http://www.w3.org/TR/css3-fonts/ if the font cannot be parsed it will return default font : 12px arial.
| Name | Type | Description |
|---|---|---|
font | string | TextStyle | current font for the text |
▸ Static setCacheLimit(val): void
Sets the maximum cache limit
| Name | Type | Description |
|---|---|---|
val | number | number of different font metrics that can be implemented |
void
▸ Static setMeasureTextStrategy(val): void
Sets the strategy to use when measuring text size This function sets the 'MeasureText' function according to the strategy
| Name | Type | Description |
|---|---|---|
val | TextMetricsMeasureStrategy | customMeasureTextStrategy | strategy to measure text |
void