Text > Shortened text to make as small as possible to fit within a region

I would like to know if this is the most optimized way to handle text shortening

					local textsize = math.abs(19-(topbar.AbsoluteSize.X-55))
					print(textsize)
					local text = computerdata.UIText.TextBounds.X
					if text > textsize then
						repeat computerdata.UIText.Text = string.sub(computerdata.UIText.Text,1,#computerdata.UIText.Text-1)
							print(computerdata.UIText.Text,computerdata.UIText.TextBounds.X,textsize-9)
						until computerdata.UIText.TextBounds.X < textsize - 9
						computerdata.UIText.Text = computerdata.UIText.Text.."..."
					end

If it is under a gui, then you can switch the TextScaled property to true. For example,


local TextLabel = "your text labet or text button or text box"

TextLabel.TextScaled = true

I don’t want it scaled. Its supposed to be the text like on a computer.

Okay, I’m a little confused now. What exactly did you want? I thought you said you wanted to make text size smaller to fit a label.

A space that fits the confines of a region, not scaling, just automating it to look like the top bar of a window.
IE:
image
Current code does this:
image

Um, I’m still confused. Can you explain in more detail what you are trying to achieve?

Basically this:
image
image
Depending on how long a thing is, it will shrink the top bar text to accurately show the text.
image
image
image

Ah okay. I myself don’t know how to do that, but I wish you good luck finding a solution!

I have already did it, but I was wondering if I could make the text handler shorter in length/runtime

Oh wait, I actually get it better now. Lemme look into some things.

Yeah I think your current method is pretty efficient. Stick with that.

I could do a check with 50% checks, where it checks half set, then if so, it removes 50% either left or right depending on stuff.

under 50%, check the left side starting from beginning to end, above 50%, check from right to left

image
yeah, I got it pretty small iteration# now