Scripting Variable Fonts in Illustrator
Copy link to clipboard
Copied
Hy there,
How can I set the parameters for a variable font?
The TextFont.axisVector is 'Read Only'
Greetings, Akiem
Explore related tutorials & articles
Copy link to clipboard
Copied
by definition, you cannot set read only properties.
I'm not familiar with the axisVector property. what is it and what does it do? What are you trying to change about the font?
Copy link to clipboard
Copied
Since CC 2018 Illustrator is supporting Variable Fonts, a new version of OpenType. See here:
What You Can Do with Variable Fonts in Illustrator CC | Adobe Blog
So to get a specific weight, you are just choosing one with the slider provided by the character panel.
And after doing this, I can use within a script:
var appliedFont = selection.characters[0].textFont
$.writeln(appliedFont.axisVector)
I get an array with two values (because the font I am using has two axes): 190, 1000
And when I do this:
$.writeln(selection.appliedFont.characters[1].textFont)
I get: DuosInlinePro_190INLI_1000wght
Which actually means: Currently the font DuosInlinePro is used with the variable parameters:
190 for the INLI axis and 1000 for the weight axis
So how can I set the variable font axis by a script???
Copy link to clipboard
Copied
There is no way by a script at the moment. This feature is to young for the old Illu DOM.
But you can do the following:
Create a new Action set. Give it a name eg Skript-Test2
Create actions and set there several values for axisVektor[1] eg 120, the next 240 and so on …
Give these actions the name what they do eg axisVektor-120
Call the action for the case you want by your script
app.doScript("axisVektor-120","Skript-Test2")
Have fun
Copy link to clipboard
Copied
Ugh...
That's strange.
Are you 100% sure about that?
Copy link to clipboard
Copied
up to 99%, sorry.
(but the method I described before - works)
Copy link to clipboard
Copied
after almost 4 years of scripting illustrator.. i can attest to the fact that there is NOTHING strange about the Illustrator JavaScript API. Because if EVERYTHING is strange, then nothing is strange.
Much of the API appears to be have created in segments by different developers who had no contact with one another. Especially the app.executeMenuCommand() API.... The formatting of available arguments available for that method range from lowercase, to uppercase, to titlecase, to camelCase to title case with spaces... And then after that.. they neglected to provide ANY documentation for the functionality. they literally created a near impossible puzzle, then gave no clues....
There are no surprises when it comes to scripting illustrator anymore. i simply expect the worst, and exhibit bemused surprise when something works as expected.
Copy link to clipboard
Copied
to quote Jack Reacher:
Hope for the best, plan for the worst.
Copy link to clipboard
Copied
OK, 99% aint 100%.
There seems to be a solution... through the SDK.
Once I set the dynamic font name (like Font_190wdth_1000wght) beforehand through the SDK, I can use this within JSX.
So what I need would be a small simple plugin to do this, and then communicate to this plugin from jsx...
Anybody experience with this?
Copy link to clipboard
Copied
You can push plugin from ExtendScript using sendScriptMessage method.
Copy link to clipboard
Copied
There seems to be a solution... through the SDK.
=> Can you share this?
Copy link to clipboard
Copied
Hi all,
Are there any updates regarding this? It would be really handy to make the axisVector property editable, it will open up many interesting possibilities for using Variable Fonts in scripts.
Copy link to clipboard
Copied
2020: Can you set axisVector by Script?
Copy link to clipboard
Copied
Sorry, but OMV Illustrator 24 Type Library says:
axisVector is still (Read Only)
Copy link to clipboard
Copied
Has anyone found a way to adjust the axes in variable type via script yet? It's 2022 and the axisVector property is still read-only. I thought maybe I could create a new TextFont object but that doesn't work either since there is no constructor, apparently.
I've just made a post on UserVoice about this, so please go there and vote if you want variable font support in Illustrator scripts.

