Reply To: Resize selected line height / spacing

#60703

I don't know why you might want to do this by script, but here it is:

Main();

function Main() {
if (app.documents.length == 0) {
alert (“Please open a document, select some text, and try again.”);
exit();
}
else if (app.selection.length > 1 || app.selection[0].hasOwnProperty(“baseline”) == false) {
alert (“Please select some text, and try again.”);
exit();
}

var the_document = app.documents[0];
var the_selection = app.selection[0];

var the_dialog = app.dialogs.add({name:”Change leading in the selected text”});
with(the_dialog.dialogColumns.add()){
with(dialogRows.add()){
staticTexts.add({staticLabel:”Change leading in the selected text by”});
var increase_by = measurementEditboxes.add({editUnits:MeasurementUnits.POINTS, editValue:0});
}
}
var dialog_result = the_dialog.show();

if (dialog_result) {
if (the_selection.leading != Leading.AUTO) {
the_selection.leading = the_selection.leading + increase_by.editValue;
}
else {
the_selection.leading = (the_selection.pointSize * (the_selection.autoLeading/100)) + increase_by.editValue;
}
}
}

Written in CS5.5, Windows.

Warning: it's not totally tested — just a quick exercise in scripting before going to bed.

Make sure that Preferences > Type > Apply Leading to Entire Paragraphs should be off.

Regards,
Kasyan

This article was last modified on October 6, 2011

Comments (0)

Loading comments...