Skip to main content
Known Participant
December 13, 2024
Answered

Is there a property to handle font favorites in illustrator script ?

  • December 13, 2024
  • 2 replies
  • 814 views

Hi, all

 

Is there a property to handle font favorites in illustrator script ?

 
I want to write a script that stores the selected favorite fonts in an array and
creates a new text frame for a specific letter with the favorite fonts list .
Is that possible?
Correct answer sttk3

Favorite fonts are stored in preferences and can be retrieved from there. But unfortunately, it seems the info is only updated when Illustrator is restarted.

/**
  * @File Get favorite families on Illustrator
  * @3653945.0.0
  * @7111211 sttk3.com
*/

(function() {
  var pref = app.preferences ;
  var favoriteFamilyNames = [] ;
  var favoriteFamilyCount = pref.getIntegerPreference('plugin/FavoriteFamily/FavoriteFamilyCount') ;
  for(var i = 0 ; i < favoriteFamilyCount ; i++) {
    var favoriteFamilyName = pref.getStringPreference('plugin/FavoriteFamily/' + i + '/Name') ;
    favoriteFamilyNames.push(favoriteFamilyName) ;
  }

  alert(favoriteFamilyNames.join('\n')) ;
})() ;

2 replies

Participant
May 17, 2025

In Adobe Illustrator scripting, there is no direct property or method to handle "favorite fonts" like you see in the Illustrator UI.

However, you can work with fonts using the app.textFonts collection. For example, you can list all fonts and manually create your own list of favorites in your script.

Here’s a simple idea:
You can create an array of your favorite font names and check against it when applying fonts.

Example:
var favoriteFonts = ["Arial", "Myriad Pro", "Roboto"];

var selectedFont = favoriteFonts[0]; // Pick the first favorite

textItem.textRange.characterAttributes.textFont = app.textFonts.getByName(selectedFont);

So, while Illustrator doesn’t give access to its "Favorites" section, you can manage your own list in the script.

 

sttk3Correct answer
Legend
December 13, 2024

Favorite fonts are stored in preferences and can be retrieved from there. But unfortunately, it seems the info is only updated when Illustrator is restarted.

/**
  * @File Get favorite families on Illustrator
  * @3653945.0.0
  * @7111211 sttk3.com
*/

(function() {
  var pref = app.preferences ;
  var favoriteFamilyNames = [] ;
  var favoriteFamilyCount = pref.getIntegerPreference('plugin/FavoriteFamily/FavoriteFamilyCount') ;
  for(var i = 0 ; i < favoriteFamilyCount ; i++) {
    var favoriteFamilyName = pref.getStringPreference('plugin/FavoriteFamily/' + i + '/Name') ;
    favoriteFamilyNames.push(favoriteFamilyName) ;
  }

  alert(favoriteFamilyNames.join('\n')) ;
})() ;
raldraldAuthor
Known Participant
December 13, 2024

Thank you so much @sttk3 !

I'm really amazed that it's possible.

Could you help me more by modifying lists in a new textFrame instead of an alert statement?

 

var t = doc.textFrames.add();
t.contents = favoriteFamilyNames.join('\n');
 
I added this instead of alert, but it doesn't work. How can I fix it?
 
And one more question, please.
Is it possible to save and retrieve several favorites lists separately?
Like grep queries in InDesign.
Legend
December 14, 2024

Not tried it, but it seems not to work because the doc is not defined. Let's add it.

var doc = app.documents[0] ;

 

> Is it possible to save and retrieve several favorites lists separately?

This probably means you want to save and load them as presets; it might be possible to rewrite the preferences with setStringPreference, but it will only be applied when Illustrator is restarted. I guess this is unsatisfactory as a feature.