Skip to content

CJK .otf.ttc fonts get fully embedded, but PDF viewer only shows tofu #5954

Closed as duplicate

Description

@Andrew15-5

Description

I've just tried compiling a document on NixOS, but found tofu, which is weird. Apparently 〜 is rendered like that, which means it doesn't see CJK fonts, but the font is fully embedded, so it must render.
But Okular and MuPDF show tofu.

I thought that using "Thin" variant instead of "Regular" by default is weird, but soon I discovered that all CJK font packages from nixpkgs only have .otf.ttc files, which is different from .otf files I used before (while all other fonts have .ttf, which is why all of them work with Typst as usual).

And indeed, as soon as I downloaded the official OTF files and compiled the document again, I was greeted with actual glyphs. So, I've never seen such files before and since all programs do render CJK glyphs, then it must be Typst that can't properly work with such format. It has nothing to do with NixOS in particular.

#set document(date: none)
#set text(font: "Noto Sans CJK JP")
テキスト

a.pdf

System fonts
NotoSansCJK-VF.otf.ttc: Noto Sans CJK JP:style=Bold
NotoSansCJK-VF.otf.ttc: Noto Sans CJK JP:style=DemiLight
NotoSansCJK-VF.otf.ttc: Noto Sans CJK JP:style=Medium
NotoSansCJK-VF.otf.ttc: Noto Sans CJK JP:style=DemiLight
NotoSansCJK-VF.otf.ttc: Noto Sans CJK JP:style=Light
NotoSansCJK-VF.otf.ttc: Noto Sans CJK JP:style=Light
NotoSansCJK-VF.otf.ttc: Noto Sans CJK JP:style=Regular
NotoSansCJK-VF.otf.ttc: Noto Sans CJK JP:style=Thin,Regular
NotoSansCJK-VF.otf.ttc: Noto Sans CJK JP:style=Black
NotoSansCJK-VF.otf.ttc: Noto Sans CJK JP
NotoSansCJK-VF.otf.ttc: Noto Sans CJK JP
NotoSansCJK-VF.otf.ttc: Noto Sans CJK JP:style=Black
NotoSansCJK-VF.otf.ttc: Noto Sans CJK JP:style=Regular
NotoSansCJK-VF.otf.ttc: Noto Sans CJK JP:style=Thin,Regular
NotoSansCJK-VF.otf.ttc: Noto Sans CJK JP:style=Bold
NotoSansCJK-VF.otf.ttc: Noto Sans CJK JP:style=Medium

With paths:

/nix/store/0wya6d4cn2yp1yfa4afq198cdh9bfpxf-noto-fonts-cjk-sans-2.004/share/fonts/opentype/noto-cjk/NotoSansCJK-VF.otf.ttc: Noto Sans CJK JP:style=Bold
/nix/store/ffnicq45xczjbpxhqs1prdld9l72wj2c-home-manager-path/share/fonts/opentype/noto-cjk/NotoSansCJK-VF.otf.ttc: Noto Sans CJK JP:style=DemiLight
/nix/store/ffnicq45xczjbpxhqs1prdld9l72wj2c-home-manager-path/share/fonts/opentype/noto-cjk/NotoSansCJK-VF.otf.ttc: Noto Sans CJK JP:style=Medium
/nix/store/0wya6d4cn2yp1yfa4afq198cdh9bfpxf-noto-fonts-cjk-sans-2.004/share/fonts/opentype/noto-cjk/NotoSansCJK-VF.otf.ttc: Noto Sans CJK JP:style=DemiLight
/nix/store/ffnicq45xczjbpxhqs1prdld9l72wj2c-home-manager-path/share/fonts/opentype/noto-cjk/NotoSansCJK-VF.otf.ttc: Noto Sans CJK JP:style=Light
/nix/store/0wya6d4cn2yp1yfa4afq198cdh9bfpxf-noto-fonts-cjk-sans-2.004/share/fonts/opentype/noto-cjk/NotoSansCJK-VF.otf.ttc: Noto Sans CJK JP:style=Light
/nix/store/0wya6d4cn2yp1yfa4afq198cdh9bfpxf-noto-fonts-cjk-sans-2.004/share/fonts/opentype/noto-cjk/NotoSansCJK-VF.otf.ttc: Noto Sans CJK JP:style=Regular
/nix/store/0wya6d4cn2yp1yfa4afq198cdh9bfpxf-noto-fonts-cjk-sans-2.004/share/fonts/opentype/noto-cjk/NotoSansCJK-VF.otf.ttc: Noto Sans CJK JP:style=Thin,Regular
/nix/store/ffnicq45xczjbpxhqs1prdld9l72wj2c-home-manager-path/share/fonts/opentype/noto-cjk/NotoSansCJK-VF.otf.ttc: Noto Sans CJK JP:style=Black
/nix/store/ffnicq45xczjbpxhqs1prdld9l72wj2c-home-manager-path/share/fonts/opentype/noto-cjk/NotoSansCJK-VF.otf.ttc: Noto Sans CJK JP
/nix/store/0wya6d4cn2yp1yfa4afq198cdh9bfpxf-noto-fonts-cjk-sans-2.004/share/fonts/opentype/noto-cjk/NotoSansCJK-VF.otf.ttc: Noto Sans CJK JP
/nix/store/0wya6d4cn2yp1yfa4afq198cdh9bfpxf-noto-fonts-cjk-sans-2.004/share/fonts/opentype/noto-cjk/NotoSansCJK-VF.otf.ttc: Noto Sans CJK JP:style=Black
/nix/store/ffnicq45xczjbpxhqs1prdld9l72wj2c-home-manager-path/share/fonts/opentype/noto-cjk/NotoSansCJK-VF.otf.ttc: Noto Sans CJK JP:style=Regular
/nix/store/ffnicq45xczjbpxhqs1prdld9l72wj2c-home-manager-path/share/fonts/opentype/noto-cjk/NotoSansCJK-VF.otf.ttc: Noto Sans CJK JP:style=Thin,Regular
/nix/store/ffnicq45xczjbpxhqs1prdld9l72wj2c-home-manager-path/share/fonts/opentype/noto-cjk/NotoSansCJK-VF.otf.ttc: Noto Sans CJK JP:style=Bold
/nix/store/0wya6d4cn2yp1yfa4afq198cdh9bfpxf-noto-fonts-cjk-sans-2.004/share/fonts/opentype/noto-cjk/NotoSansCJK-VF.otf.ttc: Noto Sans CJK JP:style=Medium

Trying to set default fonts and adding some extra didn't help:

  fonts.packages = with pkgs; [
    nerd-fonts.fira-code
    fira
    fira-code
    liberation_ttf
    libertinus
    noto-fonts
    noto-fonts-extra
    noto-fonts-cjk-sans
    noto-fonts-cjk-serif
    noto-fonts-color-emoji
  ];

  fonts.fontconfig = {
    enable = true;
    defaultFonts.emoji = ["Noto Color Emoji"];
    defaultFonts.monospace = ["FiraCode Nerd Font" "Noto Mono CJK JP"];
    defaultFonts.sansSerif = ["Liberation Sans" "Noto Sans CJK JP"];
    defaultFonts.serif = ["Libertinus Serif" "Noto Serif CJK JP"];
  };

In the end, I still have to maintain a custom fonts directory just for Typst to be usable.

Reproduction URL

No response

Operating system

Linux

Typst version

  • I am using the latest version of Typst

Activity

  1. added
    bug
    on Feb 25, 2025
  2. added
    text
    cjk
    on Feb 25, 2025
  3. Andrew15-5 commented on Feb 25, 2025

    @Andrew15-5
    ContributorAuthor

    Actually, I think it's a duplicate of #185, since I've tried using VF files locally and it still produces tofus. When I used a much bigger per-variant OTF font files, then it embeds things just fine.

    #5304 would've made this obvious.

  4. Andrew15-5 commented on Feb 25, 2025

    @Andrew15-5
    ContributorAuthor

    I would've said that maybe the noto-fonts-cjk-sans package should have a .static option, but since VF is actually much smaller, it makes sense that they use what they use.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugcjktext

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions