6 Replies Latest reply on Dec 12, 2010 6:35 AM by real_ideveloper

    FontFamily in spark Flex 4

    real_ideveloper

      Hi.

       

      For my current project I am using spark components from the Flex 4.

      I have some embedded fonts which I include with a css-file.

      When I try to set the fontFamily, for example for the spark.component.textarea, the textarea displays System Arial font.

      When I change the compiler to Flex 4.1 the spark component displays the embedded font.

       

      Is it a bug in the version 4.0 or do I make something wrong?

       

      <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" xmlns:ns="library://ns.adobe.com/flex/spark">
        <mx:Style source="fonts.css"/>
      
        <ns:TextArea fontLookup="embeddedCFF" fontFamily="TimesItalic" heightInLines="NaN" widthInChars="NaN" x="300" y="50" text="Embedded Font"/>
          
      </mx:Application>
      

       

      CSS:

       

      @font-face {
              src: url("Families/TIMES_IT.TTF");
              fontFamily: TimesItalic;
              embedAsCFF: true;
              }
      
        • 1. Re: FontFamily in spark Flex 4
          Peter deHaan Level 4

          Possibly.

          There were a number of bug fixes between the Flex 4.0 and 4.1 releases (as well as an upgrade TLF).

           

          This seems to work as expected in Flex Hero:

           

          <?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">

              <s:controlBarContent>

                  <s:Button id="sdkVer" initialize="sdkVer.label = mx_internal::VERSION;" click="System.setClipboard(sdkVer.label);" />

              </s:controlBarContent>

           

              <fx:Style source="fonts.css"/>

           

              <s:TextArea text="Embedded Font"

                          fontFamily="TimesItalic"

                          fontStyle="italic"

                          x="300" y="50" />

           

          </s:Application>

          And my fonts.css is as follows:
          /* CSS file */
          @namespace s "library://ns.adobe.com/flex/spark";
          @namespace mx "library://ns.adobe.com/flex/mx";
          @font-face {
              src: url("C:/Windows/Fonts/times.ttf");
              fontFamily: TimesItalic;
          }
          @font-face {
              src: url("C:/Windows/Fonts/timesi.ttf");
              fontFamily: TimesItalic;
              fontStyle: italic;
          }
          Peter

          • 2. Re: FontFamily in spark Flex 4
            real_ideveloper Level 1

            Hi Peter.

            I tried you code. It does not work.

             

            It only works with the version 4.1. I have noticed that the loading time of the version 4.5 is faster, therefore I would like to use the version 4.5.

             

            Here is a screenshot of my comparing results

             

            embeddedFont.jpg

             

            The player versions are 10.0 (on the left) and 10.1 (on the right).

             

            What am I doing wrong?

            • 3. Re: FontFamily in spark Flex 4
              Peter deHaan Level 4

              Are you using the code I posted, or is your code somewhat different? If your code is different, can you post your entire small test case here and I can take a look.

              I was using the latest public Hero release (4.5.0.18623 from Tue Nov 30, 2010, and a beta version of Flash Player 10.2).

               

              Peter

              • 4. Re: FontFamily in spark Flex 4
                real_ideveloper Level 1

                Hi Peter.

                 

                I have taken your code, which you posted above.

                (Copy-Paste)

                 

                I will try it again today with the newer version of SDK.

                • 5. Re: FontFamily in spark Flex 4
                  Peter deHaan Level 4

                  What if you try upgrading to the Flash Player 10.2 beta?

                   

                  Peter

                  • 6. Re: FontFamily in spark Flex 4
                    real_ideveloper Level 1

                    Hi, Peter.

                     

                    It works with the new Hero version (4.5.0.18623) and the Player verion 10!!!!!

                    The loadin time is fast.

                     

                    But now I have a new Problem.

                    Assigning a new font family for the mx:Label results in an empty text of the label.

                    (I know I could take the s:Label and it would be working, but why does it not work with the mx:Label? Is mx-package deprecated?)

                     

                    <?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">

                        <s:controlBarContent>

                             <s:Button id="sdkVer" initialize="sdkVer.label =  mx_internal::VERSION;" click="System.setClipboard(sdkVer.label);" />

                        </s:controlBarContent>

                     

                        <fx:Style source="fonts.css"/>

                     

                        <s:TextArea text="Embedded Font"

                                    fontFamily="TimesItalic"

                                    fontStyle="italic"

                                    x="300" y="50" />

                     

                    <mx:Lable text="Lable Text" "TimesItalic"

                                    fontStyle="italic"

                                    y="300" y = "200"/>

                     

                    </s:Application>