# TextService

Roblox Engine API class from Roblox Studio 0.744.0.7441077 (version-7aaa6838d36c4448).

- Inherits from, nearest first: [Instance](https://rapi.sleaze.dev/classes/Instance.md), [Object](https://rapi.sleaze.dev/classes/Object.md)
- Tags: Not creatable, Not replicated, Service
- Memory category: Instances
- HTML page: https://rapi.sleaze.dev/classes/TextService/
- Roblox documentation: https://create.roblox.com/docs/reference/engine/classes/TextService

Service internally responsible for handling the display of text.

## Methods

### FilterAndTranslateStringAsync

```luau
TextService:FilterAndTranslateStringAsync(stringToFilter: string, fromUserId: number, targetLocales: { any }, textContext: Enum.TextFilterContext? = Enum.TextFilterContext.PrivateChat): TextFilterTranslatedResult
```

- Tags: Yields, Capabilities: UI

Filters and translates a string.

### FilterStringAsync

```luau
TextService:FilterStringAsync(stringToFilter: string, fromUserId: number, textContext: Enum.TextFilterContext? = Enum.TextFilterContext.PrivateChat): TextFilterResult
```

- Tags: Yields, Capabilities: UI

Filters a string being received from a user and returns a

Parameters:

- `stringToFilter`: The text to be filtered.
- `fromUserId`: The [`Player.UserId`](https://rapi.sleaze.dev/classes/Player.md) of the player filtering the text.
- `textContext`: The context that the filtered message will be used in. This parameter does not impact the filtered result of the query and is only used to improve Roblox's text filtering.

Returns: A [`TextFilterResult`](https://rapi.sleaze.dev/classes/TextFilterResult.md) that wraps the filtered text and exposes methods for retrieving it in the form appropriate for each audience.

### GetFamilyInfoAsync

```luau
TextService:GetFamilyInfoAsync(assetId: string): { [string]: any }
```

- Tags: Yields, Capabilities: UI

Returns a table containing the name and faces of a font family.

Parameters:

- `assetId`: Asset ID of the font family to look up.

Returns: The information about the font family.

### GetFontMemoryData

```luau
TextService:GetFontMemoryData(): { [string]: any }
```

- Tags: Roblox script security, Capabilities: UI

### GetTextBoundsAsync

```luau
TextService:GetTextBoundsAsync(params: GetTextBoundsParams): Vector2
```

- Tags: Yields, Capabilities: UI

Computes the [`Vector2`](https://rapi.sleaze.dev/index/types/Vector2.md) dimensions (in pixels) that will be taken up with text when using a [`GetTextBoundsParams`](https://rapi.sleaze.dev/classes/GetTextBoundsParams.md) object.

Parameters:

- `params`: A reference to a [`GetTextBoundsParams`](https://rapi.sleaze.dev/classes/GetTextBoundsParams.md) object.

Returns: The size of the text as a [`Vector2`](https://rapi.sleaze.dev/index/types/Vector2.md).

### GetTextSize

```luau
TextService:GetTextSize(string: string, fontSize: number, font: Enum.Font, frameSize: Vector2): Vector2
```

- Tags: Capabilities: UI

Computes the [`Vector2`](https://rapi.sleaze.dev/index/types/Vector2.md) dimensions (in pixels) that will be taken up with text when using the specified formatting parameters and size constraints.

Parameters:

- `string`: The string for which the text size is to be calculated.
- `fontSize`: The integer representing the font size used. Does not accept an `FontSize` value.
- `font`: The font used.
- `frameSize`: The [`GuiBase2d.AbsoluteSize`](https://rapi.sleaze.dev/classes/GuiBase2d.md) of the text object to be used. Required to compute how the text will wrap.

Returns: The size of the space required, in pixels, by the string with the specified formatting.

### GetTextSizeOffsetAsync

```luau
TextService:GetTextSizeOffsetAsync(fontSize: number, font: Font): number
```

- Tags: Yields, Capabilities: UI

Returns the offset used to up-scale text based on the current [`GuiService.PreferredTextSize`](https://rapi.sleaze.dev/classes/GuiService.md) setting.

Parameters:

- `fontSize`: The font size, in offsets. This parameter currently does not affect the returned offset.
- `font`: The font. This parameter currently does not affect the returned offset.

Returns: The offset, in pixels, to add to the height of a [`TextLabel`](https://rapi.sleaze.dev/classes/TextLabel.md) or [`TextButton`](https://rapi.sleaze.dev/classes/TextButton.md) to up-scale it for the player's current `PreferredTextSize` setting.

### SetResolutionScale

```luau
TextService:SetResolutionScale(scale: number)
```

- Tags: Roblox script security, Capabilities: UI

## Inherited members

- From [Instance](https://rapi.sleaze.dev/classes/Instance.md): `Archivable`, `archivable`, `Attributes`, `AttributesReplicate`, `AttributesSerialize`, `HistoryId`, `Name`, `Parent`, `PredictionMode`, `PropertyStatusStudio`, `RobloxLocked`, `SerializedOverrides`, `SourceAssetId`, `Tags`, `UniqueId`, `numExpectedDirectChildren`, `DataCost`, `Capabilities`, `DefinesCapabilities`, `IsInSandbox`, `Sandboxed`, `AddTag`, `ClearAllChildren`, `Clone`, `Destroy`, `FindFirstAncestor`, `FindFirstAncestorOfClass`, `FindFirstAncestorWhichIsA`, `FindFirstChild`, `FindFirstChildOfClass`, `FindFirstChildWhichIsA`, `FindFirstDescendant`, `GetActor`, `GetAttribute`, `GetAttributeChangedSignal`, `GetAttributes`, `GetChildren`, `GetDebugId`, `GetDescendants`, `GetFullName`, `GetStyled`, `GetStyledPropertyChangedSignal`, `GetTags`, `HasTag`, `IsAncestorOf`, `IsDescendantOf`, `IsPropertyModified`, `QueryDescendants`, `RemoveTag`, `ResetPropertyToDefault`, `SetAttribute`, `WaitForChild`, `Remove`, `children`, `clone`, `destroy`, `findFirstChild`, `getChildren`, `isDescendantOf`, `remove`, `AncestryChanged`, `AttributeChanged`, `ChildAdded`, `ChildRemoved`, `DescendantAdded`, `DescendantRemoving`, `Destroying`, `StyledPropertiesChanged`, `childAdded`
- From [Object](https://rapi.sleaze.dev/classes/Object.md): `ClassName`, `className`, `GetPropertyChangedSignal`, `IsA`, `isA`, `Changed`
