Allmas

  • Increase font size
  • Default font size
  • Decrease font size

Gumbo: Using embedded fonts with the new text primitives

E-mail Print PDF

Gumbo defines 3 new text primitives that take advantage of the new text functionality of the Flash Player 10 Text Engine: TextBox, TextGraphic and TextView. More information about them can be found in the following Gumbo features specification document: Text Primitives (TextBox, TextGraphic, and TextView).

To use embedded fonts with these text primitives, the fonts must be embedded in the Compact Font Format (CFF). This is achieved by setting the new property "cff" for font embedding to "true". Here are two examples on setting this property:

Using CSS

  1. @font-face {
  2.         src: url("MyFontFile.ttf");
  3.         fontFamily: myFontFamily;
  4.         cff: true;
  5. }

Using ActionScript

  1. [Embed(source="MyFontFile.ttf",
  2.         fontFamily="myFontFamily",
  3.         cff="true"]
  4. private const font1:Class;

The text primitives also support the new style property "fontLookup", which sets the source where to lookup for fonts. This property can have two values:

  • device : uses the fonts installed on the system that is running the SWF file
  • embeddedCFF : uses font outlines embedded in the SWF

As you can guess, this property must be set to "embeddedCFF" :

Directly in the MXML tag

  1. <TextGraphic text="My Text" fontFamily="myFontFamily" fontLookup="embeddedCFF" />

Using CSS

  1. <TextGraphic text="My Text" styleName="myTextStyle" />

  1. .myTextStyle {
  2.         fontFamily: myFontFamily;
  3.         fontLookup: "embeddedCFF";
  4. }

 
Comments (1)
1 Tuesday, 26 May 2009 15:35
Rob McCardle
Thanks for the useful article. I've written a little round up called "Flash Player 10 AS3 Text Layout Engine Dynamic Selectable Embedded TTF’s" clearing a few things up and linked to you. The use of CSS is a matter of taste - I do it the AS way ;)

http://www.robmccardle.com/wp/?p=59

Demo & source there - hope this is useful to someone,

Cheers,

Rob

www.robmccardle.com

Add your comment

BoldItalicUnderlineStrikethroughSubscriptSuperscriptEmailImageHyperlinkOrdered listUnordered listQuoteCodeHyperlink to the Article by its id
Your name:
Your email:
Subject:
Comment:

RSS Feed

Search

View Haykel Ben Jemia's profile on LinkedIn


Shared Items