Indesign Script to test Character Variants in Indesign

Indesign is capable to access any opentype feature from a script.
Here a script to test a font with Character Variant in Indesign:

if( app.selection.length ) // do we have a selection?
if( app.selection[0].hasOwnProperty("opentypeFeatures") )
if( app.selection[0].opentypeFeatures.toSource()=="[[\"cv01\", 1]]" )
    app.selection[0].opentypeFeatures = []; // reset to nothing
else
   app.selection[0].opentypeFeatures=[["cv01",1]];



Copy this text to text editor and save wit jsx extension, ex: CV01.jsx.
Copy the file to indesign scripts directory.
Usually this directory in windows is: C:\Program Files\Adobe\Adobe InDesign 2021\Scripts\Scripts Panel\Scripts.
This is a simple script and You need to change the number of the "CVxx features" for every diferent "CVxx" and save with a different name.
This script is for "Character Variant 01"
Clicking one time to CVxx "On" and another to CVxx "Off".
I have test this feature using source code pro: https://fonts.google.com/specimen/Source+Sans+Pro#standard-style
I know this is a simple script but please tell me what do you think?
Regards
Sami

Comments