Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

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

Explorer ,
Dec 13, 2024 Dec 13, 2024

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?
TOPICS
Scripting
791
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Enthusiast , Dec 13, 2024 Dec 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
  * @Version 1.0.0
  * @author sttk3.com
*/

(function() {
  var pref = app.preferences ;
  var favoriteFamilyNames = [] ;
  var favoriteFamilyCount = pref.getIntegerPreference('plugin/FavoriteFamily/FavoriteFamilyCount') ;
  for(var i = 0 ; i < favoriteFamilyCount ; i++) {
    var favorite
...
Translate
Adobe
Enthusiast ,
Dec 13, 2024 Dec 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
  * @Version 1.0.0
  * @author 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')) ;
})() ;
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Dec 13, 2024 Dec 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.
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Dec 13, 2024 Dec 13, 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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Dec 13, 2024 Dec 13, 2024

Thanks so much @sttk3 

It works!

I forgot that statement as you said.😅

 

I'm a newbie to illustrator script, so

I searched the forums and found the path to preferences.

~/Library/Preferences/

 

In that folder, I found

- Adobe Illustrator 25 Settings

- Adobe Illustrator 26 Settings

- Adobe Illustrator 27 Settings

 

I also found this in that Adobe Illustrator 27 Settings/en_GB folder.

- Adobe Illustrator Prefs

 

But I don't know how to save and load settings.

var variable =  pref.setStringPreference(key, value);

How should I write key and value?

Could you help me more please? 🥲

 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Dec 15, 2024 Dec 15, 2024

Could you try to write it yourself once and show us the code here?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Dec 15, 2024 Dec 15, 2024

Thanks for reply @sttk3 .

 

First, I deselected my favorite fonts, which were probably over 80,

re-favorited only the 5 fonts, restarted Illustrator,

and ran the script after writing just this sentence, 

var favorite = app.preferences.setStringPreference('plugin/FavoriteFamily/', 0);

 

Restarted Illustrator again, ran the script you told me,

and the 5 new favorite fonts and 29 additional fonts were displayed.

 

Although all the newly favorited fonts have been added,

it doesn't seem like the first selected favorite fonts have been deleted completely in the preferences.

 

Since there are so many fonts, I just wanted to manage them by design style. 

As you said, this method doesn't seem satisfoctory as a feature.

 

I think I should start studying scriptUI.

Maybe it will help me make my ideas more concrete.

 

I really appreciate your help, sttk3. 

Have a good day! 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
May 17, 2025 May 17, 2025
LATEST

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.

 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines