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

• Change text size of a button (created via Javascript)

Engaged ,
Mar 02, 2023 Mar 02, 2023

Copy link to clipboard

Copied

Hello -

 

I was wondering how I could change the texte size of a button.

I tried already sveral "things" but nothing seems to work.

// PALETTE
// =======
var myPalette = new Window("palette");
    myPalette.text = "DC TOOLS";
    myPalette.orientation = "column";
    myPalette.alignChildren = ["center","top"];
    myPalette.spacing = 5;
    myPalette.margins = 5;

var button1 = myPalette.add("button", undefined, "3D", {name: "button1"});
    button1.graphics.font = ScriptUI.newFont ("Helvetica", "Bold", 30);   // <— From p78 https://www.daube.ch/docu/fm-documentation/ExtendScript/ScriptUI_for_Dummies-%5BPeterKahrel%5D.pdf
// button1.pointSize = 30;			—>  Doesn't work, at least doesn't change anything
// button2.text.font.size = "30pt";		—>  Doesn't work, at least doesn't change anything
// button2.text.characterAttributes.size = 30;	—>  Doesn't work, at least doesn't change anything
   button2.alignment = ["left","top"];

myPalette.frameLocation = [ 1850, 70 ];
myPalette.show();
TOPICS
Scripting

Views

1.6K

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

Community Expert , Mar 06, 2023 Mar 06, 2023

Hi Dimitri, I can confirm there's a problem with it. The below code works fine in the ESTK but it does nothing when run in Illustrator.

b.graphics.font = ScriptUI.newFont ("Minion Pro", "Italic", 60);

ai_vs_estk.png

Votes

Translate

Translate
Adobe
Guide ,
Mar 03, 2023 Mar 03, 2023

Copy link to clipboard

Copied

I don't understand the question.  Why not just use another ScriptUI.newFont() with a another font size?

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
Engaged ,
Mar 03, 2023 Mar 03, 2023

Copy link to clipboard

Copied

Hello -

 

Isn't what I have done here (or at least tried to do)?

button1.graphics.font = ScriptUI.newFont ("Helvetica", "Bold", 30);

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
Guide ,
Mar 03, 2023 Mar 03, 2023

Copy link to clipboard

Copied

Yes, that line should set font size to 30.  Is it not working?  

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 ,
Mar 03, 2023 Mar 03, 2023

Copy link to clipboard

Copied

quote
button1.graphics.font = ScriptUI.newFont ("Helvetica", "Bold", 30);

By @dimitri_cas

 

that should work, have you tried with different fonts?

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
Engaged ,
Mar 05, 2023 Mar 05, 2023

Copy link to clipboard

Copied

Hey Carlos -

Hey femkeblanco -

 

Thanks for your reply…

Nope, even with that line of code it doesn't change anything.

I tried "Verdana", "Tahoma", "Courier", …

Nothing changed

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
Guide ,
Mar 06, 2023 Mar 06, 2023

Copy link to clipboard

Copied

What about this

var font = "dialog";  // default font
var size1 = "30";
var size2 = "60";
var w = new Window("dialog");
var button1 = w.add("button", undefined, "button1");
button1.graphics.font = font + ":" + size1;
var button2 = w.add("button", undefined, "button2");
button2.graphics.font = font + ":" + size2;
w.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
Engaged ,
Mar 06, 2023 Mar 06, 2023

Copy link to clipboard

Copied

Hello again femkeblanco -

 

Strangely enough it looks exactly the same (cfr. screenshot).

I work on Mac PRO, OS Catalina (last available update), Illustrator 2022 (last update).

 

 

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 ,
Mar 06, 2023 Mar 06, 2023

Copy link to clipboard

Copied

Hi Dimitri, I can confirm there's a problem with it. The below code works fine in the ESTK but it does nothing when run in Illustrator.

b.graphics.font = ScriptUI.newFont ("Minion Pro", "Italic", 60);

ai_vs_estk.png

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
Engaged ,
Mar 07, 2023 Mar 07, 2023

Copy link to clipboard

Copied

Hey Carlos  🙂

 

Thank you again for your reply.

I thought I had gone mad (or even ore than currently 😉 )

 

Any chance Adobe will take a look at it?

 

Have a great day…

 

 

 

- Dimitri

 

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 ,
Mar 08, 2023 Mar 08, 2023

Copy link to clipboard

Copied

I think there is 99% chances they won't 🙂

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
Engaged ,
Apr 26, 2023 Apr 26, 2023

Copy link to clipboard

Copied

LATEST

OK… Thank you Carlos

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