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

[Feature request] Add support for other fonts #421

Open
simurai opened this issue Sep 13, 2023 · 0 comments
Open

[Feature request] Add support for other fonts #421

simurai opened this issue Sep 13, 2023 · 0 comments

Comments

@simurai
Copy link
Contributor

simurai commented Sep 13, 2023

This came up in https://github.com/github/primer/issues/2545.

Problem

Currently we use Mona Sans as the sans-serif font. This works great for latin based languages. But for other languages (e.g. Japanese), the browser falls back to a "system" font. Hiragino Sans seems to be the default font on macOS for Japanese.

Screenshot 2023-09-12 at 10 55 57

As a fallback that's fine too, but we got feedback that switching to another font would be preferred (Noto Sans JP in Japanese's case).

Possible solution

Maybe similar to the ThemeProvider, there could be a <FontProvider>:

<FontProvider lang="ja">
    Japanese goes here
</FontProvider>

It would load Noto Sans JP from Google Fonts:

<link rel="preconnect" href="https://fonts.googleapis.com">
<link href="https://fonts.googleapis.com/css2?family=Noto+Sans+JP:wght@400;500;700&display=swap" rel="stylesheet">

and add a data-font="ja" attribute:

<div data-font="ja">
    Japanese goes here
</div>

Which we then can use as a hook to change the --brand-fontStack-sansSerif variable:

[data-font="ja"] {
  --brand-fontStack-sansSerif: 'Noto Sans JP', sans-serif;
}
Using Noto Sans JP font Screenshot 2023-09-12 at 11 43 01

Also saw that https://docs.github.com/ja offers a language switcher as part of the nav. Which could also be used to swap the font for certain languages, but it's a bit bigger in scope.

Screenshot 2023-09-12 at 16 25 16

Urgency

As mentioned in https://github.com/github/primer/issues/2545#issuecomment-1714921015, it should be possible to override the font directly in a project. So it might not be that urgent to support in Primer Brand. But once GitHub starts to add more multi language support, then it might be nice to have.

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

1 participant