yarek
yarek

Reputation: 12044

flex: how do embed fonts in spark and mx?

My flex (4.5) application uses MX and Spark components. I want to embed Arial fonts and I a mgetting crazy: it works for either Spark components, either for MX components but never for both.

Sometimes some components just diseappear, or both are bold etc !

<?xml version="1.0" encoding="utf-8"?><mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" width="100%" height="100%"  layout="absolute" xmlns:s="library://ns.adobe.com/flex/spark">
<mx:Style>
    @namespace mx "library://ns.adobe.com/flex/mx";
    @namespace s "library://ns.adobe.com/flex/spark";
    @font-face { 
        src: url("c:/windows/fonts/arial.ttf"); 
        fontFamily: Arial; 
        fontWeight:normal;
        embed-as-cff: true;

    }
    @font-face {
        src: local("Arial");
        font-weight: normal;
        fontFamily: Arial;
        fontStyle:normal;
        embed-as-cff:false;         
    }
    @font-face {
        src: local("Arial");
        fontFamily: Arial;
        fontWeight:bold;
        fontStyle: normal;
        embed-as-cff:false;
    }
</mx:Style>
<mx:Label x="177" y="160" text="mx|normal"/>
<mx:Label x="177" y="201" fontWeight="bold" text="mx|bold"/>    
<s:Label x="182" y="235" text="S|normal"/>
<s:Label x="182" y="278" text="S|bold" fontWeight="bold"/>

Upvotes: 1

Views: 2000

Answers (1)

RIAstar
RIAstar

Reputation: 11912

Remove the font styles that say: embedAsCFF: false and add the following:

mx|global {
    textFieldClass: ClassReference("mx.core.UIFTETextField");
}

This will force all mx components that render text to use a textfield that can handle the CFF embedded fonts. It also has the advantage that you don't have to embed the same font twice.

Upvotes: 2

Related Questions