Text properties expressions

Community Beginner ,
Feb 07, 2022 Feb 07, 2022

Copy link to clipboard

Copied

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);
TOPICS
Expressions , Scripting

Views

58

Likes

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
Adobe Community Professional ,
Feb 07, 2022 Feb 07, 2022

Copy link to clipboard

Copied

Does this work - for the last line?

 

style.setLeading(setLead).text.sourceText

Motion Graphics Brand Guidelines & Motion Graphics Responsive Design Toolkits

Likes

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
Community Beginner ,
Feb 08, 2022 Feb 08, 2022

Copy link to clipboard

Copied

LATEST

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)
};

Likes

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