Copy link to clipboard
Copied
Hi, all
Is there a property to handle font favorites in illustrator script ?
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')) ;
})() ;
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?
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.
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? 🥲
Copy link to clipboard
Copied
Could you try to write it yourself once and show us the code here?