Howdy folks,
I’m painfully new to working in Applescript, so hopefully this will be an easy question.
I’m working in InDesign CS3 and I’m looking for a way to change the kerning on certain pairs of characters to avoid crashes. Unfortunately, the character pairs I need to fix are made up of one italic character and one roman character (i.e., and italic “f” followed by a roman “)”).
Is there a way to set up a script that is able to find such a combination? Alternatively, is there a way to get it to, perhaps, find an italic “f” and then utilize an if/then statement to determine if the italic “f” is followed by a roman “),” then adjust the kerning between the two?
I feel I’m pretty close to the latter method using the following:
tell application “Adobe InDesign CS3”
activate
set find text preferences to nothing
set find what of find text preferences to “f”
set properties of find text preferences to {font style:“Italic”}
tell document 1
set myFoundItems to find text
repeat with i in myFoundItems
set selection to i
tell selection
end tell
end repeat
end tell
end tell
The only part I can’t figure out is how to extend the selected found text to include the next (and for other pairs, previous) character. If there’s a way to do that, I feel like I could put in the following code in the “tell selection” module:
set CharA to character 1 of selection
set CharB to character 2 of selection
if CharB is “)” then
set kerning value of selection to 200
end if
So basically, I guess I’m wondering whether or not there’s a way to select the next character, thereby enabling the script to search for italic f’s, select the following character on each iteration and run the little if/then to determine if that character is a roman closed paren, and adjust the kerning accordingly. I feel like it would go together with the “set selection to i” line in the first part, so that it’d read kinda like “set selection to i + next character,” but that didn’t work.
Anyway, can anybody help me out? Thanks!
Owen