Skip to main content
Inspiring
January 23, 2025
Answered

extendScript: How you can edit a font in MOGRT

  • January 23, 2025
  • 4 replies
  • 930 views

I created a MOGRT in after effect. Simple. It has a text field, as well as the ability to edit the font: size, font itself, and set bold, italic and AllCaps.
When I add this MOGRT to the timeline, I would like to change the font and font size. How can I do this except through a JSON object?

i.e. I can do
getValue(), then
JSON.parce(), replace the necessary parameters,
JSON.stringify()
and apply the changed string to the parameter.

But on some computers (it doesn't matter on macOS or windows) there were problems with inserting multiline text. if it is inserted just through setValue('multilinText') - everything is fine... But how to edit the font size or change the font itself?

Correct answer Aleksei5C75

In other words, you want to say that you can't change font or size except via JSON.

4 replies

Roland Kahlenberg
Legend
January 27, 2025

I've had success with CSV. 

Here's a sample - 

DS,component,semanticName,fontName,fontSize,leading,leadingScalar,tracking,startDate
CreativeCOW,ParaText_A,Headline,MyriadPro-Bold,120,80,1.2,30,June11-2023
CreativeCOW,ParaText_A,subHeadline - 0,MyriadPro-Bold,32,NA,NA,42,June11-2023
CreativeCOW,ParaText_A,subHeadline - 1,MyriadPro-Regular,32,NA,NA,42,June11-2023
CreativeCOW,ParaText_A,subHeadline - 2,MyriadPro-Regular,32,NA,NA,42,June11-2023
CreativeCOW,ParaText_A,Para Text -1,MyriadPro-Regular,34,34,1.2,34,June11-2023
CreativeCOW,ParaText_A,Para Text -2,MyriadPro-Regular,34,34,1.2,34,June11-2023
CreativeCOW,ParaText_A,ParaText Highlight -1,MyriadPro-Regular,30,30,1.2,30,June11-2023
CreativeCOW,ParaText_A,ParaText Highlight -2,MyriadPro-Bold,30,30,1.2,30,June11-2023
CreativeCOW,ParaText_A,Footer- CREATIVE,MyriadPro-Regular,36,20,1.2,36,June11-2023
CreativeCOW,ParaText_A,Footer- COW,MyriadPro-Bold,36,20,1.2,36,June11-2023
CreativeCOW,ParaText_A,Footer- .NET,MyriadPro-Regular,36,20,1.2,36,June11-2023
CreativeCOW,ParaText_A,Footer- Quote,MyriadPro-Semibold,32,15,1.2,32,June11-2023
CreativeCOW,ParaText_A,Quote_subText1,MyriadPro-Semibold,32,28,1.2,32,June11-2023

And if you drop the CSV into the AE Timeline and your Expressions reference the timeline instance of the CSV/data, in PPro, you can load up an alternative CSV from the MoGRT (Properties Panel in v25 - Essential Graphics Panel v24 and earlier), from a Timeline instance of the MoGRT.

HTH


Very Advanced After Effects Training | Adaptive & Responsive Toolkits | Intelligent Design Assets (IDAs) | MoGraph Design System DEV
Inspiring
January 27, 2025

I know what you're talking about, but it's not the answer.
Now I can change everything via JSON. But it works with a single line of text - always, but with multiline text in several lines - not always. and although I do not plan multiline text, but I would like to know how to properly change the font, size, and other parameters without JSON.parse()....

Inspiring
January 25, 2025

So how to change font size and font itself in this case?

Bruce Bullis
Legend
January 25, 2025

Earlier, you implied that your JSON solution worked on some computers, but not others:

But on some computers...


That suggests that your method can work, and (as I mentioned) the next step should be for you to figure out the difference between those systems on which your approach works, and those on which it does not.

Aleksei5C75AuthorCorrect answer
Inspiring
January 27, 2025

In other words, you want to say that you can't change font or size except via JSON.

Bruce Bullis
Legend
January 23, 2025

But on some computers...

I think the key will be in determining what makes those 'some computers', special.

One possibility: the global ExtendScript JSON object is only available if the Libraries panel is currently visible. For more reliable JSON object availability, you may wish to use Douglas Crockford's JSON2.js

Inspiring
January 24, 2025

I apologize, but that wasn't the question.
I always have JSON integrated directly into the code at the very beginning of the file. Always.

Judging by these posts ( this and this, and a few others )- using JSON conversion is considered not the best result. and kind of not even supported. So how to change font size and font itself in this case?

Or is it still necessary to use JSON conversion to solve these problems?

Bruce Bullis
Legend
January 24, 2025

I'm glad you're not relying on the unreliable global JSON object. 🙂

Determining the difference(s) between those systems on which you see the failure, and those on which you do not, remains the best approach to resolving the issue.

Peru Bob
Community Expert
Community Expert
January 23, 2025

@Bruce Bullis 

Can you help here?