Skip to main content

TextServiceUtils

Functions

getSizeForLabel

TextServiceUtils.getSizeForLabel(
textLabelTextLabel,
textstring,
maxWidthnumber
) → Promise<Vector2>

Gets the size for the label using legacy API surface.

warning

This will not handle new font faces well.

promiseTextBounds

TextServiceUtils.promiseTextBounds(paramsGetTextBoundsParams) → Promise<Vector2>

Promises the text bounds for the given parameters

observeSizeForLabelProps

TextServiceUtils.observeSizeForLabelProps(propstable) → Observable<Vector2>--

The text bounds reported

Observes the current size for the current props. The properties can be anything Blend would accept as an input. If FontFace is defined, it will be used before Font. The following properties are available:

  • Text - string
  • TextSize - number
  • Font - Enum.Font
  • FontFace Font
  • MaxSize - Vector2
  • LineHeight - number
local stringValue = Instance.new("StringValue")
stringValue.Text = "Hello"

local observe = TextServiceUtils.observeSizeForLabelProps({
	Text = stringValue;
	Font = Enum.Font.;
	MaxSize = Vector2.new(250, 100);
	TextSize = 24;
})

-- Be sure to clean up the subscription
observe:Subscribe(function(size)
	print(size)
end)

Show raw api
{
    "functions": [
        {
            "name": "getSizeForLabel",
            "desc": "Gets the size for the label using legacy API surface.\n\n:::warning\nThis will not handle new font faces well.\n:::",
            "params": [
                {
                    "name": "textLabel",
                    "desc": "",
                    "lua_type": "TextLabel"
                },
                {
                    "name": "text",
                    "desc": "",
                    "lua_type": "string"
                },
                {
                    "name": "maxWidth",
                    "desc": "",
                    "lua_type": "number"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "Promise<Vector2>"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 27,
                "path": "src/textserviceutils/src/Shared/TextServiceUtils.lua"
            }
        },
        {
            "name": "promiseTextBounds",
            "desc": "Promises the text bounds for the given parameters",
            "params": [
                {
                    "name": "params",
                    "desc": "",
                    "lua_type": "GetTextBoundsParams"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "Promise<Vector2>"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 45,
                "path": "src/textserviceutils/src/Shared/TextServiceUtils.lua"
            }
        },
        {
            "name": "observeSizeForLabelProps",
            "desc": "Observes the current size for the current props. The properties\ncan be anything [Blend] would accept as an input. If FontFace is defined,\nit will be used before Font. The following properties are available:\n\n* `Text` - string\n* `TextSize` - number\n* `Font` - [Enum.Font]\n* `FontFace` [Font]\n* `MaxSize` - [Vector2]\n* `LineHeight` - number\n\n```lua\nlocal stringValue = Instance.new(\"StringValue\")\nstringValue.Text = \"Hello\"\n\nlocal observe = TextServiceUtils.observeSizeForLabelProps({\n\tText = stringValue;\n\tFont = Enum.Font.;\n\tMaxSize = Vector2.new(250, 100);\n\tTextSize = 24;\n})\n\n-- Be sure to clean up the subscription\nobserve:Subscribe(function(size)\n\tprint(size)\nend)\n\n```",
            "params": [
                {
                    "name": "props",
                    "desc": "",
                    "lua_type": "table"
                }
            ],
            "returns": [
                {
                    "desc": "The text bounds reported",
                    "lua_type": "Observable<Vector2>"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 95,
                "path": "src/textserviceutils/src/Shared/TextServiceUtils.lua"
            }
        }
    ],
    "properties": [],
    "types": [],
    "name": "TextServiceUtils",
    "desc": "",
    "source": {
        "line": 4,
        "path": "src/textserviceutils/src/Shared/TextServiceUtils.lua"
    }
}