Starling: inconsistentsy in TextField format/options

Hello! I`m porting a game from flash to openfl and hit some troubles. Namely - current port of starling has small inconsistency between flash realization and openfl one (starling 2.4)

Specifically here: https://github.com/openfl/starling/blob/master/src/starling/text/TextField.hx

  • In flash there is a way to give TextField custom class, derived from TextFormat (or custom class, derived from TextOptions). With this ability user can give text field additional values, which can be used later in custom BitmapFont renderer (since text format and options are the only way to send additinal text/rendering values to renderer)
  • Current port has no ways to do so, since it creates default classes and uses copies. So there is no way to send something custom to custom BitmapRenderer.

And here: https://github.com/openfl/starling/blob/master/src/starling/text/BitmapFont.hx

I know i can copy off whole class (unfortunately there private fields used everywhere, that prevent simple override of methods) and use them with custom fixes, but… Are there any reasons not to do the same in openfl port? Flash realization much more flexible for fonts rendering customization. This was really convinient.

Hi!

Thanks for the help! This was an oversight:

Please let me know if you see any other issues with the port.

You mentioned giving TextField a custom class, do you know of a place between the ActionScript and Haxe where the internal code is different, preventing you from doing this?

Thanks :slight_smile:

1 Like

Thanks a lot! :slight_smile:

Regarding your question - after looking more closely i noted that openfl code uses clone() of TextFormat in constructor.

_format = format != null ? format.clone() : new TextFormat();

and i just missed to add override for this method in custom TextFormat, so default “clone” returned default TextFormat, completely throwing away my custom class. After proper override i can see my custom TextFormat in BitmapFont renderer, hooray! :slight_smile:

Current Starling codebase uses the same clone, so no problem on openfl port, sorry for hassle. but it definitely worked before, and since i decided to switch to Haxe/Openfl at the same time as upgrading to Starling 2.4 - seems this code was ok in previous versions (of Starling)… i guess.
Anyway thanks for help!

1 Like

Thanks for the feedback, and congratulations on getting things up an running! Please stay in touch if you experience issues, or have some screenshots to show :slight_smile:

1 Like