ruffle-rs / ruffle

A Flash Player emulator written in Rust
https://ruffle.rs
Other
15.53k stars 805 forks source link

[AS2] [WEB] Dynamic text doesn't render correctly #1574

Open IestynBJones opened 3 years ago

IestynBJones commented 3 years ago

I'm new to ruffle but have been really impressed with how well it worked with my early AS1 stuff. Now I'm using it with some of our old AS2 educational content. Again very impressive; so many of our resources nearly have a perfect conversion except for issues with dynamic text (see attached swf for an example). intro.zip

Herschel commented 3 years ago

The SWF contains two separate tags defining "Arial", one of which contains no layout data. This font ends up getting used for the text field, causing the letters to not render correctly. Possibly because we are indexing by String name and not using the specific font ID stored in the TextField tag.

IestynBJones commented 3 years ago

Thank you Herschel. I think I know what's going on (the attached swf file is fixed). If the flash IDE cannot find the font that's specified it replaces it with a system font. In this instance the dynamic text fields were both set to Arial bold. However a static text title was set to Vectoroid font which I didn't have on my system so it was replaced with a system font; Arial I suspect (this is the one with no layout data). So I installed the missing font and recompiled the swf and low and behold ruffle renders it perfectly (see attached).

I think it is a fairly common thing in flash development where some exotic font is missing so flash substitutes a system font on compiling. Thank you so much for your work on this; it's a super project.

intro.zip

IestynBJones commented 3 years ago

I went ahead and created the rest of the resource which loads external swfs. I made sure there were no missing fonts. It ruffled perfectly for desktop browsers. Magic. However there are issues with iPad safari which doesn't render the text. I'm assuming this will have a different cause to that mentioned above : https://gcse.games/maths/problemSolving/eggCombinations/eggCombinations.html

torokati44 commented 1 year ago

Possibly because we are indexing by String name and not using the specific font ID stored in the TextField tag.

In addition, this SWF has two very similar fonts in it. One is "Arial" the other is "Arial Bold". But in fact, the "tag name" (whatever that is) for both is just "Arial" - and strangely both of them have the "bold" flag checked. This results in their FontDescriptor being equal, which is used as a key in a map in MovieLibrary. So the second one to get loaded replaces the first one in this map.

torokati44 commented 1 year ago

I think properly handling DefineFontName tags in preload, and using the names therein for resolution should fix this.