Gamua / Starling-Framework

The Cross Platform Game Engine
http://www.starling-framework.org
Other
2.85k stars 819 forks source link

Add autoSize to TextOptions #903

Closed neuronix closed 7 years ago

neuronix commented 7 years ago

Custom TextCompositors may require knowing if the textfield has autoSize enabled. One can cheat and look at height == 10000 but that's dirty.

TextOptions seems to have been made for this, so autoSize should be added to the list of values.

Thanks Daniel!

PrimaryFeather commented 7 years ago

Actually, the original idea was to simplify the life of the developer writing a custom compositor; that he wouldn't need to care about "autoSize", but have that handled by the TextField itself.

But I already saw this idea fail when it came to HTML fonts, which can be aligned on both sides (and thus, crippling any post-autosize logic).

I guess you ran into something similar?

neuronix commented 7 years ago

My initial implementation of TLFCompositor used TLFTextField which renders beautifully but is horribly slow (especially when using autoScale extensively). So I made a new version based on the old TLFSprite extension but it requires a few extra adjustments and workarounds.

PrimaryFeather commented 7 years ago

I see, thanks for the additional information! I'll look into it. 👍

PrimaryFeather commented 7 years ago

That should do it! Please let me know if that works for you.

neuronix commented 7 years ago

Looks great, thanks Daniel! :)