Article View: adobe.scripting.indesign
Article #20953Re: Font Kerning
From: Olav Kvern
Date: Tue, 21 May 2002 18:01
Date: Tue, 21 May 2002 18:01
11 lines
2680 bytes
2680 bytes
GeekGod--
Here's an example. It searches first for the text tagged with a given character style ("price") and adjusts two pairs ("79" and "10") if they're found in the text.
Dim myInDesign As InDesign.Application Rem Create a list of kerning pairs. Each pair contains the pair Rem (as a string) and the adjustment amount (in kerning units). Rem (You could use a custom collection object, but I'll just use a simple array.) myPairsList = Array(Array("79", 20), Array("10", -20)) Set myInDesign = CreateObject("InDesign.Application.2.0") Set myDocument = myInDesign.ActiveDocument Set myCharStyle = myDocument.CharStyles.Item("price") Rem Clear InDesign's find/change preferences myInDesign.FindPreferences = idNothing myInDesign.ChangePreferences = idNothing myInDesign.FindPreferences.CharacterStyle = myCharStyle Rem Find the text tagged with the specific character style. Set myFoundItems = myDocument.Search Rem Apply manual kerning to the relevant items in the found items list. For myItemCounter = 1 To myFoundItems.Count Set myFoundItem = myFoundItems.Item(myItemCounter) For myCounter = 0 To UBound(myPairsList) myPair = myPairsList(myCounter) myPairString = myPair(0) myKerningAmount = myPair(1) Rem Search the item for any occurrences of the kerning pair. Set myFoundPairs = myFoundItem.Search(myPairString) For myPairCounter = 1 To myFoundPairs.Count Set myFoundPair = myFoundPairs.Item(myPairCounter) Rem Get a referemce to the first character of the pair. Set myCharacter = myFoundPair.Characters.Item(1) Rem Change the kerning value. myCharacter.KerningValue = myKerningAmount Next Next Next Rem Clear InDesign's find/change preferences myInDesign.FindPreferences = idNothing myInDesign.ChangePreferences = idNothing
Would something like this work for you?
Thanks,
Ole
Technical Details
Message-ID:
<ef8a380.4@WebX.aaQKaf7vad4>Path:
arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-03!supernews.com!peer1-sjc1.usenetserver.com!usenetserver.com!cyclone.bc.net!news.maxwell.syr.edu!fr.clara.net!heighliner.fr.clara.net!newsfeed01.sul.t-online.de!t-online.de!WebXReferences:
<ef8a380.-1@WebX.aaQKaf7vad4>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: f939a,43681bc4250ba732 X-Google-Attributes: gidf939a,public X-Google-ArrivalTime: 2002-05-21 11:37:52 PST From: "Olav Kvern" <okvern@adobe.com> Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-03!supernews.com!peer1-sjc1.usenetserver.com!usenetserver.com!cyclone.bc.net!news.maxwell.syr.edu!fr.clara.net!heighliner.fr.clara.net!newsfeed01.sul.t-online.de!t-online.de!WebX Newsgroups: adobe.scripting.indesign Subject: Re: Font Kerning Message-ID: <ef8a380.4@WebX.aaQKaf7vad4> Date: Tue, 21 May 2002 11:01:19 -0700 References: <ef8a380.-1@WebX.aaQKaf7vad4> Lines: 49 MIME-Version: 1.0 Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: 8bit