|
|
Thanks Mathias!
This works much better.
But I think I may have stumbled into a limitation in MOGRTs. It seems they
don't support line breaks in text fields in Premiere, so the user will have
to split the text manually and enter in different text fields for every line
break.
If I enter the following text in Premiere:
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod
tempor incididunt ut labore et dolore magna aliqua.
Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut
aliquip ex ea commodo consequat.
This is what I get back:
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod
tempor incididunt ut labore et dolore magna aliqua.
So the second line is gone.
Bummer.
I tried with both area text and point text. No luck.
/jarle
_________________________________
Mathias Mφhl wrote:
You can split the text at linebreaks and then apply dans processing to each
of the parts separately:
txt = thisComp.layer("Source Text").text.sourceText;
n = thisComp.layer("Controls").effect("Text width")("Slider");
function breakToGivenLength(txt,n){
var outStr = "";
var newLine = ""
var splt = txt.split(" ")
for (var i = 0; i < splt.length; i++){
if ((newLine + " " + splt[i]).length > 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;
}
return outStr;
}
lines = txt.split(/|\r|\n|\x03/);
for(var i=0; i< lines.length; i++){
lines[i]=breakToGivenLength(lines[i],n);
}
lines.join("\n");
Note that this still does not deal properly at tabs, for example (it only
breaks at simple line breaks but not at tabs).
Cheers,
Mathias
|
|