Created
May 10, 2012 14:59
-
-
Save ff6347/2653708 to your computer and use it in GitHub Desktop.
Test if a character is in the font
This file contains 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
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+"\""); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This Gist is part of MT4D coming soon on fabiantheblind.info