Skip to main content
Inspiring
December 17, 2013
Answered

Installed fonts

  • December 17, 2013
  • 2 replies
  • 1821 views

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

This topic has been closed for replies.
Correct answer billgarv2007

Thanks for your help Dan...that seems like the best solution. 

Bill

2 replies

Participant
January 14, 2014

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

Participating Frequently
March 24, 2014

Is there a way to determine what the name is for a particular font installed?

Participant
March 24, 2014

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

Dan Ebberts
Community Expert
Community Expert
December 18, 2013

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

billgarv2007AuthorCorrect answer
Inspiring
December 18, 2013

Thanks for your help Dan...that seems like the best solution. 

Bill