Frank
Frank

Reputation: 6637

Loading swf-fonts with Loader works perfectly in Flex SDK 3.5 - not in Flex SDK 4

For a large project I have the following setup:

Both need to work with dynamically loaded fonts as the user can use the fonts he wants.

So we used this approach:

Now the problems: although the loaded fonts are listed when you trace Font.enumerateFonts(false), they are not used in the textarea. There the text is shown with the default font.

Maybe the problem is the fonts are loaded as embedAsCFF for the Text Layout Framework, and that way are not usable in an mx.controls.TextArea? But as I can not change that to a spark TextArea for multiple reasons, I need a solution to use the loaded fonts in that mx.controls.TextArea.

Any ideas? Thanks a lot in advance!

Frank

Upvotes: 2

Views: 1218

Answers (3)

Frank
Frank

Reputation: 6637

Apparantly the problem was located in the project properties.

In "Flex Compiler" settings, the checkbox "Use Flash Text Engine in MX components" must be unchecked!

Upvotes: 1

Jonathan Rowny
Jonathan Rowny

Reputation: 7588

This CSS code effectively retrofits mx textarea to accept CFF fonts:

mx|global{
    textFieldClass:         ClassReference("mx.core.UIFTETextField");
}

from the docs: "When MX components use FTE, they can use the same embedded fonts as Spark components, which always use FTE. Otherwise, a font must be embedded with embedAsCFF="false" for use by TextField-based components, and with embedAsCFF="true" for use by FTE-based components." http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/mx/core/UIFTETextField.html

Upvotes: 0

J_A_X
J_A_X

Reputation: 12847

I'm not sure why you're using Flash Pro to create a font swf. You could just as easily done it using CSS by embedding the fonts and compiling it as a themed swf which could be loaded on runtime.

This should work for both Flex 3 and Flex 4 (with TLF).

Upvotes: 0

Related Questions