Hi, here is some code that can set the font of a text range. When run as shown, it sets the font of the currently-selected text to "Blackoak Std", if that font exists on your system. Hope this helps.
Russ
var doc = app.ActiveDoc;
var textRange = doc.TextSelection;
applyFontToTextRange(doc, textRange, "Blackoak Std");
function applyFontToTextRange(doc, textRange, fontName)
{
if(!doc.ObjectValid())
{
alert("Invalid document. Cannot continue.");
return;
}
var fontFamilyNames = app.FontFamilyNames;
for(var i = 0; i < fontFamilyNames.length; i++)
{
if(fontFamilyNames == fontName) break;
}
if(i == fontFamilyNames.length)
{
alert("Could not find the specified font, " + fontName);
return;
}
props = AllocatePropVals(1);
props[0].propIdent.num = Constants.FP_FontFamily;
props[0].propVal.valType = Constants.FT_Integer;
props[0].propVal.ival = i;
doc.SetTextProps(textRange, props);
}