'flex에서 font 사용하기'에 해당되는 글 1건

  1. 2013.11.04 [펌] flex에서 font 사용하기 2
반응형

출처 : http://distress.tistory.com/18

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" creationComplete="init()"
 verticalScrollPolicy="off" horizontalScrollPolicy="off"
 fontSize="12" width="420" height="600">
<mx:Script>
 <![CDATA[
  import mx.collections.ArrayCollection;
  private var fontListAc:ArrayCollection;
  //Flex 에서 적용되는 폰트의 종류를 알아보도록 하자.
  //리스트에 나오는 폰트는 현재 시스템에 설치된 폰트일뿐...모두 사용가능한것은 아니다.
  //바뀌는것도 있고 아닌것도 있고....이걸 구별해서 적용 가능한 폰트만 쓸수있으면 좋겠는데....
  private function init():void{
   var allFonts:Array = Font.enumerateFonts(true);
   var text:String;

   fontListAc = new ArrayCollection();
   
   allFonts.sortOn('fontName', Array.CASEINSENSITIVE);
   for each(var font:Font in allFonts){
    fontListAc.addItem(font.fontName);
    //이 함수가 test_str 이 정상적으로 표시가능한지 아닌지 구별해 준다고는 나와있는데..
    //뭐 해봐도 항상 false 만 뱉어낸다. 사용을 잘못한건지....음....
    //font.hasGlyphs(test_str);
   }
   fontList.dataProvider = fontListAc;
  }
 ]]>
</mx:Script>
 <mx:TextArea id="sampleText" x="10" y="10" width="400" height="320">
  <mx:text>이 문장은 번역기일 뿐입니다.
  This statement is only a translation date.
  該聲明只是一個翻譯日期.
  この文は翻訳機である場合のみです.
  ★☆●◎◆□▲▽→♤♧⊙◈▤☎☜
  </mx:text>
 </mx:TextArea>
 <mx:Text x="339" y="340" text="fontSize:" width="70" textAlign="center" fontSize="13"/>
 <mx:NumericStepper id="fontSize" minimum="5" maximum="100" value="25"
  change="sampleText.setStyle('fontSize', fontSize.value);" creationComplete="sampleText.setStyle('fontSize', fontSize.value);"
  x="339" y="370" width="70" textAlign="center"/>
 <mx:List id="fontList" x="10" y="338" width="321" height="250"
  change="sampleText.setStyle('fontFamily', fontListAc.getItemAt(fontList.selectedIndex))"/>
</mx:Application>

 

Posted by 1010