Copy link to clipboard
Copied
I would like to select the font manually and not preset it in the script
//#target photoshop
main();
function main(){
if(!documents.length) return;
var w = new Window ("dialog","TEXT TEST");
w.orientation = 'row';
w.alignment='top';
w.pnl = w.add('panel', undefined, undefined, {borderStyle:'white'});
w.g15 = w.pnl.add('group');
w.g15.alignment='center';
w.g15.st1 = w.g15.add('statictext',undefined,'');
w.g15.et1 = w.g15.add('edittext');
w.g15.et1.text = 'TEST';
w.g15.et1.preferredSize=[300,20];
w.g20 = w.pnl.add('group');
w.g20.alignment='center';
w.g20.bu1 = w.g20.add('button',undefined,'OK');
w.g20.bu1.preferredSize=[147,25];
w.g20.bu2 = w.g20.add('button',undefined,'Close', { name: "cancel" });
w.g20.bu2.preferredSize=[147,25];
w.g20.bu1.onClick=function(){
var txtLayer = activeDocument.artLayers.add();
txtLayer.kind = LayerKind.TEXT;
txtLayer.textItem.size = 30;
txtLayer.textItem.font = "ArialNarrow"; /// CHANGE FONT MANUAL
var TXTColor = new SolidColor;
TXTColor.rgb.hexValue = '00ffc8';
txtLayer.textItem.color = TXTColor;
var X = ((activeDocument.width/100)*1);
var Y = ((activeDocument.height/100)*6);
txtLayer.textItem.position = new Array( X, Y);
txtLayer.textItem.contents = "TEST";
var LB=activeDocument.activeLayer.bounds;
var Height = LB[3].value - LB[1].value;
var Width = LB[2].value - LB[0].value;
activeDocument.selection.select([[LB[0],LB[1]], [LB[2],LB[1]], [LB[2],LB[3]], [LB[0], LB[3]]], SelectionType.REPLACE, 0, false);
activeDocument.selection.deselect();
activeDocument.flatten();
preferences.rulerUnits = originalRulerUnits;
w.close();
}
w.show();
}
Copy link to clipboard
Copied
Copy link to clipboard
Copied
Tom_Winkelmann
I need it because I'm creating an html panel
and I need to select the text as described above.
Copy link to clipboard
Copied
nobody can help me in this request.
Copy link to clipboard
Copied
What is the problem?
You can get a list if the available fonts via app.fonts and populate the dropdownList with the names or postScriptNames.
Copy link to clipboard
Copied
Maybe I explained myself wrong
I know what you have entered
my problem is that I don't want to preset the font
but I want to select it from the drop down menu
as in the video.
Copy link to clipboard
Copied
Copy link to clipboard
Copied
Mr. r-bin
I would like to select the font in the photoshop window
and I would like the chosen one to be applied
however I think it can't be done
that is not possible
Copy link to clipboard
Copied
setTypeToolStyle ('ArialNarrow', 30, '00ffc8' )
function setTypeToolStyle (fontName, fontSize, RGBhexColor) {
s2t = stringIDToTypeID;
(r = new ActionReference()).putClass(s2t('typeCreateOrEditTool'));
(d = new ActionDescriptor()).putReference(s2t('target'), r);
executeAction(s2t('select'), d, DialogModes.NO);
(r = new ActionReference()).putClass(s2t("typeCreateOrEditTool"));
(d = new ActionDescriptor()).putReference(s2t("target"), r);
(d4 = new ActionDescriptor()).putUnitDouble(s2t("size"), s2t("pointsUnit"), fontSize);
(d3 = new ActionDescriptor()).putDouble(s2t("red"), parseInt(RGBhexColor.substr(0, 1), 16));
d3.putDouble(s2t("grain"), parseInt(RGBhexColor.substr(2, 2), 16));
d3.putDouble(s2t("blue"), parseInt(RGBhexColor.substr(4, 2), 16));
d4.putObject(s2t("color"), s2t("RGBColor"), d3);
d4.putString(s2t("fontPostScriptName"), fontName);
(d2 = new ActionDescriptor()).putObject(s2t("textStyle"), s2t("textStyle"), d4);
(d1 = new ActionDescriptor()).putObject(s2t("textToolCharacterOptions"), s2t("null"), d2);
d.putObject(s2t("to"), s2t("target"), d1);
executeAction(s2t("set"), d, DialogModes.NO);
}