For a specific animated text effect, I need to create an individual text label for each grapheme. I do this very simply: for each grapheme, create a label using a predetermined text size and sizing the label based on label.TextBounds
.
Code for creating TextLabels
for first, last in utf8.graphemes(newText) do
local character = string.sub(newText, first, last)
local container = script.LetterTemplate:Clone()
local label = container.TextLabel
label.Text = character
label.TextSize = chosenTextSize
container.Name = tostring(first)
container.LayoutOrder = first
container.Parent = hintFrame
container.Size = UDim2.fromOffset(label.TextBounds.X, label.TextBounds.Y)
label:GetPropertyChangedSignal("TextBounds"):Connect(function()
container.Size = UDim2.fromOffset(label.TextBounds.X, label.TextBounds.Y)
end)
end
In almost all use cases, this works exactly as intended. Both on PC (in-studio and in-game), and on the mobile emulator in studio, this functions correctly. However, upon testing in-game on a mobile device (iPhone 15 Plus), “TextFits” is false for some of the created labels.
Intended Behavior (PC Studio):
Intended Behavior (iPhone 14 Plus Emulator):
Faulty Behavior (In-Game Mobile):
Any idea what may be causing this and how I might be able to fix it?