# TextMeasureService documentation

**Kind:** class

**Provided in:** `root`

```
import { TextMeasureService } from '@siemens/element-ng/common';
```

```
undecorated_class TextMeasureService
```

#### Attributes and Methods

##### getFontStyle

[Source for getFontStyle](<https://github.com/siemens/element/blob/main/projects/element-ng/common/services/text-measure.service.ts#L29-L40>)

Get font styles for `font` CSS short-hand property.

```
getFontStyle(element: HTMLElement, overrides?: FontStyleOverride): string
```

#### Parameters

| Name | Type | Default | Description |
| --- | --- | --- | --- |
| [element](<https://github.com/siemens/element/blob/main/projects/element-ng/common/services/text-measure.service.ts#L29-L29>) | `HTMLElement` |  |  |
| [overrides](<https://github.com/siemens/element/blob/main/projects/element-ng/common/services/text-measure.service.ts#L29-L29>) (optional) | `FontStyleOverride` |  |  |

**Returns:** [string](<https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String>)

##### measureText

[Source for measureText](<https://github.com/siemens/element/blob/main/projects/element-ng/common/services/text-measure.service.ts#L23-L27>)

Measure text width in pixel.

```
measureText(text: string, fontRef?: string | HTMLElement, overrides?: FontStyleOverride): number
```

#### Parameters

| Name | Type | Default | Description |
| --- | --- | --- | --- |
| [text](<https://github.com/siemens/element/blob/main/projects/element-ng/common/services/text-measure.service.ts#L23-L23>) | `string` |  |  |
| [fontRef](<https://github.com/siemens/element/blob/main/projects/element-ng/common/services/text-measure.service.ts#L23-L23>) (optional) | `string \| HTMLElement` |  |  |
| [overrides](<https://github.com/siemens/element/blob/main/projects/element-ng/common/services/text-measure.service.ts#L23-L23>) (optional) | `FontStyleOverride` |  |  |

**Returns:** [number](<https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number>)

### Types Documentation

### [FontStyleOverride](<https://github.com/siemens/element/blob/main/projects/element-ng/common/services/text-measure.service.ts#L7-L13>)

**Kind:** interface

```
import type { FontStyleOverride } from '@siemens/element-ng/common';
```

```
interface FontStyleOverride
```

#### Properties

| Name | Type | Description |
| --- | --- | --- |
| [fontFamily](<https://github.com/siemens/element/blob/main/projects/element-ng/common/services/text-measure.service.ts#L12-L12>) (optional) | `string` |  |
| [fontSize](<https://github.com/siemens/element/blob/main/projects/element-ng/common/services/text-measure.service.ts#L11-L11>) (optional) | `string` |  |
| [fontStyle](<https://github.com/siemens/element/blob/main/projects/element-ng/common/services/text-measure.service.ts#L8-L8>) (optional) | `string` |  |
| [fontVariant](<https://github.com/siemens/element/blob/main/projects/element-ng/common/services/text-measure.service.ts#L9-L9>) (optional) | `string` |  |
| [fontWeight](<https://github.com/siemens/element/blob/main/projects/element-ng/common/services/text-measure.service.ts#L10-L10>) (optional) | `string` |  |
