7 Replies Latest reply: Jun 5, 2012 11:05 AM by BDAqua
ndubau Level 1 Level 1 (0 points)


I'm a french user, very novice in scripting. In an application I created, a special font is required. So I wrote an applescript to install it in the FontBook. This is my code :


-- Chemin d'accès du présent script

set theScriptPath to path to me


-- chemin du dossier actuel

tell application "Finder"

    set my_folder_path to container of (path to me) as text


    -- Chemin d'accès à la police

    set theFontPath to my_folder_path & "IDAutomationHC39M.ttf"

end tell


set theFont to theFontPath


-- installation police

tell application "Finder"

    open theFontPath

end tell


tell application "Font Book"


    if installation target is not font domain "User" then

        set installation target to font domain "User"

    end if



    set theFontWindow to the first window

end tell



tell application "System Events"

    tell process "Font Book"

        tell window 1

            tell group 1

                click button "Installer la police"

            end tell

        end tell

        tell application "Font Book" to quit

    end tell

end tell

It's certainly not very pure, but it runs ! The only problem is when the font already exists for user or system, an alert appears to warn of the existence of a doubloon. How can I include a test : if the font exists do nothing else install the font ?

Thanks for your help


G4 1,25, Mac OS X (10.4.3)