Working with Horizontal Scaling in Quark 6

I had previously written an article about upgrading applescripts that worked with Quark 4.1 on OS 9 to Quark 6 on OSX. There were surprisingly few changes that I initially found; however, upon working with a new script that contained some commands that the previous scripts didn’t, I did find one more change.

I had a script that worked with the previous version of Quark to set a series of centered, one-line paragraphs within a text box. If any of the paragraphs were too long to fit on one line, it would use the horizontal scaling function to downsize it.

I used to be able to set the horizontal scale of the paragraph to a variable, then subtract 5 and reset, then count the number of lines in the paragraph, again, to determine if it needed to be downsized further.

With version 6, if you return the horizontal scale, you no longer get a number you can work with, so instead, I have to start with 100, and subtract 5 from there. (Horizontal scale is set in percents.) Also, it’s important to format the percent number you are setting the horizontal scale to as a one item list. Quark 4 wasn’t so picky. Since Quark still doesn’t count lines very well, I also find it more reliable to compare the contents of one line with the contents of a paragraph to see if they are the same rather than relying on the line count. In the following example, I also have a mimimum horizontal scale that I am willing to downsize to.

The first bit of code uses the Acme Script Widgets to parse apart the paragraphs. Remember, in OSX, paragraphs are delineated by ASCII character 13. The variable thetext is already set to the contents of the text box.


		set tokp to tokenize thetext with delimiters (ASCII character 13)
		set pcount to count tokp
		repeat with x from 1 to pcount
			--Go through every paragraph of the text box to see if it folds into two lines and if it does, scale it down until it doesn't.
			tell application "QuarkXPress"
				tell page eachpage of document docname
					set justification of paragraph x of newbox to «constant JUSTcent»
					set totalhli to count lines of paragraph x of newbox
					set currline to line 1 of paragraph x of newbox
					set currpar to paragraph x of newbox
				end tell
			end tell
			if currpar = currline then
			else
				set hornum to 100
				repeat
					if currpar = currline or hornum < 56 then
						exit repeat
					end if
					set hornum to hornum - 5
					tell application "QuarkXPress"
						tell page eachpage of document docname
							set horizontal scale of text of paragraph x of newbox to {hornum}
							set currline to line 1 of paragraph x of newbox
							set currpar to paragraph x of newbox
						end tell
					end tell
				end repeat
			end if
			
		end repeat

This is only an exerpt of a much longer script, but hopefully it will illustrate this change.

Happy Scripting!