I found this expression from Dan Ebberts, and it works beautifully until the
source text has line breaks.
After the line breaks, the first lines get shorter. It seems to add the
characters from the line above the break to the character count. See this
image:
https://www.dropbox.com/s/a842o913cxhyeua/LineBreakTrouble.png?dl=0 Is there a way to make this code aware of line breaks too, so that it just
keeps the line breaks from the source and starts on a new line with the
correct length?
The goal is that the user should just copy-paste text from a word document
or similar, into a field - and it should just work.
/jarle
txt = thisComp.layer("Source Text").text.sourceText;
n = thisComp.layer("Controls").effect("Text width")("Slider");
outStr = "";
newLine = ""
splt = txt.split(" ")
for (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;
}
outStr;
+---End of message---+
To unsubscribe send any message to <
ae-list-off@media-motion.tv>