Support japanese subset for next/font/google
#86336
setouchi-h
started this conversation in
Ideas
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Goals
subsets: ['japanese']withnext/font/google(e.g.Zen_Kaku_Gothic_New) without TypeScript errors.next/font/google.Non-Goals
No response
Background
When using
Zen_Kaku_Gothic_Newfromnext/font/google, thejapanesesubset is not included in the generated TypeScript definitions.In this repo,
scripts/update-google-fonts.jsbuildspackages/font/src/google/index.tsandfont-data.json. The script filters out several subsets via anignoredSubsetsarray, including'japanese','korean', and the Chinese subsets. As a result, the generated metadata for “Zen Kaku Gothic New” only includes['cyrillic', 'latin', 'latin-ext'], and thesubsetsoption in theZen_Kaku_Gothic_Newtype does not allow'japanese'.At runtime,
next/font/googlestill loads the font correctly from Google Fonts (the CSS response includes Japanese glyphs), so Japanese text renders fine. However, TypeScript reports an error, and if we try to usepreloadtogether with'japanese', the validation code treats it as an unknown subset.For Japanese users, this means we either have to suppress type errors (e.g. with
@ts-ignore) or avoid using the subset/preload options, even though the font actually works in practice.Proposal
I would like to understand the intended policy for CJK subsets in
next/font/google, and whether enablingjapanese(and potentially other CJK subsets) in the metadata is something that could be supported.My initial thought is:
'japanese'(and possibly other CJK subsets) from the generated metadata so thatsubsets: ['japanese']is allowed at the type level.preload: falseas the default for these CJK fonts, and document that preloading CJK subsets can significantly increase bundle size and initial load time.I’m happy to open a PR implementing whatever approach maintainers prefer (for example, enabling only
'japanese'first, or adding an explicit opt‑in for CJK subsets). I’d appreciate guidance on the direction you’d consider acceptable before starting implementation.Beta Was this translation helpful? Give feedback.
All reactions