Skip to main content
Participant
September 23, 2021
Question

how to change text weight using expression

  • September 23, 2021
  • 1 reply
  • 634 views

I am using following code to create timer using slider and expression.

format I want it to be in is this 00m 00s but I am not able to change weight and size of 'm' and 's'. It is taking default as 00m 00s
can anybody help me out ?

 

 

slider = effect("Slider Control")("Slider");

seconds = Math.floor(slider%60);
minutes = Math.floor(slider/60);

function addZero(n) {
if(n < 10) {
return "0" + n
} else {
return n;
}
}

if (slider > 0) {
addZero(minutes) + "m " + addZero(seconds)+ "s"
} else {
"0m 0s"
}

This topic has been closed for replies.

1 reply

Community Expert
September 23, 2021

The expression language tools for formatting text are currently limited to controlling the entire text layer. You can look at a text layer and copy the text properties of a single letter, but you can only apply that formatting to all of the text on another layer.

 

The solution to your problem is to use 4 text layers, preferably all set to monospaced fonts, one layer for Minutes, one for seconds, one for the M, and one for the S. Then you keep them lined up using sourceRectAtTime() and some padding or you write your expressions so that the seconds' layer always has two characters and you manually line them up and use parenting to keep them together. A monospaced font will keep the distance between the two seconds digits the same so the digits would not bounce around. 

Mathias Moehl
Community Expert
Community Expert
September 29, 2021

Rick is right. One little extra tip: If you want to use the workaroud with mutiple text layers, but hesitate to write your own sourceRectAtTime expressions to connect the texts, you can use my (paid) extension Pins & Boxes for that.

Just create a pin at the right border of the first text and parent the second text to it. Then create a pin on the right edge of the second text and parent the third one to it etc.

 

Mathias Möhl - Developer of tools like BeatEdit and Automation Blocks for Premiere Pro and After Effects