Gamua / Starling-Framework

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

Exposing default text compositor for extending TextField #901

Closed neuronix closed 8 years ago

neuronix commented 8 years ago

Hi Daniel,

Adding the TrueTypeCompositor and moving the rendering of text outside of the textfield class is a great move in starling 2.0. However, the compositor is private and cannot be replaced for easy extending.

I created a TLFCompositor that uses the TLF framework to render RTL correctly with starling. However, to use it, I had the modify the TextField class.

Enabling TLF support is then as simple as TextField.defaultCompositor = new TLFCompositor(); (and including the required .swcs of course).

You can see both classes and example here: https://gist.github.com/neuronix/009fa134fcfbf80a3e9ab1fdf924a5fa

This might not be how you would do it, but I would like to ask for you to allow some sort of access to the compositor for easy extending.

Thanks again for all your hard work Daniel ! :)

PrimaryFeather commented 8 years ago

Awesome! Thanks a lot for your efforts!

Yes, the idea behind that change was exactly to allow for things like that, I just wanted to wait exposing the property until I had an actual implementation available to work with — like yours. :smile:

I'll look into it!

PrimaryFeather commented 8 years ago

I implemented it just as you suggested, and removed the now unused sTrueTypeCompositor along the way. That should do it! :smile:

neuronix commented 8 years ago

Great! Thanks :)