I am making a ‘rich text’ module, which currently just fades in one character at a time by creating a text label for each character, and doing whatever with it. This works well with one line, but TextService:GetTextSize
seems to abruptly break whenever the text is about to wrap over to the next line.
How it currently looks:
As you can see, it works fine on the first line but then the characters get stuck in the same position.
Here’s an example script:
local String = ('hello world'):rep(10);
local fullText = ''
local textService = game:GetService('TextService');
for idx = 1, #String do
fullText = fullText .. String:sub(idx, idx)
print(textService:GetTextSize(fullText, 5, Enum.Font.Garamond, Vector2.new(100, 100)));
end;
Now, let’s check the output:
As you can see the text reaches up to 100, 5
just fine, but when it wraps to the next line the X value is just permanently stuck at 84
(Y axis seems to be fine).
Now, you could go around this by running the same thing again recursively and add up each result to simulate text wrapping, but that would be messy and wouldn’t fix the issue either way.
I tried messing around with the parameters (especially the last one, text size), but it didn’t seem to do anything.
I’d like to find out what the issue is, and if possible, fix it. Thank you!