2 Replies Latest reply on Jul 14, 2009 6:42 AM by Pāvils Jurjāns

    Run-time textfields with embedded unicode text

    Pāvils Jurjāns



      Now this has killed a lot of time for me. If you help me to solve
      this, your reward will be to know that someone has not lost his


      FLA source: http://www.jurjans.lv/flash/EmbeddedUnicodeWoes.zip


      [ActionScript code]
      var testStr = "ĀČĒĢĪĶĻŅŠŪŽāčēģīķļņšūž_ABC";


      // Set up the design-time textfield
      tf1.text = testStr;
      tf2.text = testStr;


      // Set up the run-time textfield
      this.createTextField("rtf", 0, 10, 130, 200, 30);
      var rtf = this["rtf"];
      rtf.selectable = false;
      rtf.multiline = true;
      rtf.html = false;
      var textFormat = new TextFormat("Font01", 14);
      rtf.embedFonts = true;
      rtf.text = testStr;




      So, firstly, I work in CS4. Secondly, I am stuck with AS2 for this
      project, because there is too much code in old classes to rewrite in


      What I am trying to achieve, is: add new texfield to stage at runtime,
      and set it up to display text (that is sure to contain also some
      unicode characters) with embedded font outlines (because a special
      font is used, and it might be needed to rotate the field).


      How I attempted to achieve this:
      - Added a new font symbol "Font01" to Library
      - Created a textfield on stage (instance name "tf1"), set up to use
      the Font01, and to embed outlines of basic Latin character set, plus a
      range of special unicode characters.
      - Created another textfield on stage (instance name "tf2"), set up to
      use the "Courier New", and to embed outlines of basic Latin character
      set, plus a range of special unicode characters.
      - Added ActionScript to the first frame (see above)


      What I have achieved:
      - The text in both textfields tf1 and tf2 can be changed to contain
      both non-unicode and unicode characters. It works nicely.
      - However, the run-time added textfield does not show up any
      characters (neither unicode nor basic).


      I would appreciate any hints what I might be doing wrong. I guess it
      will be "easy" to fix for non-unicode chars, there must be something I
      am plainly missing. However, I hope that the unicode characters would
      also be right there, I am so tired of all those unicode
      incompatibilities in different kind of software, for years.



        • 1. Re: Run-time textfields with embedded unicode text
          kglad Adobe Community Professional & MVP

          you need to assign a linkage id to your embedded font and you need to assign the font property of textFormat to be that linkage id.


          addendum:  you need to use setNewTextFormat() if you're assigning text after you assign a textformat.

          1 person found this helpful
          • 2. Re: Run-time textfields with embedded unicode text
            Pāvils Jurjāns Level 1



            Giving the linkage Id and setting the rtf.text before rtf.setTextFormat(textFormat) did the trick for getting the non-unicode characters work. The ZIPped testcase FLA online is updated now.


            However, unicode chars still do not show up, only the non-unicode are displayed.


            Strangely, the other textbox with embedded chars (Courier New in the testcase) is not messed up. However, if I'd go and change the font in the font symbol "Font01" from Arial to Courier New, that spoils the textbox whose font setting is literary "Courier New", not "Font01".


            I am not sure why this happens. I've put the textbox on stage, and in its embedded characters settings the necessary embedded chars are specified. The fact that they are interpreted correctly (at least for textboxes with other than symbol fonts) is confirmed by the test of Courier New textbox -- all the special chars display correctly. Maybe those extra characters are just ignored, not embedded for the font symbols?


            [Added] I've discovered that if I set the run-time textfield font to "Courier New" (that is, a font that is not specified as a font symbol), then also the run-time texfield displays the unicode chars. So, I can be almost happy, unless I want the run-time textfield be in the font that is specified in the library.


            Case still not fully resolved...