Using embedded font in StyleSheet

508 views Asked by At

I'm trying to use the font I've embedded in TextField.htmlText text. I've used a piece of code found here to check the font names of the embedded fonts:

var fonts:Array = Font.enumerateFonts();
for (var i:int = 0; i < fonts.length; i++) 
{
var font:Font = (fonts[i] as Font)
trace(font.fontName, ",", font.fontStyle, ",", font.fontType)
}  

I've used the output fontName ('Trebuchet MS') in my StyleSheet:

_linkStyling = new StyleSheet();
_linkStyling.parseCSS('a { color: #' + _colourScheme.link.toString(16) + '; }'); // _colourScheme returns various uint colours
_linkStyling.parseCSS('a:hover { color: #' + _colourScheme.linkOver.toString(16) + '; }');
_linkStyling.parseCSS('p { font-family: "Trebuchet MS"; }');
_linkStyling.parseCSS('p { font-size: 16px; }');

but that makes no difference. The text being set to the TextField.htmlText property is in 'p' tags.
The font-size styling also has no effect.
It can't be because the .parseCSSs are on separate lines because the 'a:hover' styling works. Any help, much appreciated!

1

There are 1 answers

3
Marcela On BEST ANSWER

You need to combine your two p selectors because you are overwriting your first definition with the second (the one containing the size).

This works:

_linkStyling.parseCSS('p { font-size: 16px; font-family: "Trebuchet MS";}');