Article View: adobe.scripting.indesign
Article #18471Re: Kerning Script
From: Olav Kvern
Date: Fri, 28 Mar 2003 20:33
Date: Fri, 28 Mar 2003 20:33
48 lines
3078 bytes
3078 bytes
Larry--
First, regarding the "rather poor" kerning--what font are you using, and which kerning method are you using (Optical/Metrics)? If you're not using the Optical method, and you're not using a script face, give it a try--it's almost always better than Metrics.
If you've tried the Optical method, and still don't like the kerning, I think what you need to do is apply your kerning using a Find/Change script. You'll want to search for "^?^=" (that's the "any character" metacharacter, followed by the end dash metacharacter). Once you've found that text, you'll want to apply a kerning value to the first character in the selection.
Note that you could do this manually with a two-pass search: search for "^?^=" and apply the kerning amount, then search for "^=" and reset the kerning method to Optical (or Metrics, if that's what you prefer).
But the script is pretty simple:
Dim myInDesign As InDesign.Application
Set myInDesign = CreateObject("InDesign.Application.2.0")
Rem If not documents are open, exit the script.
If myInDesign.Documents.Count = 0 Then
Exit Sub
End If
Set myDocument = myInDesign.ActiveDocument
Rem The variable myKerningValue contains the kerning value
Rem want to apply to the character preceding the en dash.
Rem Positive values increase the space between characters,
Rem negative values tighten the spacing.
myKerningValue = 20
Rem Clear the Find/Change preferences
myInDesign.FindPreferences = idNothing
myInDesign.ChangePreferences = idNothing
Rem At this point, you could make changes to the FindPreferences object to limit
Rem your search to a specific character style, paragraph style, font, or other attribute.
Rem Something like this:
Rem myInDesign.FindPreferences.ParagraphStyle = myDocument.ParaStyles.Item("body_text")
Rem Search the document for the string and return a collection of found text items.
Set myFoundItems = myDocument.Search("^?^=")
Rem Loop through the items, applying manual kerning to the first character in each item.
For myCounter = myFoundItems.Count To 1 Step -1
Set myFoundItem = myFoundItems.Item(myCounter)
Set myCharacter = myFoundItem.Characters.Item(1)
myCharacter.KerningValue = myKerningValue
Next
Does that help?
Thanks,
Ole
Technical Details
Message-ID:
<1de88103.0@WebX.la2eafNXanI>Path:
arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-04!sn-xit-06!sn-xit-09!supernews.com!newshosting.com!news-xfer2.atl.newshosting.com!newsfeed.icl.net!newsfeed.fjserv.net!newsfeed.freenet.de!eusc.inter.net!newsfeed01.sul.t-online.de!t-online.de!WebXReferences:
<1de88103.-1@WebX.la2eafNXanI>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: f939a,5f3b22efd52e1064 X-Google-Attributes: gidf939a,public X-Google-ArrivalTime: 2003-03-28 12:37:47 PST From: "Olav Kvern" <okvern@adobe.com> Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-04!sn-xit-06!sn-xit-09!supernews.com!newshosting.com!news-xfer2.atl.newshosting.com!newsfeed.icl.net!newsfeed.fjserv.net!newsfeed.freenet.de!eusc.inter.net!newsfeed01.sul.t-online.de!t-online.de!WebX Newsgroups: adobe.scripting.indesign Subject: Re: Kerning Script Message-ID: <1de88103.0@WebX.la2eafNXanI> Date: Fri, 28 Mar 2003 12:33:58 -0800 References: <1de88103.-1@WebX.la2eafNXanI> Lines: 59 MIME-Version: 1.0 Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: 8bit