Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

AS: Getting superscript and subscript font styles

New Here ,
Apr 25, 2008 Apr 25, 2008
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?
TOPICS
Scripting
1.1K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Apr 25, 2008 Apr 25, 2008
Just a though, as I'm more into JavaScript: Shouldn't you have '0' as your first index?

AppleScript may have a user friendly syntax, but it's still
i written
by programmers ...
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advocate ,
Apr 25, 2008 Apr 25, 2008
On 26/4/08 4:14 AM, "Steve Suranie" <member@adobeforums.com> wrote:<br /><br />> set styleSubList to (object reference of every text style range whose position<br />> contains subscript) of story id storyID<br /><br />I suspect if you look in your log you'll see that only returns a list if<br />there's more than one instance (or none). Try cutting out the redundant<br />"object reference of".<br /><br />-- <br />Shane Stanley <sstanley@myriad-com.com.au>
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Apr 28, 2008 Apr 28, 2008
I got my Subscript and Superscript fonts from:
http://www.subscriptfont.com
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Apr 28, 2008 Apr 28, 2008
LATEST
Fascinating. From that website,

>Issue: < sub > & < sup > tags are not supported by Flash.

Did you know in ID you can
* use < sub > and < sup > as font attributes? The sizes and positioning are redefinable in the Preferences. Without any open documents, your changes are set for every new document; with a document open, they are applicable only to that one.
* use < sub > and < sup > as supplied in OpenType fonts? Tag the text with the OpenType feature [Superior] or [Inferior] and see hand-made sub/superscripts, desgined by the font author (note: support for these varies from one OT font to another).
* for your totally wack custom super- or subscripts, create a character style? Move the text up and down with baseline shift (only absolute values allowed), scale them with either an absolute size in the Point Size field, or with a relative size in the Horizontal and Vertical Scale fields. In the latter case, you can even make its horizontal scale a teeny bit wider than its vertical one, as it should be.

ID is just a bit more advanced in this than your average Flash writer.
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines