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

Altering text size to fit width of text frame

Community Beginner ,
Feb 22, 2021 Feb 22, 2021

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

TOPICS
How to , Type

Views

226

Translate

Translate

Report

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

Community Expert , Feb 22, 2021 Feb 22, 2021

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
}

 

 

Screen Shot 11.pngScreen Shot 12.png

Votes

Translate

Translate
Community Expert ,
Feb 22, 2021 Feb 22, 2021

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
}

 

 

Screen Shot 11.pngScreen Shot 12.png

Votes

Translate

Translate

Report

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 ,
Feb 22, 2021 Feb 22, 2021

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:

 

Niall5E7D_0-1614017485799.png

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

 

Votes

Translate

Translate

Report

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 Expert ,
Feb 22, 2021 Feb 22, 2021

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.

Votes

Translate

Translate

Report

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 ,
Feb 22, 2021 Feb 22, 2021

Copy link to clipboard

Copied

LATEST

Ok, thanks for your help it has made a big difference! 

Votes

Translate

Translate

Report

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