Copy link to clipboard
Copied
Hi, all
Is there a property to handle font favorites in illustrator script ?
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
...
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?
Copy link to clipboard
Copied
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!