ADOBE AFTER EFFECTS: Forum Expressions Tutorials Creative Cloud

Setting Font and Font Size (style.setFont & style.setFontSize) AE 2020 issue

COW Forums : Adobe After Effects Expressions

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Ronan De Lacy
Setting Font and Font Size (style.setFont & style.setFontSize) AE 2020 issue
on Nov 21, 2019 at 2:47:16 pm
Last Edited By Ronan De Lacy on Nov 21, 2019 at 3:08:26 pm

Hello expressionists,

I'm having an issue setting the font and font size with the new expression features in AE 2020.

I have a text layer, with 2 drop down menus applied. One for the typeface, the other for font size. Both menus have a parseFloat expression applied to get there value form 2 dynamic text layers connected to a JSON file. Everything is working as it should with the parsed values.

The issue I'm facing is that I can only set either the font-size or the type-face, but not both. Below is the expression that I've applied to my Source Text. Both x and y work independently, but not together.

I think the problem is down to how I've structured the expression. I've tried to solve, but I'm lost. Any advice/help greatly appreciated.

Thanks in advance,
Ronan

var x = effect("type-face")("Menu").value;
var y = effect("font-size")("Menu").value;

if ( x === 1 ) {
style.setFont("Helvetica-Light");
} else if ( x === 2 ) {
style.setFont("Helvetica");

} else if ( x === 3 ) {
style.setFont("Helvetica-Bold");

} else if ( x === 4 ) {
style.setFont("HelveticaNeue-Thin");
};

if ( y === 1 ) {
style.setFontSize(240);
} else if (y === 2) {
style.setFontSize(200);
};


Return to posts index

Dan Ebberts
Re: Setting Font and Font Size (style.setFont & style.setFontSize) AE 2020 issue
on Nov 22, 2019 at 12:36:39 am

I haven't tested this, but try it this way:


var x = effect("type-face")("Menu").value;
var y = effect("font-size")("Menu").value;

if ( x === 1 ) {
style = style.setFont("Helvetica-Light");
} else if ( x === 2 ) {
style = style.setFont("Helvetica");
} else if ( x === 3 ) {
style = style.setFont("Helvetica-Bold");
} else {
style = style.setFont("HelveticaNeue-Thin");
}
if ( y === 1 ) {
style = style.setFontSize(240);
} else {
style = style.setFontSize(200);
}


Dan



Return to posts index

Ronan De Lacy
Re: Setting Font and Font Size (style.setFont & style.setFontSize) AE 2020 issue
on Nov 22, 2019 at 8:48:19 am

Dan, thanks so much. That did the trick!!

Cheers,
Ronan


Return to posts index

<< PREVIOUS   •   VIEW ALL   •   PRINT   •   NEXT >>
© 2019 CreativeCOW.net All Rights Reserved
[TOP]