Skip to main content
Inspiring
April 25, 2010
Question

Embedded Fonts Problem

  • April 25, 2010
  • 1 reply
  • 1435 views

Hi,

I'm trying to emebed some fonts, but I haven't been able to get it working.

I'm using this code in a style sheet:

     @11220649-face{
            src: url("../assets/fonts/lsans.ttf");
            fontFamily: LucidaSansV;
            embedAsCFF:true;
        }
       
        @11220649-face{
            src: url("../assets/fonts/ROCK.TTF");
            fontFamily: RockwellV;
            embedAsCFF:true;
        }
       
        @11220649-face{
            src: url("../assets/fonts/times.ttf");
            fontFamily: TimesV;
            embedAsCFF:true;
        }

if I use the fontFamily in Spark labes, it works:


<s:Label text="Some text here" fontSize="40" fontFamily="LucidaSansV" />
<s:Label text="Some text here" fontSize="40" fontFamily="TimesV" />
<s:Label text="Some text here" fontSize="40" fontFamily="RockwellV" />

But if I use it like this, doesn't work either:

var cf:TextLayoutFormat = new TextLayoutFormat();
cf.fontFamily = 'TimesV';
cf.fontLookup = flash.text.engine.FontLookup.EMBEDDED_CFF;

cf.renderingMode = flash.text.engine.RenderingMode.CFF;

Aslo, I've tried using formatted text, like "<p fontSize='32'><span fontFamily='LucidaSansV'>ABCDEFGHIJKLM 18</span></p>" with no luck.

The behaivor should be oposite, if I declare embedAsCFF:true;, I should be ablke to use it in FTE components and embedAsCFF:false with the old MX components. what am I missing?

tks.

This topic has been closed for replies.

1 reply

oscar7878Author
Inspiring
April 25, 2010

I wanted to update the post just in case someone has the same problem.

I created a ActionScript Library with a class for each font I need and drop the swc to the project where I need to use the fonts.

In the project, I just need to do this before using the font:

new ArialFont();

Each class looks like this:


package
{
    import flash.text.Font;

    public class ArialFont
    {

        [Embed(source='assets/fonts/arial.ttf', fontName='ArialV', mimeType='application/x-font', embedAsCFF="true")]
        private static var ArialF:Class;
       
        [Embed(source='assets/fonts/arialbd.ttf', fontName='ArialV', fontWeight="bold", mimeType='application/x-font', embedAsCFF="true")]
        private static var ArialBoldF:Class;
       
        [Embed(source='assets/fonts/ariali.ttf', fontName='ArialV', fontStyle="italic", mimeType='application/x-font', embedAsCFF="true")]
        private static var ArialItalicF:Class;
       
        [Embed(source='assets/fonts/arialbi.ttf', fontName='ArialV', fontWeight="bold", fontStyle="italic", mimeType='application/x-font', embedAsCFF="true")]
        private static var ArialBoldItalicF:Class;

       
        public function ArialFont()
        {
            Font.registerFont( ArialF );
            Font.registerFont( ArialBoldF );
            Font.registerFont( ArialItalicF );
            Font.registerFont( ArialBoldItalicF );

        }
    }
}

Hope this helps someone.

A_Shiyaz
Known Participant
May 3, 2010

Thanks Oscar, that was helpful. You have saved me some time

Regards,

Shiyaz