arakiken / mlterm

Other
156 stars 13 forks source link

Proportional font width is set to widest character, not median width #41

Open derde opened 2 years ago

derde commented 2 years ago

When using a proportional font, like Times New Roman, the character cell size is set to the maximum width for that font - generally the letter "W". It would be more useful to use the median width for some representative text, or alternatively (or addionally) to allow a percentage of the maximum width to be specified. As it is, unless you are going to use a screen full of the letter "W", there is a lot of unused real-estate on the right hand side when using proportional fonts.
The screenshot shows 80 of the same character: image xterm suffers from the same problem.

arakiken commented 2 years ago

Please try to configure ~/.mlterm/aafont as follows. DEFAULT=[FONT NAME]:100

derde commented 2 years ago

The problem is not the character cell size, but the window size, which is around 50% larger than it needs to be for the kind of text I have on the terminal. Squashing up the individual character cell just makes things look ugly. image

arakiken commented 2 years ago

Sorry for late reply. Does screen_width_ratio option help you?

clort81 commented 1 year ago

I think the problem here is a derde selecting a proportional font in a terminal.

derde commented 1 year ago

The only reason I consider using mlterm is that it makes something of an honest attempt to use proportional fonts.

guillaume-d commented 1 year ago

The problem is not the character cell size, but the window size, which is around 50% larger than it needs to be for the kind of text I have on the terminal. Squashing up the individual character cell just makes things look ugly. image

As @arakiken said, a screen_width_ratio < 100 should mimimize the issue.

There is no perfect solution here:

You will have to find out the best compromise for your particular font I guess. Using the configuration GUI makes that easy: go to the Font tab, change the value at Screen size ratio against font size:, press the Apply button to try it out, and repeat until satisfied.

What maybe would be helpful is a way to increase and decrease the ratio quickly using the keyboard, a la https://github.com/arakiken/mlterm/issues/38#issuecomment-1030631600.

Note that somehow with 100 the font width is not set to the width of the widest character: with the Input font (which I wholeheartedly recommend for programming), a full line of m characters is already too wide, which is quite fine anyway, as it will rarely if ever happen in a programming context. I hope mlterm does not assume that W is always the widest character, so maybe some proportional fonts "lie" about which one is? Or is there indeed some median width value that some fonts do not set properly? I doubt a "representative text" can be found as initially suggested which would fit prose, programming in different languages, and the many other uses I cannot think of.

guillaume-d commented 1 year ago

When using a proportional font, like Times New Roman, the character cell size is set to the maximum width for that font - generally the letter "W". [...] xterm suffers from the same problem.

To my knowledge xterm is much worse and use the same character cell width for all characters even for a proportional font. xterm's forcePackedFont seems to allow choosing between the minimum and maximum width, but that width still does not vary between narrow and wide characters. At least I could not get xterm to display anything not ugly with proportional fonts, just like many other terminal emulators that only forgot to forbid them. I would be very glad to be proven wrong, as far as I know mlterm is the only general-purpose terminal emulator which displays proportional fonts correctly (GNU Emacs's internal one supposedly works fine too).