Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
digital-ember opened this issue Apr 22, 2024 · 5 comments

Comments

@digital-ember
Copy link

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
Copy link
Author

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

  • if I measure the width using (font-size + 1)
  • if the Editor font is greater than 18pt

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
Copy link
Contributor

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
Copy link
Author

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
Copy link

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

@digital-ember
Copy link
Author

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants