Copy link to clipboard
Copied
is it possible at all?
Hi @dolce5EC2, if you mean you want to set particular set(s) via a script, here is something I wrote to do that:
/**
* Shows how to set the OpenType Stylistic Sets.
* Notes: pass zero to set no stylistic sets.
* @discussion https://community.adobe.com/t5/illustrator-discussions/accessing-stylistic-alternates-by-scripting/m-p/13927994
*/
(function () {
var doc = app.activeDocument,
item = doc.selection[0];
if (
item == undefined
|| !item.hasOwnProperty('textR
...
Copy link to clipboard
Copied
If you write a script, you'd simply use stringFromCharcode() or another method to generate the required glyphs most of the time. Of course you'd have to know the underlying Unicode glyph IDs/ character codes.
Mylenium
Copy link to clipboard
Copied
Hi @dolce5EC2, if you mean you want to set particular set(s) via a script, here is something I wrote to do that:
/**
* Shows how to set the OpenType Stylistic Sets.
* Notes: pass zero to set no stylistic sets.
* @discussion https://community.adobe.com/t5/illustrator-discussions/accessing-stylistic-alternates-by-scripting/m-p/13927994
*/
(function () {
var doc = app.activeDocument,
item = doc.selection[0];
if (
item == undefined
|| !item.hasOwnProperty('textRange')
) {
alert('Please select a text frame and try again.');
return;
}
// example: activate stylistic sets 1 and 3
item.textRange.characterAttributes.stylisticSets = getStylisticSetNumberForSets(1, 3);
})();
/**
* Returns a number suitable for setting
* the stylisticSets property of characterAttributes.
* @author m1b
* @version 2023-07-11
* @param {Number} s1 ... sN - stylistic set numbers to activate.
* @returns {Number}
*/
function getStylisticSetNumberForSets(/* pass set numbers as arguments */) {
var n = 0;
for (var i = 0; i < arguments.length; i++)
if (arguments[i] > 0)
n += 1 << (arguments[i] - 1);
return n;
};
See if this works for you. It's a quick script, so might need some testing!
- Mark
Copy link to clipboard
Copied
a m a z i n g - I was about to lose hope!
thanks a bunch!
Whilst I am using just one style, getStylisticSetNumberForSets seems really cryptical, it compacts several into one by offsetting bytes by their size, right?
Copy link to clipboard
Copied
^several ints
Copy link to clipboard
Copied
Yeah, it's a bit weird because the value for characterAttributes.stylisticSets is a single decimal Integer that encodes any number of bits. So if you want sets 1 and 3, then imagine the binary number 101 and each place value represents a set, so the right-hand 1 means set 1 is ON, then the zero in next place means set 2 is OFF, then the left-most 1 means set 3 is ON. So then you pass the value 5 to the property (because 101 in decimal is 5).
I just made the function to for convenience. If you can visualise the binary places okay, then you don't need it.
- Mark