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

Is there any specific algorithm relationship between Letter spacing and font size in InDesign?

Explorer ,
Jun 13, 2023 Jun 13, 2023

68.png

ABCD Name

AD Name

ABD Name

 

I need to align the three above.

Some people may use grids, but that feature is difficult to use and I usually don't use it. It's better to use font spacing.

 

However, it is troublesome to adjust the font spacing. For example, when the font size becomes larger, I have to try every Letter spacing value.

Just want to ask: What is the relationship between font size and spacing, can we calculate it?

 

TOPICS
Bug , How to , Import and export , Scripting , Sync and storage
5.3K
Translate
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 4 Correct answers

Community Expert , Jun 14, 2023 Jun 14, 2023

Hi @dublove5CFE, the issue here is converting tracking units (which I assume you are using to space out the A in the second line) into ruler units. Tracking is measured in em units which relate to the font size. The conversion factor is, 1000 / font size. Some fonts have differing sized em squares but Indesign seems to calibrate them all to 1000 units in terms of the UI and scripting API. You can see how it works in this script, that attempts to solve your problem.

 

 

/**
 * Letterspace Chars T
...
Translate
Community Expert , Jun 15, 2023 Jun 15, 2023

Hi @dublove5CFE, I have written a modified version that also sets the tab stop so that the tab character width is 5mm (you can adjust this in the script). I've also put the letterspacing into a function so it can be used for other purposes.

demo2.gif

Try this version and see what you think.

- Mark

 

/**
 * Letterspace Chars Before Tab
 * Script expects to have a text selection that includes
 * paragraphs that share a tab stop, and will and will
 * adjust tracking of characters before the tab character
 *
...
Translate
Community Expert , Jun 15, 2023 Jun 15, 2023

Hi @dublove5CFE, it sounds like it might be better in your case just to replace the tab with another character of your choice. Here is a re-write of the script that replaces tab with em space u+2003. You could choose another unicode space character.

- Mark

demo3.gif

 

/**
 * Letterspace Chars Before Tab
 * Script expects to have a text selection that includes
 * paragraphs that share a tab stop, and will adjust
 * tracking of characters before the tab character
 * so that the last characters before each 
...
Translate
Community Expert , Jun 16, 2023 Jun 16, 2023

Thank you Robert.

Translate
Community Expert ,
Jun 15, 2024 Jun 15, 2024

No problem, I've added code that will ignore the colon (not space it out). - Mark

Translate
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
Guide ,
Jun 15, 2024 Jun 15, 2024

@m1b 

2024.6.15 version

about":"
It doesn't seem to change?

Did you miss something?

There is no tab behind ":".

":"  is a full -bodied character, occupying a word width

dublove_0-1718462776298.jpeg

 

 

Translate
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
LEGEND ,
Jun 15, 2024 Jun 15, 2024
quote

@m1b 

2024.6.15 version

about":"
It doesn't seem to change?

Did you miss something?

dublove_0-1718462776298.jpeg

 

By @dublove

 

From your screenshot - there are no TABs after ":"?

 

Translate
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
Guide ,
Jun 15, 2024 Jun 15, 2024

There is no tab behind ":"

Translate
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
LEGEND ,
Jun 15, 2024 Jun 15, 2024

@dublove wrote:

There is no tab behind ":"


 

So the code won't work:

 

for (var i = paras.length - 1; i >= 0; i--) {

        match = paras[i].contents.match(findFirstTab);

 

It expects TAB somewhere in EVERY paragraph. 

 

Translate
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
Guide ,
Jun 16, 2024 Jun 16, 2024

This is actually two situations:
Situation 1, aligned to the longest position ".:"
Situation 2, alignment to the longest position ".\t"

Translate
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
Guide ,
Jun 15, 2024 Jun 15, 2024

@m1b wrote:

No problem, I've added code that will ignore the colon (not space it out). - Mark


Hi @m1b 

2024.6.15 version

about":"
It doesn't seem to change?

Did you miss something?

There is no tab behind ":"

":"  is a full -bodied character, occupying a word width

true.jpg

Translate
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
Guide ,
Jun 19, 2024 Jun 19, 2024

I now use another method.

After all processing,use regular search (~ K) (\ t) (~ K) to replace it with: $ 1:$ 3

Translate
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