#Japanese Kanji displayed as squares but font is installed

24 messages · Page 1 of 1 (latest)

tidal ginkgo
#

When running typst fonts | grep "Noto Sans CJK JP" I get a match, so typst should be able to find the Japanese font.

But with this code

#set page(width: auto, height: auto)
#set text(font: "Noto Sans CJK JP")
こんにちは、世界。

I get squares instead of kanji when exporting to PDF and PNG. And I get the correct font when I export to SVG.

Any clues about what went wrong?

native trail
#

first step is to check what typst fonts | grep CJK gives you. If it's there, Typst should be able to use it. Maybe you need to restart your editor if it can be found in general, but not from where you're compiling?

If not, you should check how the font was installed; not sure what could have gone wrong though.

That it works in SVG may be because SVG can use the font during rendering, instead of during compilation, perhaps.

tidal ginkgo
#

typst fonts | grep CJK returns

Noto Sans CJK HK
Noto Sans CJK JP
Noto Sans CJK KR
Noto Sans CJK SC
Noto Sans CJK TC
Noto Sans Mono CJK HK
Noto Sans Mono CJK JP
Noto Sans Mono CJK KR
Noto Sans Mono CJK SC
Noto Sans Mono CJK TC
Noto Serif CJK HK
Noto Serif CJK JP
Noto Serif CJK KR
Noto Serif CJK SC
Noto Serif CJK TC
#

fc-list | grep CJK also returns many results (160 matches)

#

I've tried restarting my computer, but it had no effect

#

Restarted neovim won't change anything as I compiled in the terminal and viewed the pdf in zathura (and the png with imv (imv showed the kanji when I viewed the svg))

#

I'm on NixOS and I've installed the fonts with

{
  # ...
  fonts.packages = with pkgs; [
    noto-fonts
    noto-fonts-cjk-sans
    noto-fonts-cjk-serif
    noto-fonts-emoji
  ];
  # ...
}
#

(that has worked because the fonts are seen with the svg)

tidal ginkgo
#

Btw, their is no mention of the font I use in the svg output file (that correctly displays the kanji) :
cat test.svg | grep CJK return nothing

#

so it seems that the font is found and used at compile time for the svg

#

I'm so confused 😭

tidal ginkgo
#

I'll try this

#

@limber breach I just tried passing the font with --font-path, it worked

#

I'll try in .local now

limber breach
#

my setups always use "--ignore-system-fonts --font-path /path/to/workspace/fonts" options

tidal ginkgo
limber breach
#

it might be some work but you can automate this away with either makeor just

tidal ginkgo
tidal ginkgo
limber breach
tidal ginkgo
#

Maybe I can also install the fonts in .local with home manager