Skip to main content
Inspiring
Jan 23, 2025 11:16 AM UTC
Answered

extendScript: How you can edit a font in MOGRT

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?

Aleksei5C75Correct answer
Inspiring
Jan 27, 2025 6:14 AM UTC

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

9 replies

Roland Kahlenberg
Legend
Jan 27, 2025 6:49 AM UTC

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


Translate
Very Advanced After Effects Training | Adaptive & Responsive Toolkits | Intelligent Design Assets (IDAs) | MoGraph Design System DEV
Inspiring
Jan 27, 2025 7:12 AM UTC

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

Translate
Inspiring
Jan 25, 2025 7:54 AM UTC

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

Translate
Bruce Bullis
Legend
Jan 25, 2025 3:35 PM UTC

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.

Translate
Aleksei5C75AuthorCorrect answer
Inspiring
Jan 27, 2025 6:14 AM UTC

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

Translate
Bruce Bullis
Legend
Jan 23, 2025 6:03 PM UTC

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

Translate
Inspiring
Jan 24, 2025 7:59 AM UTC

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?

Translate
Bruce Bullis
Legend
Jan 24, 2025 6:23 PM UTC

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.

Translate
Peru Bob
Community Expert
Community Expert
Jan 23, 2025 3:47 PM UTC

@Bruce Bullis 

Can you help here?

Translate