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

Questioning if Nimbus Sans is really a good choice for a font stack #25

Open
SethFalco opened this issue May 31, 2024 · 1 comment
Open

Comments

@SethFalco
Copy link

SethFalco commented May 31, 2024

While working on svgo.dev, I'd found that Nimbus Sans renders inconsistently between browsers due to vertical metrics.

I've actually covered this in two Stack Overflow questions:

I'm not a typeface expert, but from what I can tell, it is related to the ascent metrics of the font, and how browsers behave according to it. I'm not sure if this is merely a difference in behavior, or a bug in one of the browsers. If you have a take on this, I'd appreciate your thoughts! ^-^'

Based on this, I'd actually shifted away from Nimbus Sans, and use Liberation Sans instead, which doesn't have the issue and still looks great.

I'm also wondering, (even better if other Linux users could confirm if they experience the same behavior), do you think it'd make sense to replace Nimbus Sans with Liberation Sans in the font stacks?

Bootstrap itself actually uses Liberation Sans too, so it doesn't seem like an unreasonable choice:

Here is the code to reproduce the example in the screenshots attached:

<div id="wrapper">
  <div><span>Text</span></div>
</div>
#wrapper {
  height: 128px;
  display: flex;
  margin: .5em;

  /* monospace generic font family so it's obvious if the main font isn't used */
  font-family: "Nimbus Sans", monospace;
}

div div {
  padding: .5em;
  display: flex;
  align-items: center;
  background-color: #f55;
}

span {
  font-size: 4rem;
  border: 1px solid;
}

Firefox

Observe that on Firefox, it's perfectly centered.

Chromium

Observe that on Chromium, the text takes up less space and each character is higher. It is no longer centered within the red background.

However, if I add the following CSS, it fixes the issue:

/* Fix inconsistent ascent across browsers. */
@font-face {
  font-family: "Nimbus Sans";
  src: local("Nimbus Sans");
  ascent-override: 100%;
}


PS: Just want to note that this is a pretty awesome resource, so thank you for making it. ❤️

I wrote an article about fonts a while back, and actually replaced the section where I propose font stacks with a link to your website instead.

@Abban
Copy link

Abban commented Nov 12, 2024

I'm seeing Nimbus Sans break UI font alignment in Ubuntu Firefox when using the Neo Grotesque font stack

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

2 participants