It's really easy to change the used font.
--\[SCRIPT changeFontsInTemplate]
(*
Define an application (theApp)
Define the template to modify (theTemplate)
Define the couples of oldFontName, newFontName
Run the script.
It will modify the template accordingly.
For safe it will also create a gzipped backup of the original Index-xxx.xml file.
Yvan KOENIG (Vallauris, FRANCE)
16 octobre 2008
*)
(* you may set it to "Pages" or "Numbers" *)
set theApp to "Pages"
(* you may define the template of your choice *)
set theTemplate to "Letters:Classic Letter.template:"
set listepolices to {}
(* define your couples oldFontName, newFontName *)
set couple to {"Didot-Bold", "Arial-BoldMT"}
copy couple to end of listepolices
set couple to {"Didot", "ArialMT"}
copy couple to end of listepolices
(* define the paper size "index-iso.xml" or "index-trad.xml" *)
set nomIndex to "index-iso.xml"
set chemin to (path to applications folder as text) & "iWork '08:" & theApp & ".app:Contents:Resources:Templates:" & theTemplate
set cheminIndex to chemin & nomIndex
tell application "Finder"
set flagGz to exists file (cheminIndex & ".gz")
set flag to exists file (cheminIndex)
if (not flagGz) and not flag then error "No " & nomIndex & " file available !"
if flagGz then
if flag then delete file (cheminIndex)
if not (exists file (chemin & "backup_" & nomIndex & ".gz")) then my duplique(chemin, nomIndex & ".gz")
do shell script "gunzip " & quoted form of POSIX path of (cheminIndex & ".gz")
else
if not (exists file (chemin & "backup_" & nomIndex)) then
my duplique(chemin, nomIndex)
do shell script "gzip " & quoted form of POSIX path of (chemin & "backup_" & nomIndex)
end if
end if -- flagGz
end tell -- Finder
set leTexte to ""
try
set leTexte to read file (chemin & nomIndex)
end try
if leTexte is "" then error "Unable to read : " & cheminIndex & " !"
repeat with l in listepolices
set leTexte to my remplace(leTexte, item 1 of l, item 2 of l)
end repeat
write leTexte to (cheminIndex as alias) starting at 0
do shell script "gzip " & quoted form of POSIX path of cheminIndex
-- ==================
on remplace(t, TID1, TID2)
local l
set AppleScript's text item delimiters to TID1
set l to (text items of t)
set AppleScript's text item delimiters to TID2
set t to l as text
set AppleScript's text item delimiters to ""
return t
end remplace
-- ==================
on duplique(d, n)
local dup
set p2ti to path to temporary items
tell application "Finder"
try
set dup to duplicate file (d & n) to p2ti
end try
try
set name of dup to "backup_" & n
end try
duplicate file ((p2ti as text) & "backup_" & n) to (d as alias)
end tell
end duplique
end
-- ==================
--[/SCRIPT]
Yvan KOENIG (from FRANCE jeudi 16 octobre 2008 18:04:53)