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

Change to font Weight (For example Arial-Bold)

Participant ,
Mar 28, 2019 Mar 28, 2019

Hello,

Im using this code and im trying to change weight font in my text layer.

var textProp = app.project.activeItem.layer(1).property("Source Text");

var textDocument = textProp.value;

textDocument.font = "Arial-Bold";

textProp.setValue(textDocument);

But this does not Changing the font to the "Arial-Bold" font,

What did I do wrong?

TOPICS
Scripting
2.0K
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

Advocate , Mar 28, 2019 Mar 28, 2019

It's not Arial-Bold, but rather Arial-BoldMT

var textProp = app.project.activeItem.layer(1).property("Source Text");

var textDocument = textProp.value;

textDocument.font = "Arial-BoldMT";

textProp.setValue(textDocument);

Translate
Advocate ,
Mar 28, 2019 Mar 28, 2019

It's not Arial-Bold, but rather Arial-BoldMT

var textProp = app.project.activeItem.layer(1).property("Source Text");

var textDocument = textProp.value;

textDocument.font = "Arial-BoldMT";

textProp.setValue(textDocument);

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
Participant ,
Mar 29, 2019 Mar 29, 2019

Thanks for your answer!

Yes it works good in this case,

But what should it do in the other situations?

like when i want the font to be "Arial-Narrow",

and "Arial-NarrowMT" not working.

So what is actually the method to work with weight font ?

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
Advocate ,
Mar 29, 2019 Mar 29, 2019
LATEST

Well, all you have to do is:

1. Set font you like manually.

2. Run this command to see what it prints.

3. Use this value in your script.

var textProp = app.project.activeItem.layer(1).property("Source Text");

var textDocument = textProp.value;

alert(textDocument.font)

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