adobe-fonts / source-code-pro

Monospaced font family for user interface and coding environments
https://adobe-fonts.github.io/source-code-pro/
SIL Open Font License 1.1
19.74k stars 1.62k forks source link

Font Width #299

Closed manngo closed 1 year ago

manngo commented 1 year ago

I don’t know very much about font metrics, so this question may sound strange.

Given that this is a monospace font, what is the width of the box containing each character, relative to the font size.

For example, in a word processor, I want to set tab stops to the equivalent of 4 characters in, say, 10 or 12 point. My guess is that I have the answer, I could multiply it by 4 and work out the distances in inches or centimetres.

Does that make sense?

frankrolf commented 1 year ago

This does make sense! 😊 Source Code Pro has a glyph width of 600 units, which means setting the font at 1000 pt will make a glyph (including whitespace) 600 dtp points wide.

A dtp point is defined as 1/72 inch; consequently, in text set at 10 pt, a glyph will be 600 / 1000 * 10 = 6 dtp points wide. This means you’ll have 72 / 6 = 12 glyphs to the inch.

When setting text at 12 pt, a glyph will be 600 / 1000 * 12 = 7.2 dtp points wide, which means you’ll have 72 / 7.2 = 10 glyphs to the inch.

More information on “pitch” (which means assessing the set width of a monospaced font) can be found here: https://en.wikipedia.org/wiki/Pitch_(typewriter)

manngo commented 1 year ago

Thanks. That worked perfectly. I nearly got it by trial and error with 29pt for 4 characters (should be 28.8).

That means every tab stop for four characters should be:

In other words, 2.4 * the font size.

The hard part now is trying to get Libre Office styles set up.

Thanks