How to change text size in textarea automatically

Is there a way to resize a text in a TextArea control to match the size of the TextArea?

That means to reducing the font size if the limit of height or width of the TextArea is reached.

Note that this works only for non styled text. It would probably be possible for styled text, but it would be a whole lot more complex, involving styleRuns and looping through them. I use such a method to size styled text within TextAreas in RubberViews, though, but it would exceed this thread.

[code]Sub TextChange()
dim pic as new picture(1,1,32) = me.TextFont = me.TextSize

dim textheight as integer =,me.width)
system.DebugLog str(textheight)

if textheight > me.height then
do until textheight <= me.height or me.TextSize <= 8 =
textheight =,me.width)
me.TextSize =
me.SelTextSize = me.TextSize
elseif textheight < me.height and me.TextSize < 24 then
me.TextSize = me.TextSize+1
me.SelTextSize = me.TextSize
end if

End Sub