Copy link to clipboard
Copied
Can someone plz share how to change size and color of "staticText" object??
function buildUI(thisObj) {
var myPanel = (thisObj instanceof Panel) ? thisObj:new Window('palette', 'Stress Reducers',undefined, {resizable: true});
var txt=myPanel.add("staticText",[0,0,100,20],"txt");
//txt. newFont, fontSize,color?????
return myPanel;
}
var myToolsPanel = buildUI(this);
I did a quick test on a PC at the office and it seems that Gill Sans is not a stock PC font. You might comment those out or change them to a stock font like Helvetica or something. Once I removed that it launched on PC just fine.
Copy link to clipboard
Copied
I haven't done font size, but color you can do like this:
var txt=myPanel.add("staticText",[0,0,100,20],"txt");
var theColorArray = [1, 0.1, 0.2, 1];
var g = txt.graphics;
var c = g.newPen(g.PenType.SOLID_COLOR,theColorArray,1);
g.foregroundColor = c;
Specifying the font attributes is covered in the JavaScript Tools Guide. Please post an example if you figure out how to make it work.
Dan
Copy link to clipboard
Copied
You setup a new font like so...
var arielBold24Font = ScriptUI.newFont("Arial", ScriptUI.FontStyle.BOLD, 24);
Apply it to your text like so...
text.graphics.font = arielBold24Font;
Copy link to clipboard
Copied
Here's a better example of color and font use.
var win = new Window("palette", "Fonts", undefined);
win.orientation = "column";
var winGraphics = win.graphics;
var red = winGraphics.newPen(winGraphics.BrushType.SOLID_COLOR, [1,0,0], 1);
var blue = winGraphics.newPen(winGraphics.BrushType.SOLID_COLOR, [0,0,1], 1);
var gray = winGraphics.newPen(winGraphics.BrushType.SOLID_COLOR, [0.5,0.5,0.5], 1);
//Create fonts
var ariaBold24Font = ScriptUI.newFont("Arial", ScriptUI.FontStyle.BOLD, 24);
var arialReg10Font = ScriptUI.newFont("Arial", ScriptUI.FontStyle.REGULAR, 10);
var arialItalic18Font = ScriptUI.newFont("Arial", ScriptUI.FontStyle.ITALIC, 18);
var gillSansBold20Font = ScriptUI.newFont("Gill Sans", ScriptUI.FontStyle.BOLD, 20);
//Sample text
var a = win.add("statictext", undefined, "abcdefghijklmnopqrstuvwxyz");
var b = win.add("statictext", undefined, "abcdefghijklmnopqrstuvwxyz");
var c = win.add("statictext", undefined, "abcdefghijklmnopqrstuvwxyz");
var d = win.add("statictext", undefined, "abcdefghijklmnopqrstuvwxyz");
var e = win.add("statictext", undefined, "abcdefghijklmnopqrstuvwxyz");
var f = win.add("statictext", undefined, "abcdefghijklmnopqrstuvwxyz");
//Apply font styles
a.graphics.font = ariaBold24Font;
b.graphics.font = arialReg10Font;
c.graphics.font = arialItalic18Font;
d.graphics.font = gillSansBold20Font;
e.graphics.font = ariaBold24Font;
f.graphics.font = gillSansBold20Font;
//Apply color
a.graphics.foregroundColor = blue;
e.graphics.foregroundColor = red;
f.graphics.foregroundColor = gray;
win.center();
win.show();
Copy link to clipboard
Copied
Perfecto!!!! Thanks man.
Copy link to clipboard
Copied
Hi David
I executed your script directly and got this below result.
Colors are fine .
Fonts not working... ???
Copy link to clipboard
Copied
Ok, first thing, what version AE are you using? I tested this in AECC 2014.
Second, and it's probably an obvious one, are the fonts you are trying installed and/or spelled correctly in the code? It is case sensitive I believe.
Copy link to clipboard
Copied
Am using the same version as well..
AE2014..Windows 8.1
Copy link to clipboard
Copied
I did a quick test on a PC at the office and it seems that Gill Sans is not a stock PC font. You might comment those out or change them to a stock font like Helvetica or something. Once I removed that it launched on PC just fine.
Copy link to clipboard
Copied
Same for me with InDesign CC 2018 and 2019 on macOS 10.14. Seems, that Adobe have broken ScriptUI.newFont().
Copy link to clipboard
Copied
Right, it is broken with all versions of CC. Also with InDesign, PhotoShop, Illustrator etc.pp.
At InDesign UserVoice there is a bug report about this that needs your support. Add your voice here:
And vote for fixing the bug.
Regards,
Uwe
Copy link to clipboard
Copied
I'm on a Mac. This appears to work with CS6 but does not work with CC 2017 as I got the same result as manjunathk23388540. If there is a way to change the font of a statictext item in CC 2017, I haven't found it.
Copy link to clipboard
Copied
Got it!!
Thanks for the reply Dan!!