6 Replies Latest reply on Aug 3, 2017 7:21 AM by tobiasvk

    Line break if text is bigger then fixed width

    tobiasvk

      Hey,

       

      I'm currently trying to make a text box element that can be used with live text in premiere.

      I tried tweaking the code that makes a line break after a fixed number of characters. ( https://forums.creativecow.net/thread/227/34484 )

       

      txt = value;

      s = thisLayer;

      n = 455;

      outStr = "";

      newLine = ""

      splt = txt.split(" ")

       

       

      for (i = 0; i < splt.length; i++){

        if ((s.sourceRectAtTime(time-s.inPoint,true).width / i ) > n){

          if (outStr != "") outStr += "\r";

          outStr += newLine;

          newLine = splt[i];

        }else{

          if (newLine != "") newLine += " ";

          newLine += splt[i];

        }

      }

      if (newLine != ""){

        if (outStr != "") outStr += "\r";

        outStr += newLine;

      }

      outStr;

       

      But the problem I get is that after it reaches the max width, it makes a line break after one word.

      Is there a way that it always breaks the sentence after it reaches the max width, so that you can have for lines breaks in total?

       

      Screen Shot 2017-07-10 at 11.03.10.png

       

      I hope you guys can help.

       

      Kind regards,

      Tobiasvk