Script for changing font of one layer, only certain fonts working
I have a script in which I select the top layer of the psd file, which is a text layer, then change the font and finally resize it to a certain px width. Below is the code. The problem, is that only certain fonts seem to work. Some either don't do anything, remove the text entirely, or scale the text to a different size than specified in the script. It seems random. Several of the fonts I am attempting to apply were downloaded online (1001fonts, Dafonts, etc), but I haven't found any correlation as to which ones work/don't work.
I recently moved all downloaded fonts in FontBook from User (~/Library/Fonts/) to Computer (/Library/Fonts/), thinking the desired font would need to be accessible to all users, but this didn't work.
Any suggestions? Thanks!
#target photoshop
function main(){
if(!documents.length) return;
var startRulerUnits = app.preferences.rulerUnits;
app.preferences.rulerUnits = Units.PIXELS;
app.activeDocument.activeLayer = app.activeDocument.layers[0];
app.activeDocument.activeLayer.textItem.font = "Helvetica";
var doc = activeDocument;
var res= doc.resolution;
var LB = activeDocument.activeLayer.bounds;
var Width= LB[2].value - LB[0].value;
var onePix = 100/Width;
var newSize = onePix * 1000;
doc.activeLayer.resize( newSize , newSize, AnchorPosition.MIDDLECENTER);
app.preferences.rulerUnits = startRulerUnits;
}
main();
