Fonts are a major nuisance. I assume you are working in InDesign, as Type1 fonts are going away in Adobe. Here is what I have used for years.
on dpDocFontReplace(nameDocument, listFontReplacements)
– revised 2014-06-05 includes routine to dismiss dialogs.
– This script will manage the replacement of old fonts with new fonts in a document
–
– listFontReplacements = a list of records indicating the desired font replacements
– nameFind is the old name that is used to search
– nameBad is the applied font name that is used in the replacement code
– nameNew is the font we want to apply to characters with applied font nameBad
– often nameFind and nameBad are the same, but not always, see Avenir
– {nameFind:“Avenir (T1) 65 Medium”, nameBad:“Avenir 65 Medium”, nameNew:“Avenir Medium”}
-- Get a list of the fonts used in the document
tell application id "com.adobe.InDesign"
activate
tell document 1
set listfonts to name of every font
end tell
end tell
-- Detect and dismiss dialog
tell application "System Events"
tell (process 1 whose name contains "Adobe InDesign")
if window "Missing Fonts" exists then
keystroke return
end if
end tell
end tell
-- diagnostics
# set AppleScript's text item delimiters to return
# set listOfFonts to listfonts as text
# set AppleScript's text item delimiters to ""
# libraryUtilities's logEvent2("Activity", "dpDocFontReplace", {"", "", "listfonts contains" & return & listOfFonts})
-- Process each font on the replacement list
repeat with a from 1 to count items of listFontReplacements
--
-- Parse the current replacement information
set nameFontFind to nameFind of item a of listFontReplacements
set nameFontBad to nameBad of item a of listFontReplacements
set nameFontNew to nameNew of item a of listFontReplacements
libraryUtilities's logEvent2("Activity", "dpDocFontReplace:nameFontFind", {"", "", nameFontFind})
-- If the old font is being used, replace it with the new font
if listfonts contains nameFontFind then
tell application id "com.adobe.InDesign"
set refFontBad to font nameFontBad
set refFontNew to font nameFontNew
tell document 1
try
if (every character of every story whose name of applied font is nameFontBad) ≠ {} then
set (applied font of every character of every story whose name of applied font is nameFontBad) to refFontNew
libraryUtilities's logEvent2("Activity", "dpDocFontReplace", {"", "", (nameFontBad & " replaced with " & nameFontNew)})
else if (every character of every story whose name of applied font is nameFontFind) ≠ {} then
set (applied font of every character of every story whose name of applied font is nameFontFind) to refFontNew
libraryUtilities's logEvent2("Activity", "dpDocFontReplace", {"", "", (nameFontFind & " replaced with " & nameFontNew)})
else
set errorMessage to ("No type found to replace for " & nameFontBad)
error errorMessage number -9999
libraryUtilities's logEvent2("Activity", "dpDocFontReplace", {"", "", errorMessage}) -- of libraryUtilities
end if
on error errorMessage number errorNumber
libraryUtilities's logEvent2("Error", "dpDocFontReplace", {errorMessage, errorNumber, "could not replace font " & nameFontBad})
end try
end tell -- doc 1
end tell -- application "Adobe InDesign"
else
--logEvent2("Activity", "dpDocFontReplace", {"", "", "listfonts does not contain " & nameFontFind}) of libraryUtilities
end if
end repeat
delay 4 -- allow document to update.
end dpDocFontReplace
my logEvent2 is something I picked up from some AS book years ago, maybe Mark Munro’s? Use any log function you want.
Hope that helps