For years I've been ascribing to the belief that the only sure way to deal with localized dynamic text in Flash was to use system fonts for displaying utf-8 text (brought in via XML in my case). I've had good luck with it in the past, very few complaints, etc. One of the problems with using the system fonts though is not being able to set the transparency on that text. There's a good number of other problems, but I came across a post again today (for about the third time in the last couple of months) from polyGeek about fading and masking with device fonts.
Now, I've got my own way of dealing with masking device fonts, but his solution is interesting. I keep seeing it and wondering if there isn't a parallel hack that would allow rotation of text that uses system fonts other than that BitmapData.draw() hack. I banged away on it for a few minutes and searched around for a few minutes and decided not. The BitmapData.draw() thing is a good find for rotating maybe little labels or small bits of text, not so good for large blocks of text, but it's still a nice hack. Now if I could just use it with Flash 7.
And that brought me around to the question of what about using runtime shared fonts? Have the correct font for the current locale load at runtime and then the text would use "embedded" fonts. Right? But then I dig into shared fonts, how to get the right font loaded for the current locale for a global audience, what happens if the server hiccups and that font doesn't load, etc, etc.. there are some good resources out there, but also a lot of unknowns to me. From what I'm seeing shared fonts really haven't changed much since Flash Player 5 (?), and I remember the horror stories.. and the workarounds that kinda sorta worked.
I'm seeing a lot of "we have 50 SWFs on our site and load this one font for use in all of our SWFs, now we have the joys of embedded fonts in all 50 SWFs and the user only downloads the font once". But I'm not seeing much in the way of "we're sending our content out in 160 different languages to xxx,000 users daily and we're using shared fonts to load the correct font for each language and it's working just dandy".
And what's up with having to pay for this?
Shared fonts for Flash? Friday, February 09, 2007
Have Your Saycomments & trackbacks
The trackback URL for this entry is: Trackbacks are disabled for this entry
10 Feb 2007 at 08:47 pm | #
Great post. Very thought provoking, I have been working on some localized web content lately and need a cleaner way of handling the loading of fonts. I'm not just working with Latin characters, so the load times really do present an issue.
It does seem odd to buy such a thing, though, you are certainly right.
12 Feb 2007 at 07:36 am | #
Your post triggered me to write up a technique I came up with to dynamically choose shared font files based on a user's locale:
http://www.kelvinluck.com/article/dynamic-shared-fonts-in-flash
There is an example and some sourcecode there and a description of my technique - let me know if it works for you
12 Feb 2007 at 07:37 am | #
We had a discussion about this in one of our user groups the other day and reckon we've managed to get it working. Certainly I managed to set up a file where you could choose to use either Verdana embedded or Tahoma embedded and the code downloaded and ran the appropriate font shared library swf and made the shared font available. It was a bit weird getting it to work, but the long and short of it is:
For each font you want to share/embed, you have to create two SWFs. One contains a MovieClip (set to export for runtime sharing) that contains a TextField with the embedded font in it. We'll call this one 'myfont_shared.swf'.
The other contains that shared symbol on the timeline (stick it offstage somewhere so it's not visible when run) and we'll call it 'myfont_imported.swf'.
The main movie then uses loadMovie or loadMovieNum to load in 'myfont_imported.swf' - once this is loaded you have your embedded font ready for use. You can then use a TextFormat object on the TextFields that need to use it to apply the embedded font.
I have a working sample of this if you email me...
[[ edited to add.. Matt didn't provide an e-mail address.. Matt.. if you read this people have been asking for your files. ]]
18 Feb 2007 at 08:35 pm | #
Hello all.
I wish I found you post much eariler. I have been searching the web for a solution to this very problem for the last week or so and read most of the articles you have referenced. Matt I was hoping you could help me with the dynamic text and changing font issue with out using any server side code. Thank you for any help you may have to offer. Are any of these text issues going to be resolved in AS3?
Thanks again,
Ryan
15 Jun 2007 at 02:30 pm | #
Hi Matt,
I have seen this technique before, and it works well when attempting to use the fonts with a Textformat, however not so good for using with the Stylesheet Object. Does anyone know of a technique for doing this?
13 Aug 2007 at 06:40 pm | #
I must say that I've started to use a dynamic font loading library - set up as described above. Took a while to do but works like a charm on most systems. Works across domains too so that, once set up, the fonts can be accessed from any server - to any server. Maybe we should set up a dynamic library so that anyone can use them. Not sure about the Stylesheet Object - I use them on textfields with font options being realized only at runtime.