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

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

Enthusiast ,
Mar 02, 2023 Mar 02, 2023

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
2.4K
Translate
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.pngexpand image

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

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

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

Hello -

 

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

button1.graphics.font = ScriptUI.newFont ("Helvetica", "Bold", 30);
Translate
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

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

Translate
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
quote
button1.graphics.font = ScriptUI.newFont ("Helvetica", "Bold", 30);

By dimitri_cas

 

that should work, have you tried with different fonts?

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

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

Translate
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

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

 

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

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

 

 

Translate
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

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.pngexpand image

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

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

 

Translate
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

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

Translate
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
Enthusiast ,
Apr 26, 2023 Apr 26, 2023
LATEST

OK… Thank you Carlos

Translate
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