2 Replies Latest reply on Aug 25, 2011 4:04 PM by Budkin76

    Using a font embedded swf in mxml

    Budkin76 Level 1

      Hello,

       

      We need to load in fonts at runtime due to localization needs. I've got this working in an AS3 project in Flex by embedding the font in a class and then loading that swf into another class and registering the font.

       

       

       

      What I need now is to be able to use that font class in MXML components like a spark label. I can't seem to get it to work though. I've tried referencing the swf in a style sheet, then making a style class in the CSS using that font like this:

       

      /* Embed.css */

       

      @font-face {

           src: url("_Arial.swf");

           fontFamily: "_Arial";

      }

       

      .genericTextArial

      {

      font-family: "_Arial";

      fontSize: 40;

      color: #000000;

      }

       

      Then in the MXML I have this:

       

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

       

           

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

           

           <s:Label text="This should display my embedded text." width="100%" styleName="genericTextArial"/>

           

      </s:Application>

       

      However I can't seem to get it to render. I've also tried the method of embedding the font in a text field in Flash Professional and loading in that swf and it doesn't work either. Am I missing a parameter or just going about this the wrong way?