Skip to main content
Participant
November 12, 2009
Question

How can I embed arabic Font in Flash?

  • November 12, 2009
  • 3 replies
  • 4535 views

I want to use various Arabic Fonts in Flash. I using AS3 and the textLayout.swc with the FDT in Eclipse. And compiling with the Flex SDK 4.0.0. The Compiler-Arguments are
-default-size 780 260 -default-frame-rate 31 -static-link-runtime-shared-libraries=true -managers=flash.fonts.AFEFontManager -default-background-color 0xFFFFFF -library-path {flexSDK}/frameworks/locale/en_US --target-player=10.0.32

I try this:

Embed the Arabic Font in a Font-Class
    [Embed(source='../../../../assets/fonts/AXTGIB__.TTF', fontName='AXtGIhaneBold', mimeType="application/x-font", embedAsCFF="true")]
    public var AXtGIhaneBold : Class;
 
public function Fonts() {
  Font.registerFont(AXtGIhaneBold);
}

Create a TextFlowElement and do this:


    textFlow = new TextFlow();
   
    layoutFmt = new TextLayoutFormat();
    layoutFmt.direction = Direction.RTL;
    layoutFmt.fontFamily = "AXtGIhaneBold";
    layoutFmt.renderingMode = RenderingMode.CFF;
    layoutFmt.fontLookup = FontLookup.EMBEDDED_CFF;
   
    textFlow.format = layoutFmt;

But it doesn't work. The Font in Flash don't change to AXtGIhaneBold.
Can anyone tell me what's wrong?

This topic has been closed for replies.

3 replies

Participant
December 25, 2011

FlarabyAS3 is much simpler and lighter that TLF:  http://www.arabicode.com/flarabyas3/main

Message was edited by: arabicode

Participating Frequently
December 2, 2011

hi frankie*,

Please try this, there are some difference with your code: 

http://actionscriptexamples.com/2008/11/24/embedding-fonts-in-flash-cs4-using-actionscript/ 

// ActionScript 3.0

[Embed(source="assets/ARIAL.TTF", fontFamily="ArialEmbedded")]

var ArialEmbedded:Class;

var arialEmbeddedFont:Font = new ArialEmbedded();  

var textFormat:TextFormat = new TextFormat();

textFormat.color = 0xFF0000;

textFormat.font = arialEmbeddedFont.fontName;

textFormat.size = 32; 


var textField:TextField = new TextField();

textField.autoSize = TextFieldAutoSize.LEFT;

textField.wordWrap = true;

textField.defaultTextFormat = textFormat;

textField.embedFonts = true;

textField.text = "The quick brown fox jumps over the lazy dog.";

textField.width = 500;

textField.x = 25;

textField.y = 25;

addChild(textField);


Hope it helps.

JF Software
Inspiring
December 1, 2011

I have the same problem with a number of different Arabic fonts (including the one you're trying). A call to .hasGlyphs() returns false for any roman string.

Let me know if you stumble on an answer.

Adobe Employee
December 1, 2011
JF Software
Inspiring
December 1, 2011

Doesn't help me at all, no.