🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: adobe.scripting.indesign
Article #18190

Re: Change the font of characters (AS)

#18190
From: Olivier Berquin
Date: Fri, 18 Apr 2003 07:44
61 lines
2545 bytes
Jay, Kari,

The method is faster, not really the handler.
In my method, I take the index of the first "tab" of the paragraph directly in the InDesign application:



 
set properties of text from character 1 to � 
  (character 1 whose contents = "	") of paragraph i to � 
  {applied font:"Times", font style:"Bold"} 



In the script of Kari, it copy the content of the paragraph
in a variable (theText), and make the comparison from this variable.
This script also works with the styles: character style and paragraph style.
I (re)wrote this script without handler. For 1400 paragraphs, it takes 60 sec.
The version with handler takes 54 sec.




 
set myStart to time of (current date)

set paraStyle to "BodyText" -- name of paragraph style to have run-in head   
set runinStyle to "TimesStyle" -- name of character style to be applied   
set sepChar to "	" as text -- separator character : a tabulation in this case

tell application "InDesign 2.0.2" 
 set theStories to object reference of stories of document 1 
 repeat with theStory in theStories 
  try 
   set theParaStyles to name of applied paragraph style of object reference of paragraphs of theStory 
   repeat with x from 1 to count of theParaStyles 
    if paraStyle = contents of item x of theParaStyles then 
     set theText to paragraph x of theStory 
     set theEnd to (offset of sepChar in theText) - 1 
     if theEnd > 0 then 
      set the applied character style of �  
       characters 1 through theEnd of paragraph x of theStory � 
       to character style runinStyle of document 1 
     end if 
    end if 
   end repeat 
  end try 
 end repeat 
end tell

set myEnd to time of (current date) 
set myDifference to myEnd - myStart 
display dialog "Time: " & myDifference





HTH

Olivier.
Technical Details
Message-ID: <1de8bfdc.9@WebX.la2eafNXanI>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-06!sn-xit-09!supernews.com!news.maxwell.syr.edu!nntp.infostrada.it!newsfeed01.sul.t-online.de!t-online.de!WebX
References: <1de8bfdc.-1@WebX.la2eafNXanI>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII
X-Google-Thread: f939a,f7431b34e5085098
X-Google-Attributes: gidf939a,public
X-Google-ArrivalTime: 2003-04-18 01:08:02 PST
From: "Olivier Berquin" <olb@microscript.com>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-06!sn-xit-09!supernews.com!news.maxwell.syr.edu!nntp.infostrada.it!newsfeed01.sul.t-online.de!t-online.de!WebX
Newsgroups: adobe.scripting.indesign
Subject: Re: Change the font of characters (AS)
Message-ID: <1de8bfdc.9@WebX.la2eafNXanI>
Date: Fri, 18 Apr 2003 00:44:51 -0700
References: <1de8bfdc.-1@WebX.la2eafNXanI>
Lines: 68
MIME-Version: 1.0
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit