Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Expression to set font/size of just one line of text

Tagged: 

  • Expression to set font/size of just one line of text

    Posted by Paul Roper on November 25, 2024 at 1:43 pm

    Hello,

    I have a block of text (3 lines) and I want to be able to set the font etc. of the middle line. I can split it into three lines easily like this:

    blurb = text.sourceText;

    var firstLine = blurb.split("\r")[0];

    var secondLine = blurb.split("\r")[1];

    var thirdLine = blurb.split("\r")[2];

    firstLine + "\r" + secondLine + "\r" + thirdLine

    …but if I try something like this:

    blurb = text.sourceText;

    bigblurb = text.sourceText.style.setFontSize(400);

    var firstLine = blurb.split("\r")[0];

    var secondLine = bigblurb.split("\r")[1];

    var thirdLine = blurb.split("\r")[2];

    firstLine + "\r" + secondLine + "\r" + thirdLine

    …I get the error in line 4: “bigblurb.split is not a function”. I’ve tried moving the “setFontSize” to the end – ie. appended to the end of secondLine in the last line of the expression, but that doesn’t work either. Why is this not working??
    Any help would be greatly appreciated, thanks!

    Brie Clayton
    replied 2 weeks, 3 days ago
    3 Members · 3 Replies
  • 3 Replies
  • Dan Ebberts

    November 25, 2024 at 2:09 pm

    I think if you want to set the font size of the middle line, you just need to do something like this:

    blurb = text.sourceText;
    splitBlurb = blurb.split("\r");
    style.setFontSize(400,splitBlurb[0].length+1,splitBlurb[1].length)
  • Paul Roper

    November 25, 2024 at 2:13 pm

    Perfect, thanks!

    In fact I was just reading (on the actual Adobe help page!) about appending the numbers to the end of the function to specify the location but you saved me the head-scratching!
    As ever, thanks Dan!

  • Brie Clayton

    November 25, 2024 at 4:30 pm

    Thank you for solving this, Dan!

We use anonymous cookies to give you the best experience we can.
Our Privacy policy | GDPR Policy