2 Replies Latest reply on Jun 28, 2007 2:18 PM by erictomlinson

    USING EMBEDDED FONTS WITH DYNAMIC TEXT FIELDS

    erictomlinson
      I'm dying here trying to figure this out for days.
      Here's the scenario:

      1) External script.as file dynamically imported to loader.swf file that creates a textfield (createTextField)
      2) Content for the text field should be provided by an XML file
      3) Content styled by external css file
      4) Fonts need to be embedded so as to apply anti-alias

      I can get the XML & CSS to apply to the text field, but can't get the content to use the embedded font. It usually comes back "undefined" if the embedded font works. Otherwise, when I comment out the embed font, the content work, but of course, not the anti-aliasing. Ugh. I've tried doing all kinds of forum searches, but nothing has clarified this for me. I'm intermediate at AS and this is something new to me. Any help will be GREATLY appreciated and I will send good juju your way.
      Here's a sampling of some of the script I have been using:

      ACTIONSCRIPT:

      mf = new TextFormat();
      mf.font = "arial_font";
      Stage.scaleMode = "noScale";

      this.createTextField("news_txt", 99, 50, 50, 450, 300);
      news_txt.border = true;
      news_txt.html = true;
      news_txt.multiline = true;
      news_txt.wordWrap = true;
      news_txt.embedFonts = true;
      news_txt.autoSize = true;
      news_txt.setNewTextFormat(mf);


      // Load CSS
      var styles:TextField.StyleSheet = new TextField.StyleSheet();
      styles.load("heading.css");

      // Load XML apply to headingText
      var banner_xml:XML = new XML();
      banner_xml.ignoreWhite = true;
      banner_xml.onLoad = function(success:Boolean):Void {
      if (success) {
      news_txt.styleSheet = styles;
      news_txt.text = banner_xml;
      } else {
      trace("Error loading XML.");
      }
      };
      banner_xml.load("heading.xml");



      XML:

      <story>
      <title></title>
      <mainBody>
      <heading>Heading Text</heading>
      <tagline>Clever tagline goes here</tagline>
      </mainBody>
      </story>



      CSS:

      heading {
      color:#000000;
      font-family:"Franklin Gothic Book", Arial, sans-serif;
      display: block;

      font-size: 50pt;
      margin: 0px;
      padding: 0px;
      letter-spacing: -5px;
      }

      tagline {
      color:#000000;
      font-size: 20pt;
      font-family:"Franklin Gothic Book", Arial, sans-serif;
      display: block;
      font-weight: bold;
      }

      So, if I turn off the xml/css and use htmlText to create content for the text field, the text uses the embedded font and is anti-aliased. If I keep the xml/css but comment out embedFonts, then the content works but is not anti-aliased. I need both of these to work at the same time. PLEASE HELP!!

      peace
        • 1. Re: FOR THE LOVE OF GOD, CAN SOMEONE HELP ME?
          Level 7
          erictomlinson,

          > So, if I turn off the xml/css and use htmlText to create
          > content for the text field, the text uses the embedded
          > font and is anti-aliased.

          I'm with ya. Presumably, then there's a font symbol in your Library,
          right? And its Linkage identifier is "arial_font"?

          > If I keep the xml/css but comment out embedFonts, then
          > the content works but is not anti-aliased.

          That's because your CSS calls for Franklin Gothic Book, which hasn't
          been imported into your Library as a font symbol (at least, you haven't said
          it has).

          > I need both of these to work at the same time.

          Give Franklin Gothic Book a Linkage identifier, and use that name in
          your CSS.


          David Stiller
          Adobe Community Expert
          Dev blog, http://www.quip.net/blog/
          "Luck is the residue of good design."


          • 2. Re: FOR THE LOVE OF GOD, CAN SOMEONE HELP ME?
            erictomlinson Level 1
            Thanks! It's the little things that get you in something like this. I had embedded/linked the font in the library, but it was Arial not Franklin... duh... I also noticed that the css has to be specific and only call the font embedded (ie, no sans-serif, bold, etc) or it won't work.
            Thanks again David!