Adobe Extending Flash Professional CS5 User Manual
Page 304
282
EXTENDING FLASH PROFESSIONAL
fontItem object
Last updated 5/2/2011
function embedFontSymbol(symbolName, fontName, includeVariants) {
var doc = fl.getDocumentDOM();
if (doc) {
// look up the item. if it exists, delete it.
var index = doc.library.findItemIndex(symbolName);
if (index > -1)
doc.library.deleteItem(symbolName);
// make a new font symbol in the library
doc.library.addNewItem('font', symbolName);
// look up the symbol by its name
var index = doc.library.findItemIndex(symbolName);
if (index > -1) {
// get the item from the library and set the attributes of interest
var fontObj = doc.library.items[index];
fontObj.isDefineFont4Symbol = true;
fontObj.font = fontName;
fontObj.bold = false;
fontObj.italic = false;
fontObj.embedVariantGlyphs = includeVariants;
// this is what forces the font into the SWF stream
fontObj.linkageExportForAS = true;
fontObj.linkageExportInFirstFrame = true;
}
}
}
The following function displays all the font symbols in the Output panel.
function dumpFontSymbols()
{
var doc = fl.getDocumentDOM();
if (doc) {
var items = doc.library.items;
fl.trace("items length = " + items.length);
var i;
for(i=0; i
fl.trace("itemType = " + item.itemType);
if (item.itemType == 'font') {
fl.trace("name = " + item.name);
fl.trace("DF4 symbol = " + item.isDefineFont4Symbol);
fl.trace("font = " + item.font);
}
}
}
}
See also
,