Skip to content

Service · inherits Instance

TextService

Official docs ↗

Service internally responsible for handling the display of text.

About TextService

TextService is internally responsible for handling the display of text.

Methods 5

  • FilterStringAsync(stringToFilter: string, fromUserId: int64, textContext: TextFilterContext = PrivateChat) → TextFilterResultYieldsFilters a string being received from a user and returns a

    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 fromUserId is not online on the current server.
  • GetFamilyInfoAsync(assetId: ContentId) → DictionaryYieldsReturns a table containing the name and faces of a font family.

    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 LuaGlobals.pcall to catch and handle errors.

  • GetTextBoundsAsync(params: GetTextBoundsParams) → Vector2YieldsComputes the Vector2 dimensions (in pixels) that will be taken up with text when using a GetTextBoundsParams object.

    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 LuaGlobals.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.

  • GetTextSize(string: string, fontSize: int, font: Enum.Font, frameSize: Vector2) → Vector2Computes the Vector2 dimensions (in pixels) that will be taken up with text when using the specified formatting parameters and size constraints.

    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.

  • GetTextSizeOffsetAsync(fontSize: int, font: Datatype.Font) → floatYieldsReturns the offset used to up-scale text based on the current GuiService.PreferredTextSize setting.

    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 LuaGlobals.pcall to catch and handle errors.

TextService also has every member of Instance. Deprecated and Roblox-only members are hidden.

Reference text from the Roblox Creator Documentation, licensed CC BY 4.0, reorganized by rbxtoolshub.com · Studio 0.743.0.7431133.