Skip to main content
Participant
February 7, 2022
Question

Text properties expressions

  • February 7, 2022
  • 1 reply
  • 248 views

Hello everyone, I've been working on some templates and as I'm going through all the small bits and pieces I came across an issue that I haven't been able to fix. 

 

I have a text file with expressions that will (based on a checkbox) use two different fonts - This part is working fine 

 

I also have an expression to set the leading to a specific size based on our design guidelines - This is also working fine. 

 

But when I have both of them, only one is working properly. I've tried changing the place of the variables and so far, no luck... so any pointers or help on how to write more than one expression and having them both working would be really apreciated

 

here's my code: 

 

Text leading - 

txsz=thisComp.layer("Text").text.sourceText.style.fontSize; setLead = txsz*1.1; text.sourceText.style.setLeading(setLead);

 

Text font - 

var GTFont =text.sourceText.style.setFont("GTHaptikBold");
var ArialFont = text.sourceText.style.setFont("Arial-BoldMT");
var selec=effect("GT Haptik")("Checkbox");
 
if (selec == true) {
GTFont
} else {
ArialFont
};
 
Combined - In this case, the font works but not the leading 
txsz=thisComp.layer("Text").text.sourceText.style.fontSize;
setLead = txsz*1.1;
text.sourceText.style.setLeading(setLead);
var GTFont =text.sourceText.style.setFont("GTHaptikRegular");
var ArialFont = text.sourceText.style.setFont("ArialMT");
var selec=thisComp.layer("Themes").effect("Checkbox Control")("Checkbox");
 
if (selec == true) {
GTFont
} else if (selec == false){
ArialFont }else{ (ArialFont)
};
 
Combined 2 - In this case, the leading works but not the font. 
var txsz=thisComp.layer("Text").text.sourceText.style.fontSize;
setLead = txsz*1.1;
text.sourceText.style.setLeading(setLead);
var GTFont =text.sourceText.style.setFont("GTHaptikRegular");
var ArialFont = text.sourceText.style.setFont("ArialMT");
var selec=thisComp.layer("Themes").effect("Checkbox Control")("Checkbox");
 
if (selec == true) {
GTFont
} else if (selec == false){
ArialFont }else{ (ArialFont)
};
var txsz=thisComp.layer("Text").text.sourceText.style.fontSize;
setLead = txsz*1.1;
text.sourceText.style.setLeading(setLead);
This topic has been closed for replies.

1 reply

Roland Kahlenberg
Legend
February 8, 2022

Does this work - for the last line?

 

style.setLeading(setLead).text.sourceText

Very Advanced After Effects Training | Adaptive & Responsive Toolkits | Intelligent Design Assets (IDAs) | MoGraph Design System DEV
Eco82Author
Participant
February 8, 2022

Here's the final code that I used and it's working fine. I just had to add more styles to each option which I completely forgot you could do it 😉 

 

var txsz=thisComp.layer("Text").text.sourceText.style.fontSize;
var setLead = txsz*1.1;
var GTFont =text.sourceText.style
.setFont("GTHaptikRegular")
.setLeading(setLead)
var ArialFont = text.sourceText.style
.setFont("ArialMT")
.setLeading(setLead)
var selec=thisComp.layer("Themes").effect("Checkbox Control")("Checkbox");
 
if (selec == true) {
GTFont
} else { (ArialFont)
};