🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: adobe.scripting.indesign
Article #19392

Re: Changing text kerning

#19392
From: Olav Kvern
Date: Mon, 16 Dec 2002 23:41
54 lines
2844 bytes
Rich--

Here's a more complete version, with class checking and a bit more selection processing.



tell application "InDesign 2.0.1" 
	--Assumes you have a pair selected or a text insertion point between characters. 
	--If you have a text selection that spans more than two characters, 
	--only the first two characters will be used. 
	try 
		if class of item 1 of selection is text or class of item 1 of selection is insertion point then 
			if class of item 1 of selection is text then 
				set myCount to (count characters of item 1 of selection) 
				if myCount is 2 then 
					set myText to object reference of item 1 of selection 
				else if myCount is 1 then 
					set myIndex to index of character 1 of item 1 of selection 
					set myText to object reference of characters myIndex through (myIndex + 1) of parent story of item 1 of selection 
				else 
					set myText to object reference of characters 1 through 2 of item 1 of selection 
				end if 
			else if class of item 1 of selection is insertion point then 
				set myIndex to index of item 1 of selection 
				set myText to object reference of characters (myIndex - 1) through myIndex of parent story of item 1 of selection 
			end if 
			set kerningValue to kerning value of character 1 of myText 
			set theIndex to index of myText 
			set charContents to contents of myText 
			set charFontStyle to font style of myText 
			set CharFontSize to point size of myText 
			set charFont to applied font of myText 
			set find preferences to nothing 
			set change preferences to nothing 
			set myFoundItems to search document 1 for charContents with find attributes {applied font:charFont, point size:CharFontSize, font style:charFontStyle} with case sensitive 
			repeat with myFoundItem in myFoundItems 
				--Apply kerning to the *first* character in each found pair 
				set properties of character 1 of myFoundItem to {kerning value:kerningValue} 
			end repeat 
		else 
			error 
		end if 
	on error 
		activate 
		display dialog "Please select a character pair or insertion point and try again." 
	end try 
end tell 




Thanks,

Ole
Technical Details
Message-ID: <1de70063.6@WebX.la2eafNXanI>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-03!sn-xit-01!sn-xit-08!supernews.com!newsfeed.online.be!newsfeed01.sul.t-online.de!t-online.de!WebX
References: <1de70063.-1@WebX.la2eafNXanI>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: f939a,3bc2053af32b20a2
X-Google-Attributes: gidf939a,public
X-Google-ArrivalTime: 2002-12-16 16:07:44 PST
From: "Olav Kvern" <okvern@adobe.com>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-03!sn-xit-01!sn-xit-08!supernews.com!newsfeed.online.be!newsfeed01.sul.t-online.de!t-online.de!WebX
Newsgroups: adobe.scripting.indesign
Subject: Re: Changing text kerning
Message-ID: <1de70063.6@WebX.la2eafNXanI>
Date: Mon, 16 Dec 2002 15:41:59 -0800
References: <1de70063.-1@WebX.la2eafNXanI>
Lines: 60
MIME-Version: 1.0
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit