-
Dynamic Line Breaks and Measuring Individual Line Lengths
Hello good people!
I’m currently trying to get point text to add a line break after a set number of characters – this much works fine, But then I want to solve for the length of each new line, for a shape layer to fill in behind individual lines of text.
While I have two different scripts created by the incredible Dan Ebberts, I can’t seem to figure out how to combine them. It is possible, that it would only be able to measure the length of the original line before the dynamic line breaks are added through expressions though.
Alternately, if it broke the text source into multiple point text layers, that would achieve the same effect. Any ideas?
Here’s what I’m working with:
//Dynamic Line Break
txt = value;
n = 20;
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;//Line Length Measurement
if (time < 0){
s = value.split("\r");
txt = ""
for (i = 0; i < s.length; i++){
if (time > -10*(i+1)){
txt = s[i];
break;
}
}
txt;
}else