Skip navigation
Currently Being Moderated

Need some support with syntax from FDK to ExtendScript : Getting FontFamily

Mar 29, 2013 4:20 AM

Tags: #fontfamily #sdk_to_extendscript

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[i], "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[i]

}

 

 

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

 
Replies
  • Currently Being Moderated
    Mar 29, 2013 4:40 AM   in reply to wokoman1234

    The equivalent to the FDK's (and FrameScript's) Session is the app. So this gives you the Font Family Names:

     

    app.FontFamilyNames

     

    Rick

     
    |
    Mark as:
  • Currently Being Moderated
    Mar 29, 2013 4:50 AM   in reply to wokoman1234

    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]);
    
     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points