Using CS2, is there not a quicker way to get the postscript name of a font than looping over all installed fonts and comparing names?
function gimmePostScriptFontName(f)
{
numOfFonts = app.fonts.length;
for (var i = 0, numOfFonts; i < numOfFonts; i++)
{
fnt = app.fonts[i].name;
if (f == fnt)
{
return app.fonts[i].postScriptName;
}
}
}
For future reference:
var myLayer = app.activeDocument.layers[0]; // top layer
// just make sure it's a text layer :)
var myFont = app.fonts.getByName(myLayer.textItem.font).name;
alert(myFont);