Skip to main content
Participant
February 7, 2020
Question

Script request: adjust tracking to maximize line width

  • February 7, 2020
  • 6 replies
  • 1268 views

I often face a situation where I've adjusted the tracking of entire paragraphs to eliminate widows, reduce the number of lines, etc. I typically find myself fine-tuning the tracking of individual lines, and I wonder if anyone has whipped up a script to max-min the line width to fit best.

 

For example, say the whole paragraph has -30 tracking applied. I'd love to be able to select a single line and run a script which finds the ideal value between -30 and 0 where the line doesn't overflow.

 

Doing this manually each time I need to adjust a line is tedious, and this seems like a good application of a binary or dichotomic algorithm. I'm not familiar enough with JSX or the Indesign DOM to write it though. A little help?

This topic has been closed for replies.

6 replies

Community Expert
February 10, 2020

Hi Lars,

just a hint: The main problem is the value of the used composer with a single paragraph.

If the text is not using one of the available single line composers it's hard to tell what will happen if you change anything with tracking. A binary algorithm approach could fail easily with the Adobe Paragraph Composer.

https://helpx.adobe.com/indesign/using/text-composition.html

 

Regards,
Uwe Laubender

( ACP )

Participant
February 13, 2020

Uwe (et al),

 

Would it not be possible to check the composer status, toggle the paragraph containing the selected line into single line composer mode if necessary, make the changes, then toggle it back if it was originally in paragraph composition mode?

Jongware
Community Expert
Community Expert
February 13, 2020

What purpose would changing the composer have? As soon as you change the composer, you might find that you don't need to fix something anymore, because the entire paragraph may run differently. (Or, more likely, you only have more issues to solve--not less.)

 

Paragraph Composers do not work per line, they work per paragraph. The "single line" in "Single Line Composer" is only to differ it from the Pararaph Composer. The SLC literally works on one line only before continuing with the next and forgetting everything about that previous line. The PC, on the other hand, breaks all lines in all possible ways and keeps a score for each line, so it can use the "best" score for the entire paragraph.

Participant
February 10, 2020

I appreciate these ideas. I still hope someone can point me in the right direction for a scripting solution for min-maxing tracking of single lines to fit (Even helpful would be a starting point, such as which property to use and what bounds are affected when a selected line overflows to the next)

brian_p_dts
Community Expert
Community Expert
February 10, 2020

I'd be happy to discuss developing a solution for a nominal fee. Please feel free to PM. 

Dave Creamer of IDEAS
Community Expert
Community Expert
February 8, 2020

I create a GREP setting in the paragraph style that applies a NoBreak character style to a set number of characters. 

I'm doing this from memory, but I believe ".[18]$" is the code (without quotes). The number, 18 in my example, would be adjusted based on column width, font, and type size. You can use words too, but I like character counts to prevent a couple of short words from slipping by. Then I let InDesign do its magic.

David Creamer: Community Expert (ACI and ACE 1995-2023)
David Popham
Participating Frequently
February 9, 2020

The code ".[18]$" will find any single character (including spaces) followed by either a "1" or an "8" at the end of a paragraph. Not sure that's applicable with regard to this case. I'm guessing ".{18}$" is what is intended, which would apply the No Break character style to the last 18 characters at the end of all paragraphs with that style.

Dave Creamer of IDEAS
Community Expert
Community Expert
February 9, 2020

Thank you--that's it. As I said, I was doing it from memory--which isn't what it use to be... <g>

David Creamer: Community Expert (ACI and ACE 1995-2023)
Mike Witherell
Community Expert
Community Expert
February 7, 2020

Instead of manually adjusting tracking (with or without scripting) a number of years ago I started adjusting the Hyphenation and Justification settings of the BodyCopy paragraph style. My recipe yields volumes of good-looking lines with only the rarest need to intervene:

 

Kern method: Optical

 

Hyphenation:

9 letters

3 before (for the upper line)

4 after (for the next line down)

1 hyphen limit (which precludes multiple consecutive hyphens on succeeding stacked lines)

1p6 (in case of left-alignment text)

and OFF, OFF, OFF go the switches forbidding hyphens on capitalized words, last words, breaks across columns

 

For Justification:

Word spacing: 80%, 100%, 120%

Letter spacing: -5%, 0%, 5%

Glyph scaling: 95%, 100%, 105%

 

Keep Lines Together: 2 effectively forbids widows/orphans

 

Some add a passive GREP Style to forbid too-short lines:

GREP Style: .+{20}$ applies a NoBreak Character Style

 

Your scripting request is essentially asking for these above features that are already possible in the BodyCopy paragraph style. (And if you already knew that, sorry for steering you off-course!)

Mike Witherell
Participant
February 7, 2020

I just checked out typefitter. It's rather expensive, overkill for what I need, and simultaneously doesn't actually address my very limited use case (modifying single lines at once) because it applies at the smallest level to paragraphs, not lines).

David Popham
Participating Frequently
February 7, 2020

You also may want to check out a plug-in called Typefitter that can help with those types of issues.