Skip to main content
lordalexworks
Participant
June 14, 2012
Question

Problem with StyleableTextField, the fontFamily is being ignored

  • June 14, 2012
  • 1 reply
  • 1666 views

Hello everyone,

We seem to be having an issue with StyleableTextField.  The font does not work.  The field is not picking up the font-family property.

Anyone has had this issue?

Kind regards.

Sample code here:

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

<s:View xmlns:fx="http://ns.adobe.com/mxml/2009"

                    xmlns:s="library://ns.adobe.com/flex/spark" title="HomeView"   creationComplete="initView()">

 

  <fx:Script>

                    <![CDATA[

                              import com.lordalexworks.ReallyStyleableTextField;

                              import mx.collections.ArrayCollection;

 

                              import spark.components.supportClasses.StyleableTextField;

                              import spark.skins.mobile.*

 

 

 

                              private function initView():void

                              {

                                 var styles:String = "a { color: #33CCFF; } a:hover { color: #3366CC; text-decoration: underline; } p{fontFamily:primer;}";

               var myStyleSheet:StyleSheet = new StyleSheet();

               myStyleSheet.parseCSS(styles);           

  

               var messageDisplay:StyleableTextField = StyleableTextField(createInFontContext(ReallyStyleableTextField));

               messageDisplay.htmlText = "<p>Click <a href=\'http://www.adobe.com\'>here</a></p>";

               messageDisplay.setStyle('skinClass',spark.skins.mobile.TextInputSkin);

               messageDisplay.styleSheet = myStyleSheet;

              

               var messageDisplay2:StyleableTextField = StyleableTextField(createInFontContext(ReallyStyleableTextField));

               messageDisplay2.text = "Click Here";

 

 

               vg.addElement(messageDisplay);

               vg.addElement(messageDisplay2);

 

                              }

                    ]]>

  </fx:Script>

          <s:VGroup id="vg" y="100"/>

</s:View>

This topic has been closed for replies.

1 reply

Inspiring
June 21, 2012

Hi,

StyleableTextField only supports embedded fonts with embedAsCFF=false.

For more information, see:

http://blogs.adobe.com/jasonsj/2011/08/embedding-fonts-in-flex-mobile-projects.html

The code:

var messageDisplay3:StyleableTextField = StyleableTextField(createInFontContext(StyleableTextField));

messageDisplay3.editable = false;

messageDisplay3.styleDeclaration = styleManager.getStyleDeclaration(".myFont");

messageDisplay3.styleSheet = myStyleSheet;

messageDisplay3.htmlText = "<p>Click <a href=\'http://www.adobe.com\'>here</a></p>";

In your css:

@font-face

{

    src: url("/assets/comic.ttf");

    fontFamily: myComic;

    embedAsCFF: false;

}

.myFont

{

    fontFamily: myComic;   

}

Philippe