Copy link to clipboard
Copied
How to get a kerning value(distance between two characters) using javascript?
Copy link to clipboard
Copied
@Raykor11:
It would be best to move that question to scripting forum for InDesign.
But one solution could be:
1. Read out the property kerningValue from the insertion point between the two characters:
//if two characters are selected:
var _kerningValue = app.selection[0].insertionPoints[1].kerningValue;
2. Measure the exact distance between the characters, so you can decide if you want to increase or decrease the distance
//Two characters are selected:
var _twoCharacters = app.selection[0];
var _charLeft = _twoCharacters.characters[0];
var _charRight = _twoCharacters.characters[1];
var _temp1 = _charLeft.createOutlines(false) //false = does NOT delete original
var _bounds1 = _temp1[0].visibleBounds;
var _temp2 = _charRight.createOutlines(false) //false = does NOT delete original
var _bounds2 = _temp2[0].visibleBounds;
var _distance = _bounds2[1]-_bounds1[3];
_temp1[0].remove();
_temp2[0].remove();
alert("Distance between: "+_distance);
Be aware that there are a lot of other factors that will apply to character distance if you change the kerning value (like tracking, kerning method, composer, desiredGlyphScaling, desiredLetterSpacing, horizontalScale … just to mention a few), especially if the paragraph justification is set to JUSTIFIED or FULLY_JUSTIFIED.
Uwe
Copy link to clipboard
Copied
Copy link to clipboard
Copied
Oh wait, Uwe already mentioned that 🙂
Find more inspiration, events, and resources on the new Adobe Community
Explore Now