2012-08-02 4 views
0

UITextField에 포함 된 글꼴 (Flex 4.6)을 사용하려고합니다. Windows에 등록 된 글꼴을 사용하는 한 올바르게 작동하지만 등록되지 않은 글꼴의 경우 UITextField는 TimesRoman (또는 이와 비슷한)을 기본값으로 사용합니다.Flex 4.6 : 포함 된 글꼴이 TextField에 적용되지 않았습니다.

글꼴이 포함되어 있는지 확인하면 , True를 반환합니다 (FlexGlobals.topLevelApplication.systemManager.isFontFaceEmbedded (txtFormatCoda))

그래서 나는 무엇이 누락 되었습니까?

아래 코드에서 Kredit 글꼴을 Windows 글꼴에 추가하면 UI 텍스트 필드가 Kredit 글꼴로 표시되지만 Windows/글꼴 디렉터리에서 제거하면 필드가 TimesNewRoman (기본 글꼴)에 나타납니다. 코드 아래

<?xml version="1.0" encoding="utf-8"?> 
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009" 
       xmlns:s="library://ns.adobe.com/flex/spark" 
       xmlns:mx="library://ns.adobe.com/flex/mx" minWidth="955" minHeight="600" creationComplete="onComplete()"> 
    <s:Group id="TextCanvas" x="121" y="97" width="474" height="800"> 
    </s:Group> 
    <fx:Style> 
     @font-face { 
      src: url("fonts/KREDIT1.TTF"); 
      fontFamily: Kredit; 
      embed-as-cff:false; 
      advancedAntiAliasing:true; 
     } 
    </fx:Style> 
    <fx:Script>  
     import mx.core.FlexGlobals; 
     import mx.core.UIComponent; 
     import mx.core.UITextField; 
     import mx.core.UITextFormat; 


     public function onComplete():void{ 
      var txtFldCoda:UITextField = new UITextField(); 
      var txtFormatCoda:UITextFormat = new UITextFormat(this.systemManager); 
      var compCoda:UIComponent = new UIComponent(); 
      compCoda.addChild(txtFldCoda); 
      txtFldCoda.embedFonts=true;   
      txtFldCoda.width=300; 
      txtFormatCoda.size=33; 
      TextCanvas.addElement(compCoda); 
      txtFldCoda.text="Testing Kredit"; 
      txtFormatCoda.font= "Kredit"; 
      txtFormatCoda.color="0x0ff345"; 
      var b2:Boolean = FlexGlobals.topLevelApplication.systemManager.isFontFaceEmbedded(txtFormatCoda); 
      if(b2==false){ 
       trace("not embedded: " + txtFormatCoda.font); 
      } 
      txtFldCoda.defaultTextFormat= txtFormatCoda;//note that setTextFormat must be after setting the text 
      txtFldCoda.setTextFormat(txtFormatCoda);//note that setTextFormat must be after setting the text 
      txtFldCoda.x=0; 
      txtFldCoda.y=100;   
     }  
    </fx:Script> 
</s:Application> 

답변

0

당신을 도울 수 있습니다 - 내가 한 줄 수정 스타일 태그를 댓글을 달았 ... 사실이 나를 위해 일

<?xml version="1.0" encoding="utf-8"?> 
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009" 
       xmlns:s="library://ns.adobe.com/flex/spark" 
       xmlns:mx="library://ns.adobe.com/flex/mx" minWidth="955" minHeight="600" creationComplete="onComplete()" 
       > 
    <s:Group id="TextCanvas" x="121" y="97" width="474" height="800"> 
    </s:Group> 
    <fx:Style> 
     @namespace s "library://ns.adobe.com/flex/spark"; 
     @namespace mx "library://ns.adobe.com/flex/mx"; 

     @font-face { 
      src: url("fonts/KREDIT1.TTF"); 
      fontFamily: KREDIT1; 
      embed-as-cff: false; 
      advancedAntiAliasing:true; 
     } 

     s|Application 
     { 
      fontFamily:KREDIT1; 
     } 
    </fx:Style> 
    <fx:Script>  
     import mx.core.FlexGlobals; 
     import mx.core.UIComponent; 
     import mx.core.UITextField; 
     import mx.core.UITextFormat; 

     public function onComplete():void{ 
      var txtFldCoda:UITextField = new UITextField(); 
      var txtFormatCoda:UITextFormat = new UITextFormat(this.systemManager); 
      var compCoda:UIComponent = new UIComponent(); 
      compCoda.addChild(txtFldCoda); 
      txtFldCoda.embedFonts=true;   
      txtFldCoda.width=300; 
      txtFormatCoda.size=33; 
      TextCanvas.addElement(compCoda); 
      txtFldCoda.text="Testing Kredit"; 
      //txtFormatCoda.font= "Kredit"; 
      txtFormatCoda.color="0x0ff345"; 
      var b2:Boolean = FlexGlobals.topLevelApplication.systemManager.isFontFaceEmbedded(txtFormatCoda); 
      if(b2==false){ 
       trace("not embedded: " + txtFormatCoda.font); 
      } 
      txtFldCoda.defaultTextFormat= txtFormatCoda;//note that setTextFormat must be after setting the text 
      txtFldCoda.setTextFormat(txtFormatCoda);//note that setTextFormat must be after setting the text 
      txtFldCoda.x=0; 
      txtFldCoda.y=100;   
     }  
    </fx:Script> 
</s:Application> 
+0

감사합니다. Mahesh 다음과 같이 해결책을 시도하지 못했습니다. –

1

감사합니다 마헤시

을 :

var comp:UIComponent = new UIComponent(); 
comp.setStyle('fontFamily', fontName);      

기본적으로이 UITextField의 부모 인 UIComponent에 setStyle을 수행해야했습니다. Adobe가이를 문서화하기를 바랍니다.

관련 문제