Embedding fonts in textFields

I am trying to embed a font in my flex project that loads sprites within UI components
I load a series of swf files.  The first ones being a class that registers fonts
I have embedded each font in a separate class definition that extends FontAsset.
Each font is embedded this way
[Embed(    fontWeight="bold",
            fontName="_TRAJAN PRO",
            source="/../libs/fonts/TrajanPro-Bold.otf",
            advancedAntiAliasing="true",
            mimeType="application/x-font-truetype",
            embedAsCFF="false")]
    public class TrajanBold extends FontAsset
When its loaded I do Font.registerFont(loadedswf.trajanBoldClass) (trajanBold returning me the class TrajanBold)
when i look at all the registered fonts, _TRAJAN PRO is in the list, therefore it should be fine
Then, when i create a sprite in a UIComponent, i set the text format for all text fields to their embedded name (bold or regular, i have both embedded).
The font simply won't display, everything gets displayed as Times New Roman still.  I'm running out of options.  I've tried embedding using fx:Style @font-face, but that doesn't work either.
        static public function initializeFonts():void {
            _fontList = [];
            _fontList = Font.enumerateFonts();
        static public function setLocaleContainer(container:DisplayObjectContainer):void {
            if (_fontList == null)
                initializeFonts();
            var num:uint = container.numChildren;
            for (var i:uint = 0; i < num; i++) {
                var o:DisplayObject = container.getChildAt(i);
                if (o is TextField && (o as TextField).styleSheet == null) {
                    try {
                        var t:TextField = o as TextField
                        var f:TextFormat = t.defaultTextFormat;
                        var fontName:String = f.font;
                        var embedName:String = "_" + fontName.toUpperCase();
                         for each (var font:Font in _fontList) {
                            if (font.fontName.toUpperCase() == embedName) {
                                //var s:String = t.text;
                                f.font = font.fontName;
                                //t.embedFonts = true;
                                t.setTextFormat(f);
                                t.defaultTextFormat = f;
                                //t.text = s;
                                trace(t.name, embedName, "fontName: ", fontName, "new font", t.defaultTextFormat.font);
                                break;
                    } catch (e:Error) {
                        trace("couldn't embed font",    e.message);
                } else if (o is DisplayObjectContainer) {
                    setLocaleContainer(o as DisplayObjectContainer);
If i add the embed font = true line, then everything disappears.
Any help would be greatly appreciated!
I used to have the fonts embedded within the text field.  But i just added the dynamic embedding of fonts to reduce file size and repetition for all my screens.

You set fontWeight="true" on the embed tag, but you didn't set bold=true on
the TextFormat.

Similar Messages

  • How to show embedded and not embedded font in TextField at the same time?

    Hi guys,
    I need to show embedded and not embedded font in my TextField at the same time. TextField has embedFonts = true and isHTML = true.
    Any ideas?

    Two different font won't work for me because I need to support all UTF glyphs.
    Idea with two TextFields one on top of other seems to be working. The only problem I see here - if half string is Chinese and hand Latin - then it will be quite problematic to properly position text...

  • Show multiple embedded fonts into an html textfield

    Hi to everyone,
    I'm using Flash CS5 , Actionscript 3.0 and export fo Flash Plaer 10.
    I create a class, myHtmlText.as, that builds a basic TextField.
    I create an empty file myHtmlText.fla
    I embedded two fonts inside the myHtmlText.fla: "Ghotam Light" and "Ghotam Book"; I selected all characters for each font and exported for actionscript with the following linkage name: "GhotamBook" and "GhotamLight"
    I wish to use the fonts embedded, in the TextField using htmlText, like this:
    var tf:TextField = createTextField(10, 10, 400, 22);
         tf.htmlText = '<p><font face="GhotamBook">Lorem ipsum dolor sit amet.</font></p>';
         //tf.embedFonts = true;
    where createTextField function is:
    private function createTextField(x:Number, y:Number, width:Number, height:Number):TextField
         var result:TextField = new TextField();
         result.x = x;
          result.y = y;
         result.width = width;
          result.height = height;
         addChild(result);
          return result;
    but it does not work; the text is not displayed; If I use .text instead fo .htmlText, the latin text is displayed with a system font.
    How can I do?

    GhotamLight and GhotamBook should be class names and you'll need to import the needed classes to use:
    var tf:TextField = createTextField(10, 10, 400, 22,"GotamBook");
         tf.htmlText = '<p>Lorem ipsum dolor sit amet.</p>';
    private function createTextField(x:Number, y:Number, width:Number, height:Number, fontS:String):TextField
         var result:TextField = new TextField();
         result.x = x;
          result.y = y;
         result.width = width;
          result.height = height;
         addChild(result);
    var ClassRef:Class=Class(getDefinitionByName(fontS));
    var font:Font = new ClassRef();
    var tfor:TextFormat=new TextFormat();
    tfor.font=font.fontName;
    result.embedFonts=true;
    result.defaultFormat=tfor;
          return result;

  • Textfields Reverting From Embedded Font

    Mac OSX 10.6.6
    Flash CS5
    Help!
    I have a fairly large (16.3 MB) FLA used to publish a SWC that contains an embedded DF3 font and ui elements.  All the textfields in the FLA are named, Classic/Dynamic instances.  Everything was going fine, until one day I opened the FLA and textfields all over the document had sporadically blanked out and replaced with distorted rectangles.  When I check what the font is set to, it's at the system default (Times).
    Resetting the textfield to my embedded font fixes it, althought the height/leading of the text needs to be adjusted.
    Here are the settings of an example textfield before:
    And how it is supposed to look:
    Now here is what happens to the dialog:
    And how it now looks:
    The first time this happened, I figured it was some kind of mistake I made and fixed all the textfields by hand.  Now this is the second time, and I am somewhat concerned that if this is a recurring issue, it will destroy my project.

    Thank you for your reply to my post last week, and my apologies for the delayed follow up.
    Whilst I was moving the registerFont code from the master SWF to the embedded one, I discovered an error in the code I had originally posted as a snippet here. For some reason the code I had moved to the external font SWF had lost its static modifier (should have been public static const embeddedFont:Class). That was the reason it was not present when I did the getDefinition on the class. After going back to the original code with the static keyword in place, all began to work properly.
    Thank you for your help and my apologies for the confusion.

  • Textfield which accepts multilingual characters with embedded fonts

    Hi all,
    I have a textfield where I can paste text from different languages with device fonts. Now, I want to input multi-ligual text with embedded fonts.
    I have embedded set of fonts, where I can input only english alphabets but not other languages.
    Is there a way to input any language characters with embedded fonts?
    Thank you.

    Thanks for your reply.
    I have embedded font as follows,
    [Embed(source="myfont.ttf", fontName='myfont', mimeType='application/x-font',embedAsCFF="false")]
    With this, I was able to apply this font for english.
    I have tried to paste " मैं कौन हूँ? " on a textfield. But I have not shown मैं कौन हूँ? text.
    And setting text programmatically did not work at all as
    textField.text = "मैं कौन हूँ?";
    If I do this with device fonts, every thing work fine but not with embedded fonts.
    Is there any thing wrong with my code while embedding font?

  • [svn:fx-trunk] 13076: It turns out that embedded fonts don' t clip when you shrink the height of a TextField so we' ll use masks in that case

    Revision: 13076
    Revision: 13076
    Author:   [email protected]
    Date:     2009-12-17 14:12:18 -0800 (Thu, 17 Dec 2009)
    Log Message:
    It turns out that embedded fonts don't clip when you shrink the height of a TextField so we'll use masks in that case
    QE Notes: None
    Doc Notes: None
    Bugs: SDK-24561
    Reviewer: Corey
    API Change: No
    Is noteworthy for integration: No
    tests: checkintests mustella/components/DataGrid
    Ticket Links:
        http://bugs.adobe.com/jira/browse/SDK-24561
    Modified Paths:
        flex/sdk/trunk/frameworks/projects/framework/src/mx/controls/dataGridClasses/DataGridBase .as

    Many of your points are totally legitimate.
    This one, however, is not:
    …To put it another way, the design of the site seems to be geared much more towards its regular users than those the site is supposedly trying to "help"…
    The design and management of the forums for more than five years have driven literally dozens of the most valuable contributors and "regulars" away from the forums—permanently.
    The only conclusion a prudent, reasonable person can draw from this state of affairs is that Adobe consciously and deliberately want to kill these forums by attrition—without a the PR hit they would otherwise take if they suddenly just shut them down.

  • Embedding fonts

    I'm a bit confused about embedding fonts. I have Flash CS5, which the help files say automatically embeds fonts.  But then the files go on to describe how to embed fonts, as if it needs to be done.  Do I need to embed fonts for files made with Flash CS5?
    The reason I ask is that when I replace text fonts in the template I'm modifying, the font changes its appearance, even though it says it is the same font as the one that came with the template.  The font is Tahoma regular 11pt.
    I tried embedding the Tahoma font, but I'm not sure I'm using the embed process correctly.  For one thing, it doesn't seem to have many fonts you can embed. Tahoma isn't listed.  When I enter text, it looks awful -- low resolutions, bad justification, ragged edges.
    I have a MacBook Pro running leopard.
    Than you for any help you can give.
    Best -- Catherine

    I'm new enough to Flash that I don't fully understand what you wrote above. Is a static textfield one in which letters remain stationary? And by the characters actually used in the specified textfield, do you mean the characters I enter or the ones already there? In other words, if I enter letters that weren't used for that field in the template (eg, my name instead of the generic name), will they all be embedded?
    I'm not sure embedding is the problem. I think I've done it. At least, Tahoma 11pt is now one of the fonts listed in the embed menu when I bring it up.
    But the font looks awful. It is supposedly the same one as in the template, but it doesn't look the same. The size, resolution, and spacing are all bad, whereas in the template they look nice. It doesn't happen until I actually go into an element in Flash and change text. It essentially seems to "reset" the text to a new font that looks bad and doesn't space out properly.
    Thanks for any help you can give me with this!
    Best -- Cat

  • Embedding Font in FB 4.7 AIR 3.9

    Hello,
    Is there a different way to embed fonts with Air 3.9 or FB 4.7? I've recently upgrading and I am experience tempremental results with embedding fonts.
    With FB 4.6 and Air 3.7 the following works fine -
    [Embed(source="/assets/fonts/SEGOEUIL.TTF", fontName="Segoe UI Light", mimeType="application/x-font-truetype")]
                        public static var EverydayFont:Class;
                                            var textFormat:TextFormat = new TextFormat();
                                            var mainFont:Font = new EverydayFont();
                                            textFormat.font = mainFont.fontName;
                                  var textfield:TextField = new TextField();
                                  textfield.mouseEnabled = false;
                                  textfield.selectable = false;
      textfield.defaultTextFormat = textFormat;
                                  textfield.multiline = false;
                                  textfield.border = true;
                                  textfield.embedFonts = embedFont;
                                  textfield.width = width;
      textfield.antiAliasType = antiAliasStyle;
                                  textfield.htmlText = label;
    However now with the latest versions the text box is just blank..??

    Ok, I'm gonna give you the code that worked for me when I was working on a project back than, cause I also had a simillar, if not the same (can't remember), problem.
    So here it goes:
    [Embed(source="SuchFont.ttf", fontName="SuchFont", mimeType="application/x-font", embedAsCFF="true")]
    public static var SuchFont:Class;
    var font:Font = new SuchFont;
    var format:TextFormat = new TextFormat(font.fontName, 20, 0xFFFFFF, true, null, null, null, null, TextAlign.LEFT);
    awesomeText = new TextField;
    awesomeText.defaultTextFormat = format;
    awesomeText.embedFonts = true;
    awesomeText.width = 158;
    awesomeText.height = 56;
    awesomeText.x = 106;
    awesomeText.y = 420;
    I think the trick is using embedAsCFF="true", but the issue here could be that you're using htmlText, have you tried with text?

  • Embedded fonts in CS3

    Hi!
    Since Flash8, i use a share library with embed fonts. These
    fonts (Century Gothic, MS UI Gothic, SimHei and Avant Garde) are
    used in a multi language training application showing 218 swf
    files.
    All my dynamic and imput textfields use these fonts as
    embedded font.
    These 4 fonts are duplicate in 4 "embedded fonts version" to
    cover regular, bold, italic and bold italic mode.
    So, i've 16 fonts in my share library as this method. for
    example :
    Font name with regular mode -> Font_Name__Normal
    Font name with bold mode -> Font_Name__Bold
    Font name with italicmode -> Font_Name__Italic
    Font name with bold and italic mode ->
    Font_Name__Bold_Italic
    Thanks to this method, i can set a font to my textfield
    according to the user language mode. For exemple Century Gothic is
    set for English users, MS UI Gothic for Japanese users and SimHei
    for Chinese users.
    I would like to migrate this Flash8 application to Flash CS3.
    So i open my library, rigth click and select new font. Next, select
    linkage and check "Export for runtime sharing".
    At this moment, a class name and a base class are set bu
    Flash CS3. I just write the URL like that "./fla_name.swf" and
    press ok button.
    A warning messagebox tells me "A definition for this class
    could not be found in the classpath, so one will be automatically
    generated in the swf file upon export."
    As i don't know what type of class i need to create (i just
    start AS3, never used it before), I accept and export my flash
    file.
    The Flash CS3 swf size is 18KB and the Flash 8 swf size is
    38MB. I conclude that my fonts are not embedded in my file.
    To conclude, how to do it with Flash CS3 ?
    thanks for your help

    > export to PDF so that the newsletter can be edited by others.
    That's not how PDF works. The purpose of exporting a PDF is to make a file that can be viewed and printed by others without the software or fonts used to create the original document. If you want people to edit your InDesign files, they'll need the same version of InDesign and legitimate licence to use the same fonts.
    Some font vendors are foolishly paranoid that people will use PDF to copy their fonts. It's not impossible, but it is difficult to extract a font from a PDF, and nearly useless if the font was embedded as a subset, which most PDF exports use. It is much easier to just copy the font file, and there's nothing preventing that. So blame the morons who sell that headline font and use another or convert it to outlines before PDFing.

  • Text display issues with htmlText, Embedded Font

    Hey All,
    I'm having an issue with the display of my hyperlinks in a
    textfield that is using embedded fonts. It offsets the hyperlinks
    to the left along the line they are on and the underline doesn't
    stretch all the way under the text field. The text display normally
    when I don't embed the font. For some reason I think this might
    have to do with the embedded character range so I opened it up.
    Does anyone know if this range is enough or if there are special
    characters flash uses that need to be embedded for their width even
    though they arn't displayed.
    Embedded range:
    [Embed(source='MyriadPro-Regular.otf', fontName='Myriad Pro',
    unicodeRange='U+0000-U+00fe')]
    Here's a link to the related code:
    http://pcpnew.privatepaste.com/a7eKaAuCTt

    Any ideas?

  • Embedding Font

    Hi,
                      I am embedding the font verdana to a textField. But its not getting worked. Also i have used the linkage to actionscript with the embedding font. The following code i have used for embedding. Can anybody help me by notifying the problem.
    /*var textFormat = new TextFormat();
        videoHolderMC.videoFrame.titleMC.titleTxt.embedFonts = true;
        textFormat.font = "verd";
        videoHolderMC.videoFrame.titleMC.titleTxt.setTextFormat(textFormat); */
        videoHolderMC.videoFrame.titleMC.titleTxt.text = title;
    Thanks and Regards,
                    Sreelash.

    if your text property has already been assigned to your textfield, use setTextFormat().  if you have you're going to assign the text property after assigning a textformat, use setNewTextFormat:
    var textFormat = new TextFormat();
        videoHolderMC.videoFrame.titleMC.titleTxt.embedFonts = true;
        textFormat.font = "verd";
        videoHolderMC.videoFrame.titleMC.titleTxt.setNewTextFormat(textFormat);
        videoHolderMC.videoFrame.titleMC.titleTxt.text = title;

  • ASDoc Error: Can't find Embedded Fonts?

    Hello,
    I am working in Flash CS5 Professional.
    On my stage, I have a dynamic TextField (my_txt) that uses a basic font, we'll say Arial. However, I want to format some of the text within the field with a custom font.
    I've embedded the font and exported to ActionScript as per Adobe's documentation, so now there is a Font item in my library named "MyCustomFont".
    The properties of the Font are -
    Class: MyCustomFont
    Base Class: flash.text.Font
    So, I've written a custom class file and I want to format the text, so the AS code within the class looks something like this:
    var my_font:Font = new MyCustomFont();
    var my_fmt:TextFormat = new TextFormat();
    my_fmt.font = my_font.fontName;
    my_txt.setTextFormat(my_fmt, 5, 15);
    This is pretty much like the examples I've seen in Adobe Docs. And, it works swimmingly when I test the movie; however, when I try to document the class using the ASDoc command line tool, I get the error:
    /Path/To/Project/And/The/Classes/SomeClass.as(221): col: 27 Error: Call to a possibly undefined method MyCustomFont.
                var my_font:Font = new MyCustomFont();
                                       ^
    I THINK I understand why ASDoc isn't finding the "method" MyCustomFont... the "method" is actually a Class contained in the Library within the .fla.
    So, is there a special argument I need to write in the ASDoc command line so that it will recognize embedded fonts?
    Or, am I supposed to use an "import" statement in SomeClass to import the embedded fonts somehow?
    Thanks!

    Ahhh...found the answer, do the same thing as I would do for any project that uses the built-in AS3 components (such as FLVPlayback):
    Put the Font items into a new .fla library and export a SWC.
    Then use the "-library-path /Path/to/SWC" argument in the ASDoc command line tool.

  • Embeding Fonts in AS3?

    Hello All,
    Publish Settings:
         Program:  Flash Professional CS6
            Target:  Flash Player 11.2
             Script:  Actionscript 3
    So I've created 2 new "Fonts" in my library in order to embed them into my Program. But when I run the program the font is not correct. Not sure
    what I'm doing wrong..?
    Below are the settings for the Embedded Fonts I included. There are 2 of them, which I created by right-clicking in the Library and clicking "New Font".
    The First Font:
                           Name:  "Font_Impact" 
              Char Ranges:  All
           Outline Format:  TLF(DF4)
                    Linkage:
                          -     Checked --->  Export for Actionscript
                          -     Checked --->  Export in Frame 1     (*Don't know if I needed this but it was selected by default..??)
                          -     Identifier --->  Greyed out....
                          -           Class --->  "Font_Impact"
                          - Case Class --->  "flash.text.Font"
                    Sharing:
                             *NOTHING SELECTED HERE (*This was the default so I left it as is)
    The seconds font has the exact same settings as the one above except:
                   Name:  "Font_Arial_Black"
                   Class:  "Font_Arial_Black"
    Now, what I did was I followed the instructions I found here at this link below:
              http://www.gaslightgames.co.uk/?p=163
    I think I did exactly what they did in their example but it didn't seem to work for me.
    My code where I'm trying to use this is:
    import flash.text.TextField;
    import flash.text.Font;
    import flash.text.TextFieldAutoSize;
    import flash.text.TextFormat;
    import fl.text.TLFTextField;
        var tickerTxtField:TLFTextField = new TLFTextField();
        //var tickerTxtField:TextField = new TextField();               //---> Tried this one too, same result
     var tickerTxtField_format:TextFormat;        //TextFormat
    var embedFont:Font_Arial_Black;               //Embedded Font 1
    var embedFont2:Font_Impact;                    //Embedded Font 2
    :............OTHER CODE............:
    embedFont = new Font_Arial_Black();
    embedFont2 = new Font_Impact();
    tickerTxtField_format = new TextFormat();
    tickerTxtField_format.font = embedFont.Font_Impact;
    tickerTxtField.text = "This is some sample Text To Display..."
    :............OTHER CODE............:
    I thought I was doing it correctly while I was following the instructions in the link I provided, but I can't seem to get it working.
    Can anyone tell what I'm NOT doing correctly? Any thoughts would be greatly appreciated...!
    Thanks in Advance,
    Matt

    Hi,
    I believe this line is the one causing problems:
    tickerTxtField_format.font = embedFont.Font_Impact;
    I guess it should be:
    tickerTxtField_format.font = embedFont.fontName;
    You actually want to use the property 'fontName' of the Font class, not substitute it for the name of your font.
    Hope it helps,
    Marcel

  • Apply html tag to embedded fonts

    hi,
    i have a textfield, i embedded fonts and assigned htmlText, i.e.
    txt.embedFonts = true;
    txt.htmlText      = '<b>my text </b>';
    but it doesnt aplly html tags because of embedFonts... i tried to make style using css but didnt work....
    is there any way to accomplish this?

    I dont know it its possible in this way. I would load a text file with the html and another with the style as described here  :
    http://www.republicofcode.com/tutorials/flash/as3css/

  • Embedded fonts & htmlText

    I'm trying to use embedded fonts in htmlText.  I've embedded the font in the Style tag:
         @font-face {
                src: url("someFont.ttf");
                fontFamily: "myFont";
    Now if I add it to a Text component like:
         <mx:Text id="myText" htmlText="This is some text" fontFamily="myFont" />
    it all works fine.  If I try to use the <font> tag inside the htmlText like
         myText.htmlText = "<font face='myFont'>This is some text</font>";
    with a component <mx:Text id="myText" /> it doesn't work.  If I use a font that's not embedded like
         myText.htmlText = "<font face=Georgia'>This is some text</font>";
    it works fine. So my question: how can I use the <font face=.. > tag in htmlText with embedded fonts?

    The underlying flash.text.TextField that actually does the display of text needs to have a flag flipped to tell it to use embedded fonts.  By specifying an embedded fontFamily in the MXML, the Flex framework figures out that it is embedded and flips that flag.
    If you want to use different font tags in your html, all of the fontFamily specified must be in the same SWF and all must be embedded.  Then specify in the MXML one of the embedded fonts and override that font with the font tags in the html.  You can also call setStyle("fontFamily", "myFont") before setting the htmlText in ActionScript.
    Alex Harui
    Flex SDK Developer
    Adobe Systems Inc.
    Blog: http://blogs.adobe.com/aharui

Maybe you are looking for

  • How do I change credit card info for apps?  It thinks I want to pay with paypal and I need to put in credit card info.

    I have a new iPhone 6 and want to buy apps.  When I click on "buy" some say they don't take PayPal and that I need to change my payment information.  ITunes seems to accept PayPal, but not the apps store.  Well, some do, some don't.  I still need to

  • How to backup more than one database using powershell

    I am Trying to backup more than one database using the following script but no luck. I want user to type on command line the database they want to backup, e.g all databases that have "test" at the front like test.inventory, test.sales so i want user

  • Oracle 11g RDBMS/ASM on StorageTek 2500 Series SAN

    Hi All: We are running in a data warehouse environment using extensive 11g RDBMS partiioning and parallel query servers on fairly good sized tables. All of the storage is ASM based with external RAID 0+1 redundancy configured on SUN StorageTEK SAN (

  • Object problem

    Hi All, Internal error "UDO" (-2025) occurred...are happened when I try to open a company database from the choose company window What could be the causes ? TIA Steve

  • I can't get rid of an application!

    I am trying to install Divx 6 and I keep getting this error:"You cannot install DivX 6 for Mac on this volume. A newer version of this software already exists on this volume." I've uninstalled it, tried throwing it into the trash and also deleted it