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

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

Community Beginner ,
Dec 13, 2024 Dec 13, 2024

Copy link to clipboard

Copied

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

Views

138

Translate

Translate

Report

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

Community Expert , 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
...

Votes

Translate

Translate
Adobe
Community Expert ,
Dec 13, 2024 Dec 13, 2024

Copy link to clipboard

Copied

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')) ;
})() ;

Votes

Translate

Translate

Report

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 ,
Dec 13, 2024 Dec 13, 2024

Copy link to clipboard

Copied

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.

Votes

Translate

Translate

Report

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 Expert ,
Dec 13, 2024 Dec 13, 2024

Copy link to clipboard

Copied

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.

Votes

Translate

Translate

Report

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 ,
Dec 13, 2024 Dec 13, 2024

Copy link to clipboard

Copied

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? 🥲

 

Votes

Translate

Translate

Report

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 Expert ,
4 hours ago 4 hours ago

Copy link to clipboard

Copied

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

Votes

Translate

Translate

Report

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 ,
27m ago 27m ago

Copy link to clipboard

Copied

LATEST

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! 

Votes

Translate

Translate

Report

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