Skip navigation
Currently Being Moderated

How can I embed arabic Font in Flash?

Nov 12, 2009 9:18 AM

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?

 
Replies
  • Currently Being Moderated
    Dec 1, 2011 1:55 AM   in reply to frankie*

    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.

     
    |
    Mark as:
  • Currently Being Moderated
    Dec 1, 2011 2:02 AM   in reply to JcFx.Eu
     
    |
    Mark as:
  • Currently Being Moderated
    Dec 1, 2011 2:07 AM   in reply to Jin-Huang

    Doesn't help me at all, no.

     
    |
    Mark as:
  • Currently Being Moderated
    Dec 1, 2011 2:10 AM   in reply to JcFx.Eu

    My flex-config <languages/> node is commented out, and looks like this:

     

    <!-- Defines ranges that can be used across multiple font-face declarations. -->

              <!-- See flash-unicode-table.xml for more examples. -->

              <!-- not set -->

              <!--

              <languages>

                  <language-range>

                      <lang>englishRange</lang>

                      <range>U+0020-007E</range>

                  </language-range>

              </languages>

              -->

     

    Does this node being commented out mean all characters are embedded, or is there a default range?

     
    |
    Mark as:
  • Currently Being Moderated
    Dec 1, 2011 6:23 PM   in reply to frankie*

    hi frankie*,

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

    http://actionscriptexamples.com/2008/11/24/embedding-fonts-in-flash-cs 4-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.

     
    |
    Mark as:
  • Currently Being Moderated
    Dec 24, 2011 9:49 PM   in reply to frankie*

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

     

    Message was edited by: arabicode

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points