I have written a Flex cookbook recipe about font embedding:
The exception during transcoding is due to the fact there needs to be a match between the fontWeight / fontStyle combination and the TrueType font that you specify. You indeed need to use different font files for all the combinations: bold / italic, bold / normal, normal / italic, normal / normal. The font you use right now only corresponds to the normal / normal combination.
Arial® Complete Family Pack
Thanks for your response. However the issue is that this method is not available for Unicode fonts as they typically do not rely upon bold or italics to show emphasis. I also appreciate your suggestion on the Arial font pack, however upon testing them none in that pack could display any Japanese characters.
My question is not really how do we do multiple font faces and weights for roman characters, it is "How does Flex apply bolding and italics to a system font. Even more so when it says that that font does not support those when trying to embed that font."
The steps to make the issue reproducable are such:
Embed only MS Arial Unicode into the application and deploy it.
On a fresh Windows 2003 machine, open up Firefox and select Japanese language.
Navigate to the application URL and view the boxes where the bold and italics should be.
Now exit Firefox. Install the MS Arial Unicode font into the windows 2003 system.
Open firefox and repeat. The areas that used to be boxes, are now bold/bold italics/italics Japanese characters.
It isn't so much the how to solve this issue. There are plenty of viable solutions. However what I would really like to know is how does Flex apply bold and italics to a font that it says does not support bold or italics.
1 person found this helpful
OK. So, first of all, are you targetting Flash Player 9 or Flash Player 10 (whether you use Flex Builder 3 with Flex SDK 3.4+ and the proper playerglobal.swc setup or Flash Builder 4) ?
That makes a big difference.
As you know, there is a new Text Rendering engine in Flash Player 10.
The problem with Flash Player 9 is that you have to embed fonts so they get anti-aliased. But asian fonts cannot be fully embedded (which is why you have to reduce the Unicode range in the font embedding settings) because they weigh about 30 MB like MS Pincho.
By contrast, the Flash Player 10 Text Rendering engine is capable of anti-aliasing device fonts.
Now, I do not know (yet) about rendering bold and italic with the same device font in Flash Player 10.
Thanks for your reply Karl.
We are targeting FP 9. Our housing framework loads us as a module and only supports 9 at the moment. We compile against Flex 3.5 sdk.
I have tried to determine if the behavior is specific to a flash player, and tested this against both FP 9 and FP 10. They behave in the same manner where as soon as the font is installed into the system, Flex begins displaying that font in bold and italics.
From other posts on the interwebs it seems that this is just a "helpful" thing that Flex does for you, however if Flex can do it automagically, there must be some way to programmatically invoke it.
I can find out for sure, but my basic understanding is that the player asks
the OS to help with the rendering of device fonts. The libraries that
renderer embedded fonts do not ask the OS for help so you get more
consistency across platforms. The embedded font libraries require that all
glyph info be in the font data.
I don't think there is a way to get the embedded font libraries to render
bold and italic without that data in the SWF.
Thanks for the response.
So if flex asks the system for help, is the system actually applying the bold and italic transformation on the font as it explicitly does not exist within the Unicode Arial font?
Probably. If you use that font from Word or some other app, can it do
bold/italic. My memory is fuzzy because I haven't done Windows programming
in years, but my recollection is that an OS like Windows will do
approximations of the font. If you ask for a particular set of font metrics
it doesn't have the exact font for, it might even use a similar font that it
can find on the system that has the closest metrics and use that instead.
Did you check to see if there is another asian font than can do bold on that
system and whether you might be seeing those glyphs instead?
>> have tried to determine if the behavior is specific to a flash player, and tested this against both FP 9 and FP 10.
The application will behave in the same manner in Flash Player 9 and 10 unless you compile for Flash Player 10:
Hi Flex harUI, thanks for your response.
I have made sure that the only font that can render Asian characters is MS Unicode Arial. So the chance that another font is drawing the bold glyphs is eliminated.
I do get the same behavior on my Mac, however the odds are that since I have MS office on my mac it likely has some font that can perform the bold/italics so that does not rule out some other font being used instead of the system doing it.
I think my only real other option to find out if it is in fact the OS performing these transformations, would be to load it on a linux system with no chinese fonts, then determine if by loading the font into the system does it get transformed.
So is there no official documentation on how this gets done within the flex framework? IE some document that explicitly relies on the OS performing a best match? And if there is, is there no standard behavior information for the various OS's?
Karl, thanks for the info, I was mainly taking a stab in the dark to see if FP 10 was doing some magic with some of the new font handling capabilities within the player.
1 person found this helpful
There is no Flex Framework code involved in font rendering. It is all done
by the underlying Flash Player. I can go bug those engineers for the answer
if you really need it, but basically, if other desktop applications on an OS
can render bold or italic given the set of installed fonts, the Flash Player
probably will leverage the same mechanism when using device fonts. But for
sure, there is different code in the Flash Player that renders embedded
fonts entirely from the font data embedded in the SWF. And probably, this
is not documented by the Flash Player because it wants to reserve the right
to change the device font implementation as the host OS services change and
new platforms with GPUs proliferate.
Thanks again for the response
I am about to the point where I am just going to have to chalk it up to magic. It would be nice to see who is actually performing that transformation. We actually tried to embed the font in a swf file and use the anti-aliasing and faux bold/italic feature in flash to make our own variation of the font but ended up with no better luck in having flex pick the right weight/style.
Its about to the point where we have a workaround that will suffice, but now my curiosity is piqued. I hate having to rely upon some unknown magic in the background to get something done. We think we can take care of this issue when we get to move to Flex 4 so that is a bonus, however that may be awhile, and this product will be in the wild for a good bit.
Thanks for all your help.