Application.Fonts.getByName () is not installed on the system fonts

The situation:

My colleague has a Mac and I work under Windows. We both use PS 5.1. Whenever I get a document he PS tell that not all fonts have been found. I'm doing a script that goes through all the textlayers and find these missing fonts.

My problem:

The script that loops through all the textlayers, find the font and checks using Application.fonts.getByName () if the police. The problem is that the Application.fonts.getByName () always succeeds and returns the police, even when it is not installed on my system. How is that possible? (When I try with a name completely bogus as "jklm" it will fail as expected)

(In the future I would like to extend my script, so it can replace these fonts with another font of my choice.)

The problem is that the fonts in the document are included in app.fonts, even if they are not on your system.

I don't have CS5 to test and I don't know when the key to necessary action descriptor added so this may not work for you, but it works with Photoshop CC.

function activeLayerFontMissing(){
    var ref = new ActionReference();
    ref.putProperty( charIDToTypeID( "Prpr" ), charIDToTypeID("Txt ") );
    ref.putEnumerated( charIDToTypeID("Lyr "), charIDToTypeID("Ordn"), charIDToTypeID("Trgt") );
    var desc = executeActionGet(ref);
    if(desc.count == 0) return -1;
    desc = desc.getObjectValue(charIDToTypeID("Txt "));
    return  desc.hasKey(stringIDToTypeID("substitutesUsed")) ? true:false;
}

Returns true is police is missing, false if it is on the system, and -1 if the layer is not a textLayer.

Tags: Photoshop

Similar Questions

Maybe you are looking for