Copy link to clipboard
Copied
Hi,
I'm writing script and need it to check if a particular font is install. Does anyone know if this is possible and how it would be done?? I can't seem to find any documentation on it.
Bill
Thanks for your help Dan...that seems like the best solution.
Bill
Copy link to clipboard
Copied
I don't know of any way currentlyt to get all the installed fonts, but if you just need to know if a font is installed, you could just set your text layer (or maybe a temporary text layer) to that font, read the font back and see if they match:
var myFontName = "xxxx";
var myComp = app.project.activeItem;
var myTextLayer = myComp.layer(1);
var mySourceText = myTextLayer.property("ADBE Text Properties").property("ADBE Text Document");
var myTextDoc = mySourceText.value;
myTextDoc.font = myFontName;
mySourceText.setValue(myTextDoc);
myTextDoc = mySourceText.value;
if (myTextDoc.font != myFontName) alert ("failed");
Something like that.
Dan
Copy link to clipboard
Copied
Thanks for your help Dan...that seems like the best solution.
Bill
Copy link to clipboard
Copied
Hello!
I needed to do a font test today.
With fontName as it is typed in the character window font dropdown, this code seems to work...
var fontName = "Times New Roman";
var fontExists = false;
try {
ScriptUI.newFont(fontName, "REGULAR", 1);
fontExists = true;
} catch(err) {}
if (fontExists) alert("Font exists!");
else alert("Font does not exist!");
As far as getting a list of available machine fonts, I can't seem find a solution so...help needed!
The 'newFont()' function has to look it up...so why can't we? I'm pretty sure you can for InDesign
Jack
Copy link to clipboard
Copied
Is there a way to determine what the name is for a particular font installed?
Copy link to clipboard
Copied
In AE, I believe it's just the string used in the font family dropdown in the character window.
So you'd have to have the font installed for testing.
Jack
Copy link to clipboard
Copied
I tried that but AE just put Myriad in instead. Do you need to specify the weight as well? I'm trying to call "Helvetica Neue LT STD" for example. Do I need to write in that I also want "77 Bold Condensed" too?
Copy link to clipboard
Copied
I just make a quick tweak to Dan's script snippet and had AE show me the font with it. Apparently, what I wanted is below. I'll use that trick in the future to find how AE spells the font in question.
---------------------------
Script Alert
---------------------------
HelveticaNeueLTStd-BdCn
---------------------------
OK
---------------------------
Copy link to clipboard
Copied
Ah, I was just getting ready to jump in. This should be all you need (assuming the text layer is layer 1):
var myTextLayer = app.project.activeItem.layer(1);
var mySourceText = myTextLayer.property("ADBE Text Properties").property("ADBE Text Document");
var myTextDoc = mySourceText.value;
alert(myTextDoc.font);
Dan