embedding font in Flex CSS locally with a installed font works, but w/ url to refer to a ttf font file doesn't
I'm trying to embed a font in my project by using url("font.ttf") rather than local("Font Name"), but it doesn't seem to pick it up. The font in question is called "Gotham Bold". When i view the details of the font, the font weight is regular, however when i use local("Gotham Bold") in the css i have to specify fontWeight: bold or else it wont pick it up. But when I use url("folder\Gotham-Bold.ttf"), and specify fontWeight: bold, i开发者_如何转开发t says that font weight is not found for that TTF. If i remove the fontweight, there's no errors, but the font is not applied to the text. any ideas please?
Thanks
I use this code to embed a custom Font in my Flex App. I placed this code directly in mx:Application.
I have found two different file one for the normal weight and one for the bold.
<mx:Style>
/*S!_DCB__.TTF*/
@font-face{
src: url("S!_DC__.TTF");
fontFamily: DAX2;
font-weight:normal;
}
@font-face{
src: url("S!_DCB__.TTF");
fontFamily: DAX2;
font-weight:bold;
}
</mx:Style>
After that i just put the DAX2 font name in the component.
Claudio.
Fonts may not actually being embedded in your code. One more thing, You must embed distinct font for different styles. as per say, If you want to embed Arial with Normal and Bold style, you have to embed Arial twice with different class names given.
To embed font use
[Embed(source = "path of font file.ttf", fontName = "Gotham-Regular", mimeType="application/x-font-truetype")]
private var fontGothamRegular:Class; //Class name which would be used to register font
//To register font
Font.registerFont(fontGothamRegular);
//For embedding bold style of same font
[Embed(source = "path of font file.ttf", fontWeight="Bold", fontName = "Gotham-Bold", mimeType="application/x-font-truetype")]
private var fontGothamBold:Class;
Font.registerFont(fontGothamBold);
精彩评论