-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Description
Is your feature request related to a problem? Please describe.
It took me 3 days to figure out how to use a no-latin font. (Japanese)
I know this is not a valid feature request, but for those who struggled too, I would like to share how I managed to make it work.
Describe the solution you'd like
Maybe a README listing all tested working fonts for every kinds of languages.
Describe alternatives you've considered
This is what I did:
tldr:
To render japanese, use Nasu or 源真ゴシック
// Font.register({
// family: "Nasu",
// src: `${FONT_PATH}/Nasu-Regular.ttf`,
// });
Font.register({
family: "源真ゴシック",
fonts: [
{ src: `${FONT_PATH}/genshingothic/GenShinGothic-P-ExtraLight.ttf`, fontWeight: 200 },
{ src: `${FONT_PATH}/genshingothic/GenShinGothic-P-Light.ttf`, fontWeight: 300 },
{ src: `${FONT_PATH}/genshingothic/GenShinGothic-P-Regular.ttf`, fontWeight: 400 },
{ src: `${FONT_PATH}/genshingothic/GenShinGothic-P-Medium.ttf`, fontWeight: 500 },
{ src: `${FONT_PATH}/genshingothic/GenShinGothic-P-Bold.ttf`, fontWeight: 700 },
{ src: `${FONT_PATH}/genshingothic/GenShinGothic-P-Heavy.ttf`, fontWeight: 900 },
],
});
more details:
- I would like to have a monospaced latin font and a somewhat nice-looked japanese font.
Of course the defaultRobotodid not work. Japanese characters are all garbled. - I searched for issues of this repository, tried all solutions other people mentioned, and none worked for me.
- I searched for japanese monospace font, and found this post: https://qiita.com/wheatandcat/items/73b1452bd92f831334e7
And I tried theNasuhe used in his code, and it worked! - But the numbers were not look like what I wanted, so the searching continued.
- After trying
Noto Sans, which mentioned in other issues, I also triedNoto Sans CJK JP,Source Han Sans, downloading the default.otf, searching for and downloading.ttf, but none of those worked. - And the search kept going. Then I found
源真ゴシックmentioned above. Did not expect it to work, but it worked like a charm.
By the way, when using Font.register to register custom fonts, you can not have both PDFViewer and BlobProvider in same page.(at least in my environment)
That's all. If you guys know any other working fonts for any other languages, please share it here (or somewhere else that's ok for this kind of content).