Skip to content

Compiler not rendering Chinese/CJK fonts #6054

Closed

Description

@DeepSpaceTravel

Description

I have CJK fonts installed at /usr/share/fonts/google-noto-sans-cjk-vf-fonts/NotoSansCJK-VF.ttc
However, it's not rendering

Image
(Rendered with Okular)

Code:

#align(center)[
    #block(
        text(weight: 700, size: 2em, font: "Noto Sans CJK TC")[
            名字
        ]
    )
]

Reproduction URL

No response

Operating system

Linux

Typst version

  • I am using the latest version of Typst

Activity

  1. added
    bug
    on Mar 13, 2025
  2. DeepSpaceTravel commented on Mar 13, 2025

    @DeepSpaceTravel
    Author

    Fonts correctly picked up by the OS
    Image

  3. MDLC01 commented on Mar 13, 2025

    @MDLC01
    Collaborator

    Is the font detected by Typst? You can check that with typst fonts.

  4. added
    text
    cjk
    on Mar 13, 2025
  5. DeepSpaceTravel commented on Mar 13, 2025

    @DeepSpaceTravel
    Author

    It does pick up the font

    Image

    Also, I didn't know the command exist. Ty

  6. liuguangxi commented on Mar 13, 2025

    @liuguangxi

    Maybe Variable Font couldn't be well processed by Typst.

  7. LaurenzV commented on Mar 13, 2025

    @LaurenzV
    Collaborator

    Could you send the resulting PDF? I suspect that it's a CFF2 font, which is currently not supported by Typst.

  8. DeepSpaceTravel commented on Mar 13, 2025

    @DeepSpaceTravel
    Author

    Here's a stripped down version of the original pdf

    sample.pdf

    Edit: Re-Upload the file with specified font

  9. LaurenzV commented on Mar 13, 2025

    @LaurenzV
    Collaborator

    Well that is interesting... It is embedded as a Type3 font, which should only happen with color fonts, but it confirms my suspicion that it's a CFF2 font because if the font doesn't have a glyf or CFF table we automatically consider it as a color font:

    pub fn should_outline(font: &Font, glyph: &Glyph) -> bool {
    let ttf = font.ttf();
    let glyph_id = GlyphId(glyph.id);
    (ttf.tables().glyf.is_some() || ttf.tables().cff.is_some())
    && !ttf
    .glyph_raster_image(glyph_id, u16::MAX)
    .is_some_and(|img| img.format == ttf_parser::RasterImageFormat::PNG)
    && !ttf.is_color_glyph(glyph_id)
    && ttf.glyph_svg_image(glyph_id).is_none()
    }

    The glyph in the PDF stream is literally drawn as a tofus:

    9 0 obj
    <<
      /Length 91
    >>
    stream
    1000 0 d0
    1 0 0 -1 0 1000 cm
    /d65gray CS
    0 SCN
    50 w
    0 J
    0 j
    [] 0 d
    4 M
    150 300 700 700 re
    S
    endstream
    endobj
    

    which makes me wonder why that happens, because ttf-parser does support CFF2 fonts. @laurmaedje Any ideas?

  10. DeepSpaceTravel commented on Mar 16, 2025

    @DeepSpaceTravel
    Author

    Update: With same font and typst file.
    This behavior is NOT observed on Windows platform.
    (i.e. The syntax works as expected on Windows.)

    Edit: The font is called :Noto Sans TC on Windows,
    However, Linux reads it as Noto Sans CJK TC
    But it should be the same font

  11. tani commented on May 23, 2025

    @tani

    I've also encountered this problem. Indeed, the Noto Sans font isn't working; however, the IPA font (an older, well-established TTF font for Japanese) does render.

  12. conao3 commented on May 23, 2025

    @conao3

    Variable fonts problem? #185

  13. lumingzh commented on Jun 11, 2025

    @lumingzh

    Should be variable fonts problem, you can try install non-vf fonts like Source Han Sans/Serif SC otf fonts and use them instead.

  14. YDX-2147483647 commented on Jun 5, 2026

    @YDX-2147483647
    Contributor

    #8425 has just been merged. This issue can be closed if there's no further problem. See also #8434.

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