Copy link to clipboard
Copied
Hi,
When using a text box to house an article title my desired format is to change the size of the font for each line so that it fits the entire width of the text box but doesn't alter letter spacing. Is there an easy way to do this as I'm currently altering each line of text manually.
Thanks
You might be able to script it, select the entire line and run this script:
var doc = app.documents.item(0);
var s = doc.selection;
var i = .1;
if (s[0] == null || s[0].lines.length>1) {
alert("Please select a single line of text")
}else{
var l = s[0].lines[0]
while (s[0].lines.length==1) {
l.pointSize = l.pointSize + i
}
l.pointSize = l.pointSize - i
}
Copy link to clipboard
Copied
You might be able to script it, select the entire line and run this script:
var doc = app.documents.item(0);
var s = doc.selection;
var i = .1;
if (s[0] == null || s[0].lines.length>1) {
alert("Please select a single line of text")
}else{
var l = s[0].lines[0]
while (s[0].lines.length==1) {
l.pointSize = l.pointSize + i
}
l.pointSize = l.pointSize - i
}
Copy link to clipboard
Copied
Hi Rob,
Thanks for this, it's a big help! It's almost there but it doesn't seem to like when I do it on a sinlge word on a line of it's own, I get the below error and the hgihlighted text disappears:
The other issue that highlights is that I can't then undo back to the position prior to running the script.
Thanks again for your help on this
Copy link to clipboard
Copied
Sorry, it would not work for a single word because the script is checking for the line to break and a single word or character wouldn’t necessarily break. Maybe someone else will have a better idea.
Copy link to clipboard
Copied
Ok, thanks for your help it has made a big difference!