Question
AS: Getting superscript and subscript font styles
I'm trying to locate all the subscripts and superscripts in a story and change their applied font. When I run this script it works fine:
set styleSubList to (object reference of every text style range whose position contains subscript) of story id storyID
if (count of every item of styleSubList) > 0 then
repeat with i from 1 to count of every item of styleSubList
set thisStyle to item i of styleSubList
-->set ranges
set startRange to index of thisStyle
set rangeContents to contents of thisStyle
set endRange to startRange + ((length of rangeContents))
-->set font of thisStyle
try
set applied font of thisStyle to "Times"
set font style of thisStyle to "Roman"
on error errMsg
return errMsg
end try
end repeat
end if
if I return the first item of styleSubList I get this as a result:
text from character 245 to character 245 of story id 173 of document "testfile3.indd" of application "Adobe InDesign CS3"
from which I can also get all the properties.
Same script but replace "subscript" with "superscript" and I get an error:
"Can't get index of \"3\"."
3 is the character that is superscript in the story. There's only one superscript. If I had a second one to the story it works fine. Any clues? Is there something in my script which I am overlooking or is this a glitch with the Editor or Indesign?
set styleSubList to (object reference of every text style range whose position contains subscript) of story id storyID
if (count of every item of styleSubList) > 0 then
repeat with i from 1 to count of every item of styleSubList
set thisStyle to item i of styleSubList
-->set ranges
set startRange to index of thisStyle
set rangeContents to contents of thisStyle
set endRange to startRange + ((length of rangeContents))
-->set font of thisStyle
try
set applied font of thisStyle to "Times"
set font style of thisStyle to "Roman"
on error errMsg
return errMsg
end try
end repeat
end if
if I return the first item of styleSubList I get this as a result:
text from character 245 to character 245 of story id 173 of document "testfile3.indd" of application "Adobe InDesign CS3"
from which I can also get all the properties.
Same script but replace "subscript" with "superscript" and I get an error:
"Can't get index of \"3\"."
3 is the character that is superscript in the story. There's only one superscript. If I had a second one to the story it works fine. Any clues? Is there something in my script which I am overlooking or is this a glitch with the Editor or Indesign?
