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

Problem changing font size

Contributor ,
Apr 22, 2015 Apr 22, 2015

Copy link to clipboard

Copied

Hello,

I've been working on a script and have the following line of code, where I create and want to edit the font size of the just created text. However I can't seem to get it work. I can change some of the other text properties, which is why it is stumping me.

var finishText = thisComp.layers.addText(finishTime); 

    var textProp = finishText.property("Source Text");

    var textDocument = textProp.value;

    textDocument.resetCharStyle();

    textDocument.fontSize = 36;

    textProp.setValue(textDocument);

Help appreciated! Thanks!

TOPICS
Scripting

Views

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

Enthusiast , Apr 22, 2015 Apr 22, 2015

Sup Nathan,

I`ve tried the following code and it seems like everything work properly.

var thisComp = app.project.activeItem;

var finishText = thisComp.layers.addText("finishTime");   

    var textProp = finishText.property("Source Text"); 

    var textDocument = textProp.value; 

    textDocument.resetCharStyle(); 

    textDocument.fontSize = 50; 

    textProp.setValue(textDocument); 

Can you tell us your AE version?

Votes

Translate

Translate
Enthusiast ,
Apr 22, 2015 Apr 22, 2015

Copy link to clipboard

Copied

Sup Nathan,

I`ve tried the following code and it seems like everything work properly.

var thisComp = app.project.activeItem;

var finishText = thisComp.layers.addText("finishTime");   

    var textProp = finishText.property("Source Text"); 

    var textDocument = textProp.value; 

    textDocument.resetCharStyle(); 

    textDocument.fontSize = 50; 

    textProp.setValue(textDocument); 

Can you tell us your AE version?

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
Contributor ,
Apr 22, 2015 Apr 22, 2015

Copy link to clipboard

Copied

I'm using CC 2014.

I would like to point out that finishTime is a variable established earlier in my code that basically puts a stopwatch looking timer into the text layer. Any ideas as to what it might be? It still isn't working for me

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
Enthusiast ,
Apr 22, 2015 Apr 22, 2015

Copy link to clipboard

Copied

I guess the problem is under finishTime variable. Can`t tell you exactly without code example, but you can try adding .toString to this one:

var finishText = thisComp.layers.addText(finishTime.toString);

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
Contributor ,
Apr 22, 2015 Apr 22, 2015

Copy link to clipboard

Copied

if(minutes == 0 && seconds == 0 && milliseconds == 0){

           var finishTime = "00:00.00";

        }

   

    if(minutes == 0 && seconds == 0){

           var finishTime = "." + milliseconds;

        }

   

    if(minutes == 0 && milliseconds == 0){

           var finishTime = seconds + ".00";

        }

    

     if(seconds == 0 && milliseconds == 0){

           var finishTime = minutes + ":00.00";

         }

   

    if(minutes == 0){

         var finishTime = seconds + "." + milliseconds;

        }

     if(milliseconds == 0){

        var finishTime = minutes + ":" + seconds + ".00";

         }

alert(finishTime);

    thisComp.openInViewer();

    var finishText = thisComp.layers.addText(finishTime); 

    var textProp = finishText.property("Source Text");

    var textDocument = textProp.value;

    textDocument.resetCharStyle();

    textDocument.fontSize = 36;

    textProp.setValue(textDocument);

toString appears not to work. It's a bit messy, but this is kind of how I get the var finishTime. i confirmed with an alert that it is indeed working properly. With the code how it is, everything but the font size change works.

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
Enthusiast ,
Apr 22, 2015 Apr 22, 2015

Copy link to clipboard

Copied

Well, that`s weird...

I`ve tried this code with deffirent condition on several AE versions including 13.2 and it works fine.

Tried to reboot/restart AE/clear cache? Also are you on Mac?

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
Contributor ,
Apr 22, 2015 Apr 22, 2015

Copy link to clipboard

Copied

I'm running Windows 7. I rebooted my computer, cleared the caches, and it still doesnt work.... hmmmm


Update: I added .value to the end of the var textProp line. It seems to change the font size, but cause problems in other places.


Another Update: I had a dumb moment and forgot there was a function after this that changes the font size... Thanks for your help Alex!

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
Enthusiast ,
Apr 22, 2015 Apr 22, 2015

Copy link to clipboard

Copied

I`m glad that you solved 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
Guest
Apr 23, 2015 Apr 23, 2015

Copy link to clipboard

Copied

setValue twice can avoid this problem when you create the text layer without text string.Another method is to create the text layer with text string.I posted a thread a few days ago in this forum,so you can check for 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 ,
Feb 22, 2023 Feb 22, 2023

Copy link to clipboard

Copied

LATEST

как

quote

I posted a thread a few days ago in this forum,so you can check for it.


By @Deleted User

Where is this topic? Give me a link please?

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