Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions AE2024.6.2 – Expression Removing Second Font in line

  • AE2024.6.2 – Expression Removing Second Font in line

    Posted by Lukasz Pason on November 13, 2024 at 1:52 am

    On my single line I need to use a second font for registration marks and the typeface is being removed with this expression applied to it. I can not upgrade AE and I’m not sure why the code is removing the second typeface or how to fix it.

    X = text.sourceText;
    F = Math.round(time * effect("Blink Speed")("Slider") % 1); 
    L = X.length;
    T = time * effect("Speed")("Slider") - effect("Start At")("Slider") * effect("Speed")("Slider");
    
    Cursor = " ";
    if (F==1 | T>0) Cursor = " | ";
    if (T>=L) Cursor = " ";
    if (T>0) X.substr(0,T) + Cursor
    else Cursor
    Lukasz Pason replied 4 weeks, 1 day ago 3 Members · 5 Replies
  • 5 Replies
  • Yoan Boisjoli

    November 13, 2024 at 2:13 am

    Hi Lukasz! So you would like to have a different font for the cursor without upgrading to the new After Effects 2025 which supports the per character expression styling?

  • Dan Ebberts

    November 13, 2024 at 2:22 am

    Unless you’re taking advantage of the new per-character styling feature in AE 2025, whenever you apply an expression to the source text property, all characters get the same styling as the first character.

  • Yoan Boisjoli

    November 13, 2024 at 2:41 am

    if you ever consider upgrading, here’s an expression that works for having 2 different fonts. I also added an option for controlling the font size of the cursor:

    var X = text.sourceText;

    var F = Math.round(time * effect("Blink Speed")("Slider") % 1);

    var L = X.length;

    var T = time * effect("Speed")("Slider") - effect("Start At")("Slider") * effect("Speed")("Slider");

    // Define the main text and cursor with distinct styles

    var baseStyle = X.style.setFont("Helvetica-Bold"); // Main font

    var cursorFont = "CourierBOLD"; // Cursor font

    var Cursor = " ";

    if (F == 1 || T > 0) Cursor = "|";

    if (T >= L) Cursor = " ";

    // Combine the text with the cursor

    var displayText = T > 0 ? X.substr(0, T) + Cursor : Cursor;

    // Apply styling

    var styledText = baseStyle.setText(displayText);

    // Apply the cursor font style only to the cursor portion

    if (Cursor.trim() != "") {

    styledText = styledText.setFont(cursorFont, displayText.length - Cursor.length, Cursor.length).setFontSize(100, displayText.length - Cursor.length, Cursor.length);

    }

    // Return the final styled text

    styledText;

  • Lukasz Pason

    November 13, 2024 at 6:06 pm

    Got it. Thanks Dan. I’ll have to find a new approach to my setup then. We are unable to upgrade the team to the latest.

  • Lukasz Pason

    November 13, 2024 at 6:07 pm

    This is great! Thank you! I wish we could upgrade to the latest but we are locked in to 2024 at the moment.

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