Resizing text in Illustrator CS2

Okay – so I’ve written a script that takes a huge block of text within illustrator and makes it so that each line of that text block is smaller than the last – see output at File:UmlautPoster.png - Meta

The script looks like this:


tell application "Adobe Illustrator"
	set FontSize to 160
	set itemCount to 1
	repeat
		set size of line itemCount of text frame 2 of document 1 to FontSize
		set FontSize to (FontSize ^ 0.9815) + (5 / FontSize)
		set itemCount to itemCount + 1
	end repeat
end tell

160 is the size of the first line, 0.9815 is the shrink factor, and the (5/fontsize) term sets a minimum size for the lines at the bottom. (I usually have to run the script twice on the same text block to iron out the kinks, otherwise text of one font size overflows to the next line – not a major issue.)

The problem is that I have to tweak the script individually for each block of text – make the shrink factor smaller if the text is longer, for example. It takes a long time to get it right, partly because I’m on an intel mac and Illustrator’s running through rosetta.

Argh. I hit enter by mistake, sorry.

As I was saying: I’m trying to automate the script so that it can work with a block of text containing any number of words – have the script automatically find the shrink factor to make the resulting text a certain height.

I thought of having the script try to find the height of the text, and then increment the shrink factor and rerun itself until the height was close to what I want. But this is complicated by the fact that it seems like the “height” of an area text box in Illustrator is always the size of the bounding box – the “height” doesn’t change just because it’s more completely filled with text.

Any help is appreciated.

Hi togmer

Before you say it i guess this script does exactly what yours does.
i was trying to recreate the text overflow problem but couldn’t
and also kept getting an out of range error on your script even though the script still worked.
i couldn’t get your script to overflow the text onto the next line either.

tell application "Adobe Illustrator"
	set FontSize to 160
	repeat with i from 1 to (count line of text frame 1 of document 1)
		set size of line i of text frame 1 of document 1 to FontSize
		set FontSize to (FontSize ^ 0.9815) + (5 / FontSize)
	end repeat
end tell

Not sure how the script would find the shrink factor!
it maybe just how we have our illustrators setup

cheers

Oh, oops – forgot about the out of range error (that’s just 'cause I never broke the loop!) =)
The overflow problem only happens with very long lines of text and when the resizing is severe, so it would depend on the text and the shape of the box.

As for the shrink factor – is there some sort of boolean flag that lets you know whether text overflows the text frame (i.e. the little red + sign) – that would solve my problem too? I’ll look into it.