<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
	<key>name</key>
	<string>ROOT</string>
	<key>submenu</key>
	<array>
		<dict>
			<key>content</key>
			<string>--AppleScript direct

--- Test a font set.
-- Font set commands are delimited by %SetFonts lines.
-- In none are found, the script fails.
--Prepares a report showing relative sizes of fonts in the set.
--Useful for fine-tuning the scale factors to better match your fonts.

--Last revised 01/12/2011
-- Michael Sharpe, msharpe@ucsd.edu
global lf
set lf to (ASCII character 10)

--break the document into 3 pieces--part before 1st %SetFonts,between and after 2nd
tell application "TeXShop"
	set whole_document to (the text of the front document) as string
end tell
set oldtid to AppleScript's text item delimiters
set AppleScript's text item delimiters to lf &amp; "\\begin{document}"
set prepost to text items of whole_document
set preamble to (item 1 of prepost)
set AppleScript's text item delimiters to lf &amp; "%SetFonts"
set doc_items to the text items of preamble
set AppleScript's text item delimiters to oldtid
set n to count of doc_items

if not (n = 3) then
	display dialog "Your preamble does not contains exactly two %SetFonts lines. Bailing out." buttons "OK" default button "OK"
	return
end if
set fontblock to trim(true,item 2 of doc_items)
set pre to "\\documentclass{article}" &amp; lf ¬
	&amp; "%\\batchmode" &amp; lf ¬
	&amp; "\\setlength\\parindent{0pt}" &amp; lf ¬
	&amp; "\\usepackage[papersize={3in,2.5in},margin=0in]{geometry}" &amp; lf ¬
	&amp; "\\usepackage{lmodern,amsfonts,mathrsfs}" &amp; lf ¬
	&amp; "\\usepackage{graphicx}" &amp; lf ¬
	&amp; "\\pagestyle{empty}" &amp; lf ¬
	&amp; "\\setlength\\unitlength{1in}"&amp; lf¬
	&amp; fontblock &amp; lf ¬
	&amp; "\\begin{document}" &amp; lf ¬
	&amp; "\\begin{picture}(3,2.5)" &amp; lf¬
	&amp; "\\put(.25,0){\\scalebox{20}{"
set post to "}}\\end{picture}" &amp;lf &amp; "\\end{document}"&amp;lf

set cmds to {"X", "\\textsf{X}", "\\texttt{X}", "$X$", ¬
	"$\\mathcal{X}$", "$\\mathbb{X}$", "$\\mathfrak{X}$", "$\\mathscr{X}$","x", "\\textsf{x}", "\\texttt{x}", "$x$"}
set sizes to {"", "", "", "", "", "", "", "","","","",""}
set glyphsource to {"", "", "", "", "", "", "", "","","","",""}

repeat with i from 1 to 12
	set t to ((path to temporary items) as string &amp; "tempfn" &amp; (i as string) &amp; ".tex")
	set thefile to (POSIX path of t)
	set ref_num to open for access thefile with write permission
	set eof of ref_num to 0
	write pre to ref_num
	write (item i of cmds) &amp; post to ref_num
--	write "\\setbox0=\\hbox{"&amp;(item i of cmds)&amp;"}"&amp;lf to ref_num
--	write "\\newwrite\\foo \\immediate\\openout\\foo=tempfn"&amp;(i as string)&amp;".txt \\immediate\\write\\foo{\\the\\dp0}" to ref_num
--	write "\\closeout\\foo"&amp;lf to ref_num
--	write "\\end{document}" &amp; lf to ref_num
	close access thefile

	try
		set s to (do shell script ("cd \"${TMPDIR}/TemporaryItems\"&amp;&amp;/usr/texbin/pdflatex tempfn" &amp; (i as string)))
	on error errmsg number errnum
		set AppleScript's text item delimiters to oldtid
		display dialog "pdflatex returned error :"&amp; (errnum as string)&amp;": "&amp;errmsg &amp;" while processing tempfn"&amp;(i as string)&amp;".tex --bailing out."
		return
	end try
	set logfile to (POSIX path of ((path to temporary items) as string &amp; "tempfn" &amp; (i as string) &amp; ".log"))
	open for access logfile
	set file_contents to (read logfile)
	close access (logfile)
	set AppleScript's text item delimiters to "you used:"
	set lst to the text items of file_contents
	if (count of lst) is not equal to 2 then
		set AppleScript's text item delimiters to oldtid
		display dialog "Pdflatex log error--bailing out"
		return
	end if
	set s to (item 2 of lst)
	set AppleScript's text item delimiters to {"&lt;", "&gt;"}
	set lst to the text items of s
	if (count of lst)&lt;2 then
		set AppleScript's text item delimiters to oldtid
		display dialog "Unexpected log contents---bailing out."
		return
	end if
	set AppleScript's text item delimiters to "/"
	set fpath to text items of (item 2 of lst)
	set (item i of glyphsource) to clean(item -1 of fpath)
	try
		set s to (do shell script (¬
			"cd \"${TMPDIR}/TemporaryItems\"&amp;&amp;" &amp; ¬
			"/usr/local/bin/gs  -dSAFER -dBATCH -dNOPAUSE -q -r3600 -sDEVICE=bbox -sOutputFile=- " &amp; "-c \"/setpagedevice {pop} def\" -f tempfn" &amp; (i as string) &amp; ¬
			".pdf -c quit 2&gt;&amp;1 | " &amp; "/usr/bin/awk '/HiRes/ { printf \"%4u\", ($5 - $3)*5.01875+0.5 }'"))
		--set k to (s as integer)
		--set t to ((path to temporary items) as string &amp; "tempfn" &amp; (i as string) &amp; ".txt")
		--set thefile to (POSIX path of t)
		--open for access thefile
		--set dp to (read thefile)
		--close access (thefile)
		--set dp to (text 1 thru -3 of trim(true,dp))
		--set k to k-(((dp as number)*100+.5) as integer)
		--set s to (k as string)
	on error
		set s to "0"
	end try
	set (item i of sizes) to trim(true,s)
end repeat

--finally, create report--bg8.pdf must be available somewhere in the texmf (tex/latex) trees
--must first close file if open in texshop
try
	tell application "TeXShop"
		if (exists  document "tempfnrep.tex") then
			close document "tempfnrep.tex"
		else
			if  (exists  document "tempfnrep") then close document "tempfnrep"
		end if
	end tell
on error --catch errors like timeout errors
end try
set repcontent to "\\documentclass{article}"&amp;lf¬
&amp;"%\\batchmode"&amp;lf¬
&amp;"\\setlength\\parindent{0pt}"&amp;lf¬
&amp;"\\usepackage[landscape,margin=.5in]{geometry}"&amp;lf¬
&amp; "\\usepackage{lmodern,amsfonts,mathrsfs}" &amp; lf ¬
&amp;"\\usepackage{xcolor,graphicx}"&amp;lf¬
&amp;"\\usepackage{multido}"&amp;lf¬
&amp;"\\setlength\\unitlength{80pt}"&amp;lf¬
&amp;"\\def\\myr{\\color{red!50}}"&amp;lf¬
&amp;fontblock&amp;lf¬
&amp;"\\pagestyle{empty}"&amp;lf¬
&amp;"\\def\\wid{8.89pt}"&amp;lf¬
&amp;"\\begin{document}"&amp;lf¬
&amp;"\\begin{picture}(8,1.1)"&amp;lf¬
&amp;"\\put(0,0){\\includegraphics{bg8.pdf}}"&amp;lf¬
&amp;"\\put(0,.16){\\scalebox{9}{\\hbox to \\wid{X\\hfil}}}"&amp;lf¬
&amp;"\\put(0,.16){\\scalebox{9}{\\myr\\hbox to \\wid{\\hfil x}}}"&amp;lf¬
&amp;"\\put(1,.16){\\scalebox{9}{\\hbox to \\wid{\\textsf{X}\\hfil}}}"&amp;lf¬
&amp;"\\put(1,.16){\\scalebox{9}{\\myr\\hbox to \\wid{\\hfil\\textsf{x}}}}"&amp;lf¬
&amp;"\\put(2,.16){\\scalebox{9}{\\hbox to \\wid{\\texttt{X}\\hfil}}}"&amp;lf¬
&amp;"\\put(2,.16){\\scalebox{9}{\\myr\\hbox to \\wid{\\hfil\\texttt{x}}}}"&amp;lf¬
&amp;"\\put(3,.16){\\scalebox{9}{\\hbox to \\wid{$X$\\hfil}}}"&amp;lf¬
&amp;"\\put(3,.16){\\scalebox{9}{\\myr\\hbox to \\wid{\\hfil$x$}}}"&amp;lf¬
&amp;"\\put(4,.16){\\scalebox{9}{\\hbox to \\wid{{\\hfil$\\mathcal{X}$\\hfil}}}}"&amp;lf¬
&amp;"\\put(5,.16){\\scalebox{9}{\\hbox to \\wid{\\hfil$\\mathbb{X}$\\hfil}}}"&amp;lf¬
&amp;"\\put(6,.16){\\scalebox{9}{\\hbox to \\wid{\\hfil$\\mathfrak{X}$\\hfil}}}"&amp;lf¬
&amp;"\\put(7,.16){\\scalebox{9}{\\hbox to \\wid{\\hfil$\\mathscr{X}$\\hfil}}}"&amp;lf¬
&amp;"\\multido{\\i=0+1,\\ia=1+1}{8}"&amp;lf¬
&amp;"{\\put (\\i,-.2){\\hbox to 80pt{\\hfil\\ia\\hfil}}}"&amp;lf¬
&amp;"\\end{picture}"&amp;lf¬
&amp;"\\vspace{2pc}"&amp;lf¬
&amp;"\\begin{tabbing}"&amp;lf¬
&amp;"Key \\= Height----- \\= Type\\hspace{7pc} \\= \\verb|$\\mathfrak{XXX}$| \\= \\kill"&amp;lf¬
&amp;"Key \\&gt; Height \\&gt; Type\\&gt; Command \\&gt; Glyph source file\\\\"&amp;lf¬
&amp;"1 \\&gt; "&amp;(item 1 of sizes)&amp;"/"&amp;(item 9 of sizes)&amp;" \\&gt; Roman \\&gt;X/x \\&gt; \\texttt{"&amp;(item 1 of glyphsource)&amp;"}\\\\"&amp;lf¬
&amp;"2 \\&gt; "&amp;(item 2 of sizes)&amp;"/"&amp;(item 10 of sizes)&amp;" \\&gt; Sans Serif \\&gt; \\verb|\\textsf{X/x}| \\&gt; \\texttt{"&amp;(item 2 of glyphsource)&amp;"}\\\\"&amp;lf¬
&amp;"3 \\&gt; "&amp;(item 3 of sizes)&amp;"/"&amp;(item 11 of sizes)&amp;" \\&gt; Typewriter \\&gt; \\verb|\\texttt{X/x}| \\&gt; \\texttt{"&amp;(item 3 of glyphsource)&amp;"}\\\\"&amp;lf¬
&amp;"4 \\&gt; "&amp;(item 4 of sizes)&amp;"/"&amp;(item 12 of sizes)&amp;" \\&gt; Math Italic \\&gt; \\verb|$X/x$| \\&gt; \\texttt{"&amp;(item 4 of glyphsource)&amp;"}\\\\"&amp;lf¬
&amp;"5 \\&gt; "&amp;(item 5 of sizes)&amp;" \\&gt; Math Calligraphic \\&gt;\\verb|$\\mathcal{X}$| \\&gt; \\texttt{"&amp;(item 5 of glyphsource)&amp;"}\\\\" &amp;lf¬
&amp;"6 \\&gt; "&amp;(item 6 of sizes)&amp;" \\&gt; Math Blackboard Bold \\&gt; \\verb|$\\mathbb{X}$| \\&gt; \\texttt{"&amp;(item 6 of glyphsource)&amp;"}\\\\"&amp;lf¬
&amp;"7 \\&gt; "&amp;(item 7 of sizes)&amp;" \\&gt; Math Fraktur \\&gt; \\verb|$\\mathfrak{X}$| \\&gt; \\texttt{"&amp;(item 7 of glyphsource)&amp;"}\\\\"&amp;lf¬
&amp;"8 \\&gt; "&amp;(item 8 of sizes)&amp;" \\&gt; Math Script \\&gt; \\verb|$\\mathscr{X}$| \\&gt; \\texttt{"&amp;(item 8 of glyphsource)&amp;"}\\\\"&amp;lf¬
&amp;"\\end{tabbing}"&amp;lf¬
&amp;"\\vspace{1pc}"&amp;lf¬
&amp;"\\textbf{Font commands:}"&amp;lf¬
&amp;"\\begin{verbatim}"&amp;lf¬
&amp;fontblock&amp;lf¬
&amp;"\\end{verbatim}"&amp;lf¬
&amp;"\\end{document}"

set t to ((path to temporary items) as string &amp; "tempfnrep.tex")
set thefile to (POSIX path of t)
set ref_num to open for access thefile with write permission
set eof of ref_num to 0
write repcontent to ref_num
close access thefile
try
	set s to (do shell script ("cd \"${TMPDIR}/TemporaryItems\"&amp;&amp;/usr/texbin/pdflatex tempfnrep"))
on error errmsg
	set AppleScript's text item delimiters to oldtid
	display dialog "pdflatex returned error: "&amp;errmsg&amp;lf&amp;"while processing tempfnref.tex --bailing out."
	return
end try
set s to do shell script "open -a TeXShop.app " &amp; quoted form of (POSIX path of t)

on trim(theseCharacters, someText)
	-- Lazy default (AppleScript doesn't support default values)
	if theseCharacters is true then set theseCharacters to ¬
		{" ", tab, ASCII character 10}
	
	repeat until first character of someText is not in theseCharacters
		set someText to text 2 thru -1 of someText
	end repeat
	
	repeat until last character of someText is not in theseCharacters
		set someText to text 1 thru -2 of someText
	end repeat
	
	return someText
end trim

on clean(someText)
	--get rid of all internal lf
	set thetid to Applescript's text item delimiters
	set Applescript's text item delimiters to lf
	set fields to text items of someText
	set Applescript's text item delimiters to ""
	set someText to (fields as string)
	set Applescript's text item delimiters to thetid
	return someText
end clean</string>
			<key>name</key>
			<string>TestFontSet</string>
		</dict>
	</array>
</dict>
</plist>
