Service · inherits Instance
TextService
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 aThis method filters a string being received from a user and returns a
TextFilterResultwhich 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.
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 theTextLabel.FontFaceproperty set, then the method returns without yielding.This method can fail because of network errors and should be wrapped in
LuaGlobals.pcallto catch and handle errors.GetTextBoundsAsync
(params: GetTextBoundsParams) → Vector2YieldsComputes theVector2dimensions (in pixels) that will be taken up with text when using aGetTextBoundsParamsobject.Computes the
Vector2dimensions (in pixels) that will be taken up with text when using parameters defined in aGetTextBoundsParamsobject. This method is similar toGetTextSize()but uses theFontobject which has access to more fonts thanFont.This method is a useful alternative to the
TextBoundsproperty of theTextLabel/TextButtonobjects, sinceGetTextBoundsAsync()can calculate the dimensions required by a particular text string in aTextLabelorTextButtonbefore 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.pcallto catch and handle errors. If the font is already loaded, it will not yield;ContentProvider.PreloadAsynccan be used to make sure a font is loaded.GetTextSize
(string: string, fontSize: int, font: Enum.Font, frameSize: Vector2) → Vector2Computes theVector2dimensions (in pixels) that will be taken up with text when using the specified formatting parameters and size constraints.Computes the
Vector2dimensions (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
TextBoundsproperty of theTextLabel/TextButtonobjects, sinceGetTextSize()can calculate the dimensions required by a particular text string in aTextLabelorTextButtonbefore such an object is created or text property set.This method is limited to fonts under
Font. To access more fonts underFont, useGetTextBoundsAsync()instead.GetTextSizeOffsetAsync
(fontSize: int, font: Datatype.Font) → floatYieldsReturns the offset used to up-scale text based on the currentGuiService.PreferredTextSizesetting.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
TextLabelorTextButtonbased onPreferredTextSize.Note that, currently, the
fontSizeandfontparameters 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 inLuaGlobals.pcallto 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.