Skip to content

fix: update font-family settings for improved language support - #5438

Open
tats-u wants to merge 6 commits into
vuejs:mainfrom
tats-u:fix-fonts
Open

tats-u wants to merge 6 commits into
vuejs:mainfrom
tats-u:fix-fonts

Conversation

@tats-u

@tats-u tats-u commented Sep 13, 2026 •

Copy link
Copy Markdown
Contributor

Description

Prefers Noto Sans CJK to good old Microsoft fonts

Good old Windows standard fonts from before 2010, such as Microsoft YaHei and Meiryo, are overly optimized for 96 dpi displays. The Noto Sans CJK fonts included with recent versions of Windows (e.g., Noto Sans SC and Noto Sans JP; note that only the subset for the CJK language in use is installed by default) feature character shapes with fewer quirks and provide a consistent look with Linux-based operating systems and other CJK languages.

Furthermore, Noto Sans CJK offers a wide range of weights from extremely thin to extremely bold, and its aesthetic is similar to Hiragino Sans, making it possible to match the appearance on Apple devices.

Even on a 96 dpi display, as long as the text is not rendered extremely small, I think Noto's readability is not much inferior to the older Windows standard fonts. Rather, it has an appropriate stroke weight and renders smoothly. Also, unlike older Windows standard fonts other than Yu Gothic, Noto supports text-spacing-trim, which removes the excess whitespace that occurs with certain combinations of consecutive punctuation marks (as defined by the typesetting rules of each language).

Meiryo and YaHei cannot remove the extra spacing that occurs between parentheses, brackets, or quotation marks and adjacent punctuation:

image
Respects Traditional Chinese locales

In current VitePress, Simplified Chinese fonts are assigned to Traditional Chinese pages. When it is clear that a page is for Taiwan, Hong Kong, or Macao, fonts optimized for those regions should be prioritized. When it is unclear which of those three regions the page is for, the user's preference should be respected. Microsoft JhengHei is optimized for Taiwan, so it should not be prioritized for pages intended for Hong Kong or Macao.

Reflects internal lang change

In the language selector, "日本語" on the Simplified Chinese page and "简体中文" on the Japanese page are not rendered in the font of their respective languages:

image

"简体中文" is rendered by Meiryo but it should not be.

image

"日本語" is rendered by YaHei but it should not be.

Adjusts Yu Gothic weights for non-Japanese Windows

Yu Gothic, which is used when displaying Japanese pages on non-Japanese versions of Windows, has a Regular weight that is only about as thick as the Light weight of other fonts. It is simply much too thin. Therefore, I made it use Medium by default, and Bold (though it is still only about as thick as the SemiBold of a typical font) for bold text. See https://github.com/tats-u/yu-gothic-css/ for details.

Linked Issues

Additional Context


Tip

The author can publish a preview release by commenting /publish after creating the PR.

@tats-u
tats-u marked this pull request as draft September 13, 2026 15:09
@tats-u

tats-u commented Sep 13, 2026

Copy link
Copy Markdown
Contributor Author

Needs to adjust subsetFonts.py.

- Prefers Noto Sans CJK to good old Microsoft fonts
- Respects Traditional Chinese locales
- Reflects internal lang change
- Adjusts Yu Gothic weights for non-Japanese Windows
@tats-u
tats-u marked this pull request as ready for review September 19, 2026 15:40
@tats-u

tats-u commented Sep 20, 2026

Copy link
Copy Markdown
Contributor Author

Before

image

YaHei looks a little too pixelated compared to Inter. The Chinese ellipsis is positioned at the bottom rather than in the center. Given our commitment to fine-tuning the Latin font, this flaw cannot be overlooked.

image

Meiryo looks too thin and pixelated compared to Inter.

After

image image

Noto Sans CJK (Noto Sans SC/JP) harmonizes with the look of Inter better than the "good" old built-in Windows CJ(K) fonts.

@tats-u
tats-u requested a review from brc-dd November 9, 2026 14:51
@tats-u

tats-u commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor Author

With the current design, it's pretty troublesome to customize fonts for a specific CJK language.

We will probably need to add a lot of CSS variables like --vp-font-family-zh-cn.

  • --vp-font-family-{ja,ko,zh-{cn,tw,hk,mo}}
  • --vp-font-family-cjk

User:

:root {
  --vp-font-family-ja: Hiragino Sans, Meiryo, Yu Gothic Weight Fixed, Noto Sans CJK JP, Noto Sans JP;
}

Our side:

:root {
  --vp-font-family-ja: 'Hiragino Sans', 'Noto Sans CJK JP', 'Noto Sans JP', 'Yu Gothic Weight Fixed', 'Meiryo';
  --vp-font-family-zh-cn: 'PingFang SC', 'Noto Sans CJK SC', 'Noto Sans SC', 'Microsoft YaHei',;
  /* ... */
}

[lang]:where(:lang(zh, ja, ko)) {
  --vp-font-family-base: 'Inter Core', var(--vp-font-family-cjk),
    BlinkMacSystemFont, sans-serif, 'Apple Color Emoji',
    'Segoe UI Emoji', 'Segoe UI Symbol', 'Noto Color Emoji';
}

[lang]:where(:lang(ja)) {
  --vp-font-family-cjk: var(--vp-font-family-ja);
}

[lang]:where(:lang(zh)){
  --vp-font-family-cjk: var(--vp-font-family-zh-cn);
}

/* ... */

@netlify

netlify Bot commented Nov 28, 2026

Copy link
Copy Markdown

👷 Deploy request for vitepress-docs pending review.

Visit the deploys page to approve it

Name Link
🔨 Latest commit 5123053

@tats-u
tats-u requested a review from brc-dd November 28, 2026 15:05
@tats-u

tats-u commented Nov 28, 2026 •

Copy link
Copy Markdown
Contributor Author

To prefer Windows built-in fonts like before, you now simply need to insert the following:

:root {
  --vp-font-family-zh-cn: 'PingFang SC', 'Microsoft YaHei', 'Noto Sans CJK SC';
  --vp-font-family-zh-tw: 'PingFang TC', 'Microsoft JhengHei', 'Noto Sans CJK TC', 'Noto Sans TC';
  --vp-font-family-ja: 'Hiragino Sans', 'Meiryo', 'Yu Gothic Weight Fixed', 'Noto Sans CJK JP';
  --vp-font-family-ko: 'Apple SD Gothic Neo', 'Malgun Gothic', 'Noto Sans CJK KR';
}

This branch has not been deployed

No deployments
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

Successfully merging this pull request may close these issues.

2 participants