Copy link to clipboard
Copied
Hi there, I am using some scripts to traverse my text and add tags to specific characters when they use a given font. This works fine if the PlatformName is known, but every now and a while these seem to be not set. I therefore want to do the following : If no FontPlatformName get the FontFamily instead, but I'm struggling to get it working as the scripting references are a bit limited on covering conversion.
This is what's in the fdk (simplified for my needs) :
families = F_ApiGetStrings(0, FV_SessionId, FP_FontFamilyNames);
for (i=0; i < families.len; i++)
if(F_StrIEqual(families.val, "myFont")
/* Do something*/
) break;
But I can't get it working on extendscript
What I have now is something like below :
var doc = app.ActiveDoc;
var families = Constants.FP_FontFamilyNames.GetStrings;
for (var i = 0; i < families.length; i += 1)
{
// alert fontname of families.val
}
But I'm doing something wrong as it fails on my for loop. Anybody that can help getting the syntax correct ?
Thanks in advance already
Copy link to clipboard
Copied
The equivalent to the FDK's (and FrameScript's) Session is the app. So this gives you the Font Family Names:
app.FontFamilyNames
Rick
Copy link to clipboard
Copied
The FontFamily property is an index into the list of FontFamilyNames. For example, you can tell the font that is used by the paragraph containing the insertion point with this:
#target framemaker
var doc = app.ActiveDoc;
var pgf = doc.TextSelection.beg.obj;
alert (app.FontFamilyNames[pgf.FontFamily]);