10 Replies Latest reply: Aug 16, 2012 6:26 AM by sinious RSS

    Fonts Embed issue

    kiranemc2 Community Member

      while iam embedding in air application through flash IDE. iam not able to see the text from where i get numarical numbers. can some one help me regarding this.

       

        Mystring : <font face="arial" size="20"><b> this is audioTranscript M01L01T01ST01P07P  </b></font>

       

      View string: this is audioTranscript Sl

        • 1. Re: Fonts Embed issue
          Ned Murphy CommunityMVP

          What process are you following to embed the font?

          • 2. Re: Fonts Embed issue
            kiranemc2 Community Member

            Hi Sir

             

            Sorry no fonts Displaying. I dont why it is comming .

            I am using below  process (code)  please let me know where i did mistake  below are the points.

             

            • I have created new Air file with flash IDE and i have loaded fonts.swf
            • after fonts loading completed then i have loaded page1.swf
            • when i   trace(Font.enumerateFonts()[k].fontName)  // Arial, Kruti Dev 010

                                   

             

            Fonts embed Process:

            1. fonts.swf Code

             

            1. Font.registerFont(hindifont)
            2. Font.registerFont(arial)

            hindifont, arial in library

             

            Doccument class code :

             

            package

            {

              import flash.display.Loader;

              import flash.events.Event;

              import flash.net.URLRequest;

              import flash.display.MovieClip;

              import flash.text.Font;

              public class Main extends MovieClip

              {

              private var fonstsURL:String = "fonts.swf";

              private var pagesURL:String = "page1.swf";

              public function Main()

              {

              // constructor code

              loadFonts();

              }

              private function loadFonts()

              {

              var ldr:Loader=new Loader();

            ldr.contentLoaderInfo.addEventListener(Event.COMPLETE,loadfile);

              ldr.load(new URLRequest(fonstsURL));

              }

              private function loadfile(e)

              {

              loadpages();

              }

             

             

              private function loadpages()

              {

              for (var k in Font.enumerateFonts())

              {

            trace(Font.enumerateFonts()[k].fontName);

              }

              var ldr:Loader=new Loader();

            ldr.contentLoaderInfo.addEventListener(Event.COMPLETE,pagesLoaded);

              ldr.load(new URLRequest(pagesURL));

              this.addChild(ldr);

              }

              private function pagesLoaded(e)

              {

              }

              }

            }

             

             

             

            Page1.swf code

            //dynamic textfield in stage

            labelText1.htmlText=str

            labelText1.embedFonts=true

            labelText1.wordWrap=true

            • 3. Re: Fonts Embed issue
              lalitha subramanian

              When your textfield is on stage you can embed the font easily, select the textfield and go to that property and click the embed option there you can see select the character range.you select numerals option then it will display correctly.(This embed option you can get only in cs5,cs5.5 and cs6 not in cs4)

              • 4. Re: Fonts Embed issue
                kiranemc2 Community Member

                Thank's for your reply,

                 

                It is easy for me to embed all the fonts in one fla file, but the problem is I will have multiple fla's for multiple pages. it is be difficult to embed all the fonts in all the files and the size of the swf file will also be increased. I will change the text with different font through xml file at the run time. So, I am trying to load the swf file at the beginning where I have all the fonts embedded.

                • 5. Re: Fonts Embed issue
                  dmeN Community Member

                  You should not need to use registerFont, at least I've not needed it. In order to use an embedded font, you should only need to make a Font object out of it, then use that in a TextFormat. Here's what I do:

                   

                  import flash.text.Font;

                  import flash.utils.getDefinitionByName;

                   

                   

                  var fontClass:Class = getDefinitionByName("libraryFontLinkageName") as Class;

                  var theFont:Font = new fontClass() as Font;

                   

                  var texFormat:TextFormat = new TextFormat();

                  textFormat.font = theFont.fontName;

                   

                  myField.defaultTextFormat = textFormat;

                  • 6. Re: Fonts Embed issue
                    sinious CommunityMVP

                    kiranemc2 wrote:

                     

                    Mystring : <font face="arial" size="20"><b> this is audioTranscript M01L01T01ST01P07P  </b></font>

                     

                    You're bolding the font. This can often trigger havoc. You need to embed a font in regular, bold and italic (3 separate fonts and linkages) if you want to do things like that.

                     

                    I suggest you set your linkage names to something other than a built-in font name. Arial is on every machine in existence. Setting embedFonts=true isn't enough to be clear to the machine which font to use. Use names that do not exist as system fonts like:

                     

                    ArialRegular

                    ArialBold

                    ArialItalic

                    etc...

                     

                    Then instead of using a <b> bold tag, do this:

                    <font face="ArialBold" size="20">this is audioTranscript M01L01T01ST01P07P</font>

                    • 7. Re: Fonts Embed issue
                      kiranemc2 Community Member

                      i followed the steps which you mentioned. But it has given default font name(arial). if we give the same font name then it is showing nornally.

                      but i tried "arialBold" for Bold text. then it is showing empty.

                       

                      what should i do in this case.

                       

                      thanks in advance

                      • 8. Re: Fonts Embed issue
                        sinious CommunityMVP

                        A font is embedded as a Class so it should always start with an uppercase letter. That aside, are you using any fonts other than Arial? If not you really don't need to be going through all of this.

                         

                        I'd swoop back and ask yourself, do you really want to embed a font that every computer and device already has? Try removing the embedded Arial font and don't set embedFont=true. Still set the TextFields AntiAliasType.ADVANCED however. Then just use the proper font name and it should use your computer or devices font directly which is much higher performance, especially on mobile devices. You can also use your bold tag again as you were.

                         

                        <font face="Arial" size="20"><b>this is audioTranscript M01L01T01ST01P07P</b></font>

                         

                        A TextFormat object will accept the device fonts name as a string too of course:

                         

                        myTextField.defaultTextFormat = new TextFormat("Arial",20,0x0,true); // device font Arial, size 20, black, bolded

                        • 9. Re: Fonts Embed issue
                          kiranemc2 Community Member

                          I missed one major thing in my previous question, we are providing elearning courses for different local languages, so that we need different font faces,

                          please let me know if there any alternate for this. 

                          • 10. Re: Fonts Embed issue
                            sinious CommunityMVP

                            Simply make the font face a variable so you can change it to a font that's supported by other languages. If you're doing online training where the user needs to load your app over the Internet then this is typically a good practice.

                             

                            I've had the unfortunate luck of having clients who both want a very specific non-standard font that needed Traditional and Simple Chinese. The font increased the initial download by 18MB. I'm not happy doing things like this, especially when the app is a promotional experience about a product. A user may sit through your download if it's an online e-learning course but not really for product advertising.

                             

                            Try device fonts you know to contain the glyphs in the style you choose for any particular language first. Arial actually contains them all but it doesn't look like a "good font" to other cultures. I ended up doing this more and more and I typically do it with 13-15 languages. Only Asian and Cyrillic fonts are the bane of my existence. Luckily good old Arial will handle almost all your Latin.