Skip to content

Fix weird character rendering on Windows with Japanese locale#20318

Draft
RobinMalfait wants to merge 4 commits into
mainfrom
fix/issue-19768
Draft

Fix weird character rendering on Windows with Japanese locale#20318
RobinMalfait wants to merge 4 commits into
mainfrom
fix/issue-19768

Conversation

@RobinMalfait

Copy link
Copy Markdown
Member

This PR fixes an issue where some characters are incorrectly rendered on Windows with the Japanese locale.

This is arguably a bug in the font that's loaded by Windows when it encounters system-ui. But waiting for fixes there might ... take a while.

Another option is to not change the defaults in Tailwind CSS and instead let the users that support different locales implement a fallback by overriding the --font-sans variable.

The biggest reason for me to not change it in Tailwind CSS is that it requires us to know what the (proper) fallback fonts need to be on a per OS basis.

But the main reason why I did want to make the change is that MDN says this about the system-ui font:

Glyphs are taken from the default user interface font on a given platform. Because typographic traditions vary widely across the world, this generic is provided for typefaces that don't map cleanly into the other generics.

Note: As the name implies, system-ui is intended to make UI elements look like native apps, and not for typesetting large paragraphs of text. It may cause the displayed typeface to be undesirable for some users—for example, the default Windows CJK font may render Latin scripts poorly, and the lang attribute may not affect the displayed font. Some operating systems do not allow customizing system-ui, while browsers generally allow customizing the sans-serif font family. For large paragraphs, use sans-serif or some other non-UI font family instead.

https://developer.mozilla.org/en-US/docs/Web/CSS/Reference/Properties/font-family#system-ui

There are PRs in other big projects that made this kind of change as well. E.g.:

Fixes: #19767
Fixes: #19768

Test plan

  1. system-ui is not used anymore, so the bug doesn't happen
  2. Everything still looks the same for the places I checked, but it's hard to know if this created other issues on other OS + Locale combinations...

Replace `ui-sans-serif` and `system-ui` with the following set of fonts:
- `-apple-system`
- `BlinkMacSystemFont`
- 'Segoe UI'
- Roboto
- 'Helvetica Neue'
- 'Noto Sans'
- Arial

For most peole this will look exactly the same, but it's for places like
Windows where a different font is used for `system-ui` in case your
machine is using a Japanese locale for example. Then the font used is
'Yu Gothic UI' which is the font that has bugs.

You could argue that it's a bug in that font and even an OS bug for not
providing a proper font for `system-ui`.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant