-
Notifications
You must be signed in to change notification settings - Fork 87
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
fix: put all kinds of system monospace fonts before Courier New #114
Open
haoqunjiang
wants to merge
2
commits into
vuejs:main
Choose a base branch
from
haoqunjiang:fix-monospace-font
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
There are multiple issue about Courier New being awful-looking on Linux: - [Bootstrap](twbs/bootstrap#18609) - [Chromium](https://issues.chromium.org/issues/40260598) - [Vue.js Docs](vuejs/docs#3105) Courier New is only readable under Windows because [ClearType made a special case for it](https://learn.microsoft.com/en-us/archive/blogs/fontblog/why-is-courier-new-so-thin). Therefore, it should never be one's first choice for monospace font. It should be put at the end of the list. By the way, though Courier New is a proprietary font, it is available on Linux through [Microsoft's Core Fonts for the Web](https://en.wikipedia.org/wiki/Core_fonts_for_the_Web). That's why Linux users might see it. In this PR I propose we set the monospace font stack to: ```text ui-monospace, 'SF Mono', 'SFMono-Regular', Menlo, Monaco, 'Cascadia Mono', Consolas, 'Liberation Mono', 'Noto Sans Mono', 'DejaVu Sans Mono', 'Roboto Mono', 'Courier New', monospace; ``` This puts all kinds of system monospace fonts before Courier New, with some personal preference. - `ui-monospace` is part of the CSS Fonts Module Level 4, and [only available in Safari for now](https://caniuse.com/extended-system-fonts). The difference between it and `monospace` is that `ui-monospace` aims to match the user's system monospace font, while `monospace` is a generic monospace font that's defined by the browser. So it's better to put it first. It currently defaults to "SF Mono" on macOS. - "SF Mono" is for macOS users who don't use Safari. - "SFMono-Regular" is a hack before Apple made "SF Mono" available everywhere (It was only bundled with Xcode and Terminal on first launch). - Menlo was the macOS default monospace font during 2009-2015. - Monaco was the macOS default monospace font before Menlo. - Cascadia Mono is the default monospace font for Windows Terminal. It's widely regarded as a modern replacement for Consolas. Its variant, "Cascadia Code", features programming ligatures. Programming ligatures is a controversial topic, and isn't average-user-friendly in the documentation, so I choose Cascadia Mono here. - Consolas is the default monospace font in Visual Studio and VS Code. It has been the modern monospace font of choice in Windows since Windows Vista. - Liberation Mono is the default monospace font in Red Hat Enterprise Linux. It's a metric-compatible replacement for Courier New. - Noto Sans Mono is the default monospace font in ChromeOS and Fedora 36+. - DejaVu Sans Mono is a popular choice among Linux distributions. It was the default monospace font in Fedora before v36 and ChromeOS Secure Shell before v73. It's also an inspiration for Menlo. - Roboto Mono is the default monospace font for Android. - Source Code Pro is the default monospace font in GNOME. - Courier New is the web-safe fallback. I intentionally left out a few system monospace fonts: - Ubuntu Mono. According to [the user feedback in the StackOverflow design refresh announcement](https://meta.stackexchange.com/questions/364048/we-are-switching-to-system-fonts-on-may-10-2021), Even Ubuntu users don't like it. It's smaller than its sans-serif counterpart, too, which is a notable issue. - Source Code Pro. It's the default monospace font in GNOME. It's a good UI font, but I doubt it's a good choice for code. It's too wide. --- As a reference: GitHub's default: ```text ui-monospace, SFMono-Regular, SF Mono, Menlo, Consolas, Liberation Mono, monospace ``` Tailwind 3.4.13: ```text ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace; ``` StackExchange's design refresh in 2021: <https://meta.stackexchange.com/questions/364048/we-are-switching-to-system-fonts-on-may-10-2021>
It looks really promising and good. And thanks for all the information. I just wonder whether it's a good idea to add the information into the code comments somehow. WDYT? |
Done! Added a link to my newly deployed blog |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There are multiple issues about Courier New being awful-looking on Linux:
Courier New is only readable under Windows because ClearType made a special case for it.
Therefore, it should never be one's first choice for monospace font. It should be put at the end of the list.
By the way, though Courier New is a proprietary font, it is available on Linux through Microsoft's Core Fonts for the Web. That's why Linux users might see it.
In this PR I propose we set the monospace font stack to:
This puts all kinds of system monospace fonts before Courier New, with some personal preference.
ui-monospace
is part of the CSS Fonts Module Level 4, and only available in Safari for now. The difference between it andmonospace
is thatui-monospace
aims to match the user's system monospace font, whilemonospace
is a generic monospace font that's defined by the browser. So it's better to put it first. It currently defaults to "SF Mono" on macOS.SFMono-Regular
is a hack before Apple made "SF Mono" available everywhere (It was only bundled with Xcode and Terminal on first launch).I intentionally left out a few system monospace fonts:
As a reference:
GitHub's default:
Tailwind 3.4.13:
StackExchange's design refresh in 2021:
https://meta.stackexchange.com/questions/364048/we-are-switching-to-system-fonts-on-may-10-2021