JetBrains / JetBrainsMono

JetBrains Mono – the free and open-source typeface for developers
https://jetbrains.com/mono
SIL Open Font License 1.1
10.57k stars 298 forks source link

JetBrains Mono font is not monospace for bold style & if weight is not "regular" #675

Open digital-ember opened 2 months ago

digital-ember commented 2 months ago

I originally reported this in the unofficial MPS Slack: https://jetbrains-mps.slack.com/archives/C3YUV3YK0/p1713368543862319

When I use the font "JetBrains Mono" with a weight that is not "Regular", the font gets wider in case of using the style "bold" or "boldItalic".

I created a simple, self-contained example with MPS 2023.3 that I attached here called FontWeightIssue. In the sandbox model, there are two editor lines for the same "name" property. You can set the font for both at the top of the editor and the style for each line individually. It will also show you the measured width next to the name:

mps_fontWeightIssue

FontWeightIssue.zip

digital-ember commented 2 months ago

Another observation: the measured width for my non-bold test string aligns with the bold ones

I verified that by changing the measured width calculation to use the current (font size + 1).

Noticably, this is not true for space characters. Only visible characters' seem to have this effect, which means each space in the test string causes the measued widths to be one off by 1.

Note that the actual test string is still shown shorter cause it uses the same font size, only the calculation for the width uses a (font-size +1)

mps_fontWeightIssue2

Using (font-size+1) also to render the property in the plain style shows that it is actually the same width without whitespaces:

mps_fontWeightIssue3

In fact, using a font < 16.0 does not show the original issue I reported here at all!

alexeyten commented 2 months ago

My guess is that for non-Regular font MPS uses "fake bold", i.e. artificially stretch and bolden original font instead of using special Bold version.

Probably because it tries to find non-existent JenBrains Mono Medium Bold font.

digital-ember commented 2 months ago

Does this idea of "fake bold" make sense given my observations, i.e. that the effect differs with different font-sizes as shown above?

maros-sandor commented 1 month ago

Can you try the MPS 24.1 EAP? I downloaded your project and cannot reproduce the issue in the latest MPS.

digital-ember commented 1 month ago

I downloaded MPS 24.1 EAP (generic distribution) and put it on a clean Windows 11 sandbox. When I open my font weight issue, it is still reproducable.

fontWeight_issue Are you sure you tested under Windows and changed the font size to 16 or above in the settings?