Skip to main content
Known Participant
October 27, 2015
Answered

How to change size and color of "staticText"??

  • October 27, 2015
  • 1 reply
  • 5179 views

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);

This topic has been closed for replies.
Correct answer David Torno

Am using the same version as well..

AE2014..Windows 8.1


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.

1 reply

Dan Ebberts
Community Expert
Community Expert
October 27, 2015

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

Legend
October 28, 2015

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;

David TornoCorrect answer
Legend
October 28, 2015

Am using the same version as well..

AE2014..Windows 8.1


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.