Skip to content

Instantly share code, notes, and snippets.

@ff6347
Created May 10, 2012 14:59
Show Gist options
  • Save ff6347/2653708 to your computer and use it in GitHub Desktop.
Save ff6347/2653708 to your computer and use it in GitHub Desktop.
Test if a character is in the font
var tf = app.activeDocument.pages.item(0).textFrames.item(0);
for(var i = 0; i < tf.characters.length;i++){
var theChar = tf.characters.item(i);
try_char (theChar);
};
// original function by Peter Kahrel
// http://www.kahrel.plus.com/indesign/compose_cs3.jsx
// edited by fabiantheblind
function try_char (theChar){
try {
// save the character
var storage = theChar.contents;
// create outline
theChar.createOutlines();
// if we got here it worked, so delete the outline
// if not the next line will be within the catch block
// if not it will cause an error
theChar.remove();
// insert the character (again)
theChar.contents = storage;
} catch(e){
alert("The character "+ theChar.contents +
" could not be converted into an Outline.\n"+
"That means he does not exist in the font:\n\""
+ theChar.appliedFont.name+"\"");
}
}
@ff6347
Copy link
Author

ff6347 commented May 11, 2012

This Gist is part of MT4D coming soon on fabiantheblind.info

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment