Forum Replies Created

  • Matt Welton

    September 21, 2021 at 5:22 pm in reply to: Insert Line Break every X number of characters

    Dan, do you think what I’m trying to do above is possible?

  • Matt Welton

    September 17, 2021 at 3:25 pm in reply to: Insert Line Break every X number of characters

    For context, here is the expression I’m using.

    txt = value;
    n = effect("Height & Width")("Slider");
    outStr = "";
    newLine = ""
    splt = txt.split(" ")
    //convertBreak = thisComp.layer("Body Content").text.sourceText.replace(/"\r"/g,"§");
    //convertBreak = thisComp.layer("Body Content").text.sourceText.split("\r").join("§");
    for (i = 0; i < splt.length; i++){
    if ((newLine + " " + splt[i]).length > n){
    if (outStr != "") outStr += "\n";
    outStr += newLine;
    newLine = splt[i];
    }else{
    newLine += " " + splt[i];
    }
    }
    if (newLine != ""){
    if (outStr != "") outStr += "\n";
    outStr += newLine;
    }
    outStr;
    //REconvertBreak = thisComp.layer("Body Content").text.sourceText.replace("§",/"\r"/g);
    //ReconvertBreak = thisComp.layer("Body Content").text.sourceText.split("§").join("\r");

    You’ll notice some code is commented out — these were my (failed) attempts to find/replace carriage returns with a symbol, then run the code that determines where line breaks should go, then restore the symbols to carriage returns again.

    I also tried replacing \r with \n in the original code to see if that’d resolve whatever conflict was occurring, but that had no effect either.

  • Matt Welton

    September 17, 2021 at 1:07 am in reply to: Insert Line Break every X number of characters

    I’ve recently used this expression for a “textbox” .mogrt I’m making, but realized that if the inputted text has any return characters in it (i.e. manual line breaks) then the text in the subsequent paragraphs start getting line breaks in unusual places — as if the character count function gets thrown off somehow.

    There also appears to be a “space” character that’s placed in the very beginning of the text that doesn’t exist in the text itself.

    Does anyone have any ideas on how to remedy? The code is (unfortunately) a little outside of my ability, so I’m not sure how to troubleshoot it.

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