Copy link to clipboard
Copied
I want to fix 1mm space evenly in-between characters in indesign script like below e.g.
A n e e s h
Copy link to clipboard
Copied
Not sure Why you need script? Give positive tracking
Copy link to clipboard
Copied
Hi all,
see also this discussion that already is revolving mainly about the typographical aspects of the problem:
Even space inbetween characters
Aneesh012 Dec 3, 2016
https://forums.adobe.com/message/9178021#9178021
I gave a possible algorithm here:
10. Re: Even space inbetween characters
Laubender Dec 4, 2016 (in response to Aneesh012)
https://forums.adobe.com/message/9179320#9179320
I'm quoting myself and adding some advice by Rob Day in the same thread:
Changing the kerning to "optical" can be done by script. Also changing the tracking values. What you need is a handle on the shapes of the character pairs for measuring the distance. And that could be done by converting them to outlines as duplicates and measure from there.
Depending on the used font it could be a good starting point to set the kerning to "metric".
I think, the main problem is to find a good pair of glyphs—maybe "in" for a none-serif font—one could work with for the measuring.
For a serif font it's much harder.
Now to the scripting side:
A start would be to get rid of already individually kerned pairs by re-setting the kerning to "Optical".
Then use the prefered kerning method. Maybe we trust the font creator of doing better kerning than InDesign's algorithm "Optical", then we go for "Metrics". And later we change the tracking to our desired value.
/*
Example for a sample of:
Minion Pro Regular
justification = Justification.LEFT_ALIGN
pointSize = 12
horizontalScale = 100
verticalScale = 100
*/
// Text selected:
var myText = app.selection[0];
// Getting rid of arbitrary manual kerning in the selected text:
myText.kerningMethod = "$ID/Optical";
// Setting kerning to "Metrics"
myText.kerningMethod = "$ID/Metrics";
// Changing the tracking:
myText.tracking = 140;
To measure the distance of a pair of glyphs is a bit tricky.
One would think that a property like horizontalOffset of an insertionPoint could be used.
But that would lead to false assumptions, because it will add the side bearings of the adjacent glyph to the glyph's shape.
My suggestion: Convert a pair of characters to outline and measure the distance of their shapes.
The problem is to get the right pair that will be the right role model for all glyphs when doing the tracking.
How can a pair of two single characters be converted and the originals, the editable characters, will stay intact?
/*
Example:
Duplicate the first two characters of the selected text as outlines
Measure the distance between the glyphs.
Naive way.
*/
var text = app.selection[0];
var myResultArrayCharacterOne = text.characters[0].createOutlines(false);
var myResultArrayCharacterTwo = text.characters[1].createOutlines(false);
// Just testing:
for(var n=0;n<myResultArrayCharacterOne.length;n++)
{
$.writeln(n+"\t"+"geometricBounds:"+"\t"+myResultArrayCharacterOne
.geometricBounds); $.writeln(n+"\t"+"visibleBounds:"+"\t"+myResultArrayCharacterOne
.visibleBounds); };
// Just testing:
for(var n=0;n<myResultArrayCharacterTwo.length;n++)
{
$.writeln(n+"\t"+"geometricBounds:"+"\t"+myResultArrayCharacterTwo
.geometricBounds); $.writeln(n+"\t"+"visibleBounds:"+"\t"+myResultArrayCharacterTwo
.visibleBounds); };
// Measure distance in a naive way:
var distance = myResultArrayCharacterTwo[0].geometricBounds[1] - myResultArrayCharacterOne[0].geometricBounds[3];
// Get rid of the outlines if you want:
// myResultArrayCharacterOne[0].remove();
// myResultArrayCharacterTwo[0].remove();
$.writeln(distance);
alert(distance);
To find the right pair of glyphs—could be ".." as well—and to do the math now is up to the OP.
We did not see a sample of his font. Maybe there are individually sized glyphs? Maybe it's text on a path?
It's hard to make suggestions…
Regards,
Uwe
Copy link to clipboard
Copied
Hi Aneesh,
also explore the possibilities to change some paragraph or paragraphStyle properties if you want to implement this with paragraph.justification Justification.FULLY_JUSTIFIED, Justification.LEFT_JUSTIFIED or Justification.RIGHT_JUSTIFIED.
See what Willi Adelberger said:
5. Re: Even space inbetween characters
Willi Adelberger Dec 3, 2016 (in response to Aneesh012)
https://forums.adobe.com/message/9178135#9178135
Some properties to watch:
justification
kerningMethod
ligatures
// Set all values to 100
desiredGlyphScaling
maximumGlyphScaling
minimumGlyphScaling
// Test various values all set to the same value:
desiredLetterSpacing
maximumLetterSpacing
minimumLetterSpacing
// Set all values to one value depending on the found best value above with letter spacing:
desiredWordSpacing
maximumWordSpacing
minimumWordSpacing
// Setiing this on or off, this is the question:
otfContextualAlternate
otfDiscretionaryLigature
// If digits are used and the font has the features, what to do here?
otfFigureStyle
otfFraction
etc., etc. …
I did not test this, but also lay an eye on the used paragraph composer.
Maybe the composer would also have a say on the result.
See also Jongware's indispensable ExtendScript documentation of the Document Object Model here:
Regards,
Uwe