Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Line break if text is bigger then fixed width

Community Beginner ,
Jul 13, 2017 Jul 13, 2017

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;

  }else{

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

    newLine += splt;

  }

}

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

7.3K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Advisor , Aug 02, 2017 Aug 02, 2017

Tobiasvk,

Maybe I'm misunderstanding the issue, but...

Can't you just drag out a text box (not just 'click and type') to be just slightly smaller than the size of your background shape?

Any text entered in Premiere via the Essentials Graphic panel would then word-wrap into that text box.
Or are you trying to do something else?

Translate
LEGEND ,
Jul 13, 2017 Jul 13, 2017

Well, the code obviously looks for the first space to determine the split. You would have to modify it considerably to make it work with real sentences, meaning you need some regular expression or nested string processing that ignores any spaces within the given range and still makes sure full words remain tied together. It's not as simple as you may have thought. I don't have time at the moment, but if you're not in a rush and I don't forget perhaps I can have a look at it over the weekend.

Mylenium

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jul 17, 2017 Jul 17, 2017

That would be very nice, I wasn't able to make a code that works.

I'm pretty new to complex expressions in After Effects, so any help would be more then appreciated!

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Employee ,
Aug 01, 2017 Aug 01, 2017

Hi tobiasvk,

Are you still facing this problem? If not, let us know how you solved it. If so, please let us know so we can assist you further.

Thanks,

Kevin

Kevin Monahan - Sr. Community & Engagement Strategist – Pro Video and Audio
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Aug 02, 2017 Aug 02, 2017

Hi Kevin,

I'm still facing the same problem, so any help would be much appreciated.

Kind regards,

Tobiasvk

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advisor ,
Aug 02, 2017 Aug 02, 2017

Tobiasvk,

Maybe I'm misunderstanding the issue, but...

Can't you just drag out a text box (not just 'click and type') to be just slightly smaller than the size of your background shape?

Any text entered in Premiere via the Essentials Graphic panel would then word-wrap into that text box.
Or are you trying to do something else?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Aug 03, 2017 Aug 03, 2017
LATEST

Who, I'm feeling stupid.

Sometimes the simplest solution are the beste.

Thanks!

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines