-
Notifications
You must be signed in to change notification settings - Fork 13
Open
Labels
Description
Usecase:
load an external stylesheet. Then get a list of all fontNames used in stylesheet so the fonts can also be loaded from individual, external, files. Optionally mapping fontNames to fontFileNames.
example ( once css has been loaded into a FStyleSheet):
var len:int = styleSheet.styleNames.length;
var fonts:Array = [];
for (var i:int = 0; i < len; i ++)
{
var style:IStyle = styleSheet.getStyle(styleSheet.styleNames[i]);
// create temp textfeild to get access to textFormat
var tf:TextField = new TextField();
TextFieldUtil.applyStyle(tf, style);
// only add fonts if specifed in css
if (style['font'] || style['font-face'] || style['fontFace'] || style['font-family'] || style['fontFamily'] )
{
fonts.push(tf.defaultTextFormat.font );
}
}
// remove duplicates
fonts = fonts.filter(function(e, i, fonts) {return fonts.indexOf(e) == i}, this);
trace(fonts);
Reactions are currently unavailable