I am converting Animate/Flash projects to OpenFL based HTML5 projects. Most of the display objects are stored in the SWF file.
When I embed a static text field that has multiple lines of text, the width property is ignored and the text is displayed as one line. If I insert line breaks to ensure multiple lines, formatting such as bold, etc. is lost.
If the text field is a dynamic text field with multiline option on, the width of the text field is preserved so I get the multiple lines but again some of the text formatting is lost.
So when I do need dynamic text fields, I have to code those. But using the auto-size options sometimes results in the text field being shifted horizontally when text is placed in the field. Iâve had to make my own subclass of text field so that I can specify the text and x coord of the field and it mimics the behavior of the auto-size options.
For labels and other text that does not change, I have to resort to making individual static fields for each line of text.
I have the same problem so Iâll try to make a sample fla when Iâll get back from holidays.
Itâs strange but Iâm able to keep my formatted text when I use the htmlText returned in as3.
My process :
-extract htmlText from all textfields and export it in xml (use as3 or jsfl for that).
-use the htmlText stored in your xml in your project
-everything seems fine now
Other bug:
When I use ALIGN RIGHT in Adobe Animate, some texts (or maybe all) appear left aligned.
Oh, and in AS3, you canât set the text on a dynamic TextField or it loses the formatting. You need to textField.defaultTextFormat = textField.getTextFormat () first (which seems a little silly, but thatâs how I always had to do it) ÂŻ_(ă)_/ÂŻ
Yes, itâs very strange, some of my projects work pretty well, other donât.
There are some differences in those projects : they donât have the same font, the project that doesnât work properly has been made in Mac first from Illustrator import and then compiled in Windows, while the project that works has been made 100% in Animate/Windows. Maybe there is a strange Animate bug here that affects the openfl swf importer or the htmlparser?
Iâll make a sample in 2 weeks.
I remember having an other problem in my projects that use Animate. If you scale a little a textfield (99%) that has a text that takes all the width, you will see the text correctly in Animate and the swf but not in openfl (itâs like the textfield is still at 100%, so you donât see the last character). Iâll also try to add this in the sample.
A sample would be great â there are a lot of SWF tags, so thereâs a possibility that different operating systems or versions could write different SWF tags, which could behave slightly differently.
As for dynamic TextField width, when we render, the text measurement might be slightly different for HTML5 especially. Different font rendering engines can behave a little differently, and measure a half pixel wider or smaller.
Static TextField content should be written as shape drawing information, so we can render the text out like any other vector
I made a test project that illustrates what happens to textfields stored in a Animate/Flash swf file. The first image shows how several different fields are formatted in Animate and displayed by Flash Player and the second how Firefox displayed the HTML5 version created with a lime build html5 (openfl 7.0.0 & lime 6.0.1) using Visual Studio Code.
This show what I said before, static fields preserve the text format but only displays one line. Dynamic fields can display multiple lines but while font size, font color are preserved, the font setting of Open Sans is not which makes no sense to me. With code I can change the font to Open Sans but I donât understand why I should have to.
The last image is simply the code that grabs the one symbol that holds everything and adds it to the stage. I made a zip file with all the code files, resources and build results which you can access at https://www.dropbox.com/s/rsh27q9zppbva0s/TextFieldTest.zip?dl=0
No I havenât and donât know how to access it after I put it in Assets. But the fact that sometimes the font I want is used and sometimes not says that the name itself is not being preserved and having a font file with that name wouldnât change anything.
Currently, our SWF support remembers the name used in Adobe Animate, then looks for that name at runtime. Adding a font to your assets on build will allow us to build a webfont, using the detected name from that font. Usually that matches, but if it does not, you can change the name in Animate sometimes, or even use custom CSS to match the exact name
I updated to openfl (7.1.2), lime (6.2.0) and Haxe std (3.4.7). Still have a problem with static textfields showing just the first line.
Using Terminal I did âopenfl rebuild toolsâ which gave me "Library format is not installed : run âhaxelib install formatâ
So I did âhaxelib install formatâ which downloaded format-3,4,1.zip, installed it and then said Current version is now 3.4.1
I did âopenfl rebuild toolsâ again and there was a pause for a couple of seconds and then no message, just the prompt returned.
Rebuilt the test projects and static textfields still showing just the first line.
What do I need to do and please if I have to type something in Terminal, tell me exactly what to type. I had no idea how to âpull the latest sourceâ or âpatch my release copy of OpenFL.â