0 Replies Latest reply on Jul 30, 2009 4:54 AM by planck_length

    Unable to draw Unicode chars whose value is > 0xFFFF

    planck_length

      I'm trying to draw a character from a Unicode font whose value is 0x1d11e (this is the treble clef character from the Sonata font).

       

      I read here that I have to convert Unicode chars > 0xFFFF to using surrogate pairs, but this doesn't seem to work.

       

      Here's my code:

       

          [Embed(source='C:/WINDOWS/Fonts/SonataStd.otf', fontName="Sonata__", mimeType="application/x-font")]
            private var font1:Class;


          public function draw():void {
            var txt:TextField = new TextField();
            var fmt:TextFormat = new TextFormat("Sonata__", 40);
            var clefChar:uint = 0x1d11e

            var p1:uint = (((clefChar - 0x10000) >> 10) & 0x3ff) + 0xd800;
            var p2:uint = ((clefChar - 0x10000) & 0x3ff ) + 0xdc00;


            txt.text = String.fromCharCode(p1, p2);


            txt.setTextFormat(fmt);
            txt.embedFonts = true;
            addChild(txt);

       

      Thanks