30)字形変更

| コメント(0) | トラックバック(0)

選択されたテキストフレーム内の文字を1文字づつあたっていき連続数字なら等幅半角字形に1ケタ数字なら等幅半角字形で前後に4分アキを入れる。
本当に1文字づつあたっていく超ベタなスクリプト。ほんとはずかしい。serchを使った方が早いですね。興味ある方はチャレンジしてみてください。

CS3なら正規表現
CS4なら正規表現スタイルを使った方が良いです。

set findList to {"0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "0", "1", "2", "3", "4", "5", "6", "7", "8", "9"}
set findListCount to count findList

tell application "Adobe InDesign CS2_J"
	tell document 1
		set selectedItems to selection
		if selectedItems is {} then
			display dialog "テキストフレームを選択ツール(黒矢印)で¬
				選択してください。"
			return
		end if
		repeat with selItem in selectedItems
			if class of selItem is not text frame then
				display dialog "テキストフレームを選択ツール(黒矢印)で¬
					選択してください。"
				return
			else
				set Pnum to count paragraphs of selItem
				repeat with P from 1 to Pnum
					set myPara to paragraph P of selItem
					set FLG to false
					repeat with FL from 1 to findListCount
						if item FL of findList is in myPara then
							set FLG to true
							exit repeat
						end if
					end repeat
					if FLG is true then
						set Cnum to count characters of paragraph P of selItem
						repeat with N from 1 to Cnum
							if N = 1 then
								set TXTpre to "★"
							else
								set TXTpre to contents of character (N - 1) of ¬
								paragraph P of selItem
							end if
							set TXT to contents of character N of paragraph P of selItem
							if N = Cnum then
								set TXTaf to "★"
							else
								set TXTaf to contents of character (N + 1) of ¬
								paragraph P of selItem
							end if
							if TXTpre is in "01234567890123456789,." and ¬
							TXT is in "01234567890123456789,." then
								set glyph form of character (N - 1) of paragraph P of ¬
								selItem to monospaced half width form --等幅半角字形
								set glyph form of character N of paragraph P of ¬
								selItem to monospaced half width form --等幅半角字形
							else if TXTpre is not in "01234567890123456789"¬
							 and TXT is in "01234567890123456789" ¬
							and TXTaf is not in "01234567890123456789" then
								set properties of character N of paragraph P ¬
								of selItem to {glyph form:monospaced half width form,¬
								 trailing aki:0.25, leading aki:0.25}
							end if
						end repeat
					end if
				end repeat
			end if
		end repeat
	end tell
end tell
display dialog "終了しました"

トラックバック(0)

トラックバックURL: http://www.adg7.com/mt/mt-tb.cgi/111

Comments are nofollow setting

コメントする

エントリー一覧

OpenID対応しています OpenIDについて
Powered by Movable Type 7.902.0
漢字イラストロジック-脳トレ京
FREE ONLINE SUDOKU