• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

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

Explorer ,
Oct 27, 2015 Oct 27, 2015

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

TOPICS
Scripting

Views

4.2K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Advocate , Oct 28, 2015 Oct 28, 2015

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.

Votes

Translate

Translate
Community Expert ,
Oct 27, 2015 Oct 27, 2015

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advocate ,
Oct 27, 2015 Oct 27, 2015

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;

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advocate ,
Oct 27, 2015 Oct 27, 2015

Copy link to clipboard

Copied

Here's a better example of color and font use.

Screen Shot 2015-10-27 at 5.23.35 PM.png

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Oct 28, 2015 Oct 28, 2015

Copy link to clipboard

Copied

Perfecto!!!! Thanks man.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Oct 28, 2015 Oct 28, 2015

Copy link to clipboard

Copied

Hi David

I executed your script directly and got this below result.

Colors are fine .

Fonts not working... ???

Untitled-1 copy.jpg

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advocate ,
Oct 28, 2015 Oct 28, 2015

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Oct 28, 2015 Oct 28, 2015

Copy link to clipboard

Copied

Am using the same version as well..

AE2014..Windows 8.1

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advocate ,
Oct 28, 2015 Oct 28, 2015

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Feb 14, 2019 Feb 14, 2019

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().

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
May 02, 2019 May 02, 2019

Copy link to clipboard

Copied

LATEST

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:

unable to change font, size, style in Script UI, alignment problem with Image on button – Adobe InDe...

And vote for fixing the bug.

Regards,
Uwe

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Feb 02, 2017 Feb 02, 2017

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Oct 28, 2015 Oct 28, 2015

Copy link to clipboard

Copied

Got it!!

Thanks for the reply Dan!!

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines