TextService
Service internally responsible for handling the display of text.
| Memory category | Instances |
|---|
Member index 8
Description
TextService is internally responsible for handling the display of text.
History 19
- 647 Add GetTextSizeOffsetAsync
- 645 Change Parameters of GetFamilyInfoAsync from (assetId: Content) to (assetId: ContentId)
- 607 Change ReturnType of FilterStringAsync from Instance to TextFilterResult
- 607 Change ReturnType of FilterAndTranslateStringAsync from Instance to TextFilterTranslatedResult
- 576 Add FilterAndTranslateStringAsync
- 573 Change ReturnType of SetResolutionScale from void to null
- 552 Add GetFontMemoryData
- 529 Add GetTextBoundsAsync
- 517 Add GetFamilyInfoAsync
- 462 Change ThreadSafety of SetResolutionScale from to Unsafe
- 462 Change ThreadSafety of GetTextSize from to Unsafe
- 462 Change ThreadSafety of FilterStringAsync from to Unsafe
- 452 Add SetResolutionScale
- 341 Change Parameters of FilterStringAsync from (stringToFilter: string, fromUserId: int64) to (stringToFilter: string, fromUserId: int64, textContext: TextFilterContext = PrivateChat)
- 322 Change Parameters of FilterStringAsync from (stringToFilter: string, fromUserId: int) to (stringToFilter: string, fromUserId: int64)
- 293 Add FilterStringAsync
- 274 Change Security of GetTextSize from RobloxScriptSecurity to None
- 216 Add GetTextSize
- 47 Add TextService
Members 8
FilterAndTranslateStringAsync
| Parameters (4) | Default | |
|---|---|---|
| stringToFilter | string | |
| fromUserId | int64 | |
| targetLocales | Array | |
| textContext | TextFilterContext | PrivateChat |
| Returns (1) | ||
| TextFilterTranslatedResult | ||
This method is no longer supported and should not be used. Translating chat messages is only available via TextChatService.
| Thread safety | Unsafe |
|---|
History 2
- 607 Change ReturnType of FilterAndTranslateStringAsync from Instance to TextFilterTranslatedResult
- 576 Add FilterAndTranslateStringAsync
FilterStringAsync
| Parameters (3) | Default | |
|---|---|---|
| stringToFilter | string | |
| fromUserId | int64 | |
| textContext | TextFilterContext | PrivateChat |
| Returns (1) | ||
| TextFilterResult | ||
This method filters a string being received from a user and returns a TextFilterResult which can be used to distribute the correctly filtered text accordingly.
This method should be called once each time a user submits a message. If it fails, do not display the text to any user.
See text filtering for usage guidelines and examples.
Notes
- This method always yields to make a text filtering service call.
- This method may throw if there is a service error that cannot be resolved. In such cases, do not retry the request, as this method implements its own retry logic internally.
- This method currently throws if
fromUserIdis not online on the current server.
| Thread safety | Unsafe |
|---|
History 5
- 607 Change ReturnType of FilterStringAsync from Instance to TextFilterResult
- 462 Change ThreadSafety of FilterStringAsync from to Unsafe
- 341 Change Parameters of FilterStringAsync from (stringToFilter: string, fromUserId: int64) to (stringToFilter: string, fromUserId: int64, textContext: TextFilterContext = PrivateChat)
- 322 Change Parameters of FilterStringAsync from (stringToFilter: string, fromUserId: int) to (stringToFilter: string, fromUserId: int64)
- 293 Add FilterStringAsync
GetFamilyInfoAsync
| Parameters (1) | ||
|---|---|---|
| assetId | ContentId | |
| Returns (1) | ||
| Dictionary | ||
Returns a table containing the name and faces of a font family. If the
font family has already been loaded by a previous call to
GetFamilyInfoAsync(), ContentProvider:PreloadAsync(), or a text
object with the TextLabel.FontFace property set, then the method
returns without yielding.
This method can fail because of network errors and should be wrapped in pcall() to catch and handle errors.
| Thread safety | Unsafe |
|---|
History 2
- 645 Change Parameters of GetFamilyInfoAsync from (assetId: Content) to (assetId: ContentId)
- 517 Add GetFamilyInfoAsync
GetFontMemoryData
| Parameters (0) | ||
|---|---|---|
| No parameters. | ||
| Returns (1) | ||
| Dictionary | ||
| Security | RobloxScriptSecurity |
|---|---|
| Thread safety | Unsafe |
History 1
- 552 Add GetFontMemoryData
GetTextBoundsAsync
| Parameters (1) | ||
|---|---|---|
| params | GetTextBoundsParams | |
| Returns (1) | ||
| Vector2 | ||
Computes the Vector2 dimensions (in pixels) that will be taken up with text when using parameters defined in a GetTextBoundsParams object. This method is similar to GetTextSize() but uses the Font object which has access to more fonts than Font.
This method is a useful alternative to the TextBounds property of the
TextLabel/TextButton objects, since GetTextBoundsAsync()
can calculate the dimensions required by a particular text string in a
TextLabel or TextButton before such an object is created
or text property set.
This is a yielding method because some fonts may need to be loaded in order to measure them. As a result, it should be wrapped in pcall() to catch and handle errors. If the font is already loaded, it will not yield; ContentProvider:PreloadAsync() can be used to make sure a font is loaded.
| Thread safety | Unsafe |
|---|
History 1
GetTextSize
| Parameters (4) | ||
|---|---|---|
| string | string | |
| fontSize | int | |
| font | Font | |
| frameSize | Vector2 | |
| Returns (1) | ||
| Vector2 | ||
Computes the Vector2 dimensions (in pixels) that will be taken up with text when using the specified formatting parameters and size constraints.
This method is a useful alternative to the TextBounds property of the
TextLabel/TextButton objects, since GetTextSize() can
calculate the dimensions required by a particular text string in a
TextLabel or TextButton before such an object is created
or text property set.
This method is limited to fonts under Font. To access more fonts under Font, use GetTextBoundsAsync() instead.
| Thread safety | Unsafe |
|---|
History 3
- 462 Change ThreadSafety of GetTextSize from to Unsafe
- 274 Change Security of GetTextSize from RobloxScriptSecurity to None
- 216 Add GetTextSize
GetTextSizeOffsetAsync
| Parameters (2) | ||
|---|---|---|
| fontSize | int | |
| font | Font | |
| Returns (1) | ||
| float | ||
Returns the offset used to up-scale text based on GuiService.PreferredTextSize, a property which may change through the player's setting in the Roblox or in‑experience Settings menus.
This offset can be used as an additive value to adjust the core height value of a TextLabel or TextButton based on PreferredTextSize.
Note that, currently, the fontSize and font parameters do not affect
the outcome and this method returns merely the offset as described above.
Also note that this method can fail because of network errors and should
be wrapped in pcall() to catch and handle errors.
| Thread safety | Unsafe |
|---|
History 1
SetResolutionScale
| Parameters (1) | ||
|---|---|---|
| scale | float | |
| Returns (1) | ||
| null | ||
| Security | RobloxScriptSecurity |
|---|---|
| Thread safety | Unsafe |
History 3
- 573 Change ReturnType of SetResolutionScale from void to null
- 462 Change ThreadSafety of SetResolutionScale from to Unsafe
- 452 Add SetResolutionScale