Last active
August 8, 2025 11:17
-
-
Save elmimmo/04404a0c666877bc57edd62dc80fb68a to your computer and use it in GitHub Desktop.
Adobe InDesign startup script that alerts if a document uses Adobe Fonts when opening or packaging it.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//DESCRIPTION:Alert when opening or packaging a document if it uses Adobe Fonts. | |
//by Jorge Hernández Valiñani _ | |
#target "InDesign" | |
#targetengine "alertAdobeFonts" | |
(function () { | |
// Localization strings for alerts | |
var STR_ALERT_LINE1 = "usa fuentes no recopilables:"; | |
var STR_ALERT_SUFFIX = "Al empaquetar un documento, asegúrate de copiarlas a mano."; | |
// Flag to suppress alerts during packaging | |
var packagingInProgress = false; | |
// Remove any existing listener to avoid duplicates | |
try { | |
var oldListener = app.eventListeners.itemByName("alertAdobeFontsListener"); | |
if (oldListener && oldListener.isValid) { | |
oldListener.remove(); | |
} | |
} catch (e) { | |
// No existing listener | |
} | |
/** | |
* Returns true if the font is from Adobe Fonts, | |
* based on allowEditableEmbedding or its file path. | |
*/ | |
function isAdobeFont(font) { | |
try { | |
var loc = String(font.location); | |
if (loc.indexOf("Adobe Fonts") !== -1) { | |
return true; | |
} | |
} catch (_) {} | |
return false; | |
} | |
// ─── Handler for document open ───────────────────────────────── | |
function handleAfterOpen(event) { | |
try { | |
var target = event.target; | |
// Only proceed if the target is a Document | |
if (!(target && target.constructor && target.constructor.name === "Document")) { | |
return; | |
} | |
// If packaging is in progress, suppress this alert | |
if (packagingInProgress) { | |
return; | |
} | |
var doc = target; | |
// Arrays for Adobe Fonts and protected fonts | |
var adobeFonts = []; | |
for (var i = 0; i < doc.fonts.length; i++) { | |
var f = doc.fonts[i]; | |
// Determine font type | |
if (isAdobeFont(f)) { | |
// Add to adobeFonts without duplicates | |
var foundA = false; | |
for (var a = 0; a < adobeFonts.length; a++) { | |
if (adobeFonts[a] === f.fullName) { | |
foundA = true; | |
break; | |
} | |
} | |
if (!foundA) { | |
adobeFonts.push(f.fullName); | |
} | |
} | |
} | |
// Only show alert if there are relevant fonts | |
if (adobeFonts.length) { | |
// Build message using localization strings | |
var msg = doc.name + " " + STR_ALERT_LINE1; | |
if (adobeFonts.length) { | |
msg += "\n\n• " + adobeFonts.join("\n• "); | |
} | |
msg += "\n\n" + STR_ALERT_SUFFIX; | |
alert(msg); | |
} | |
} catch (err) { | |
} | |
} | |
// Register the listener | |
var listener = app.eventListeners.add("afterOpen", handleAfterOpen); | |
listener.name = "alertAdobeFontsListener"; | |
// Hook the Package… action by its ID to suppress duplicates and fire once | |
try { | |
var pkgAction = app.menuActions.itemByID(39938); | |
if (pkgAction && pkgAction.isValid) { | |
pkgAction.eventListeners.add("beforeInvoke", function() { | |
packagingInProgress = true; | |
}); | |
pkgAction.eventListeners.add("afterInvoke", function() { | |
packagingInProgress = false; | |
handleAfterOpen({ target: app.activeDocument }); | |
}); | |
} | |
} catch (_) {} | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment