2 Replies Latest reply on Mar 1, 2010 12:12 AM by Patel Bharat

    Font family on TextRange content !!

    Patel Bharat Level 2

      Hi Friends,

       

      I am facing one problem regarding apply Embed Font on TextRange content. I want to apply an embeded font on the selected text of a TextArea.

       

      Thanks In Advance

       

      =====================================

      Below is the sample code.

      =====================================

       

      <?xml version="1.0" encoding="utf-8"?>

      <mx:Application

       

       

      xmlns:mx="http://www.adobe.com/2006/mxml" layout="horizontal">

       

       

      <mx:Style>

       

       

      @font-face {

       

       

       

       

       

       

      src: url("/assets/KAP001.TTF");

       

      fontFamily: KAP001;

       

      advancedAntiAliasing: true;

      }

       

       

       

       

       

      </mx:Style>

       

       

      <mx:Script>

      <![CDATA[

       

       

      import mx.controls.textClasses.TextRange;

       

      private function onChangeFontClick(event:MouseEvent ):void

      {

       

       

      var _textRange:TextRange = new TextRange(txt, true, 0, 5);

      _textRange.fontSize = 10

      _textRange.fontFamily =

      "KAP001";

       

      //txt.setStyle("fontFamily","KAP001");

      }

      ]]>

       

       

      </mx:Script>

       

       

       

      <mx:TextArea width="400" id="txt" text="THIS IS TEST TEXT" fontSize="20" />

       

       

      <mx:Button label="CHANGE FONT FAMILY" click="onChangeFontClick(event)"/>

       

      </mx:Application>