Skip to content

Letters are not correctly aligned in a grid or table when using some Chinese fonts #1610

Open

Description

@wildabc

Description

When different fonts are used, they may be not correctly aligned. The font used in the example is Fangzheng Hei GBK (FZHTK.TTF which can be downloaded from https://github.com/Universebenzene/wps-office-fonts/). And this can also cause problems in list or enum

#grid(columns: (2em, 2em), text(font:"Arial")[123], text(font:"FZHei-B01")[123])

#text(font:("Arial","FZHei-B01"))[+ 壹]

图片

Reproduction URL

No response

Operating system

Windows

Typst version

  • I am using the latest version of Typst

Activity

  1. added
    bug
    on Jun 29, 2023
  2. added
    text
    on Jul 3, 2023
  3. added
    needs-investigation
    on Nov 14, 2023
  4. YDX-2147483647 commented on Jul 4, 2025

    @YDX-2147483647
    Contributor

    Relevant: #1204

    In the following image, the aqua boxes are from baseline to cap-height.

    Image

    Full code
    #set text(fallback: false)
    
    #table(
      columns: 2,
      stroke: (x, y) => (
        if y > 0 { (x: none, y: 0.5pt + green.lighten(50%)) }
          + if x == 1 { (left: green.lighten(50%)) }
      ),
      inset: (top: 0pt),
      table.header(
        [*TeX Gyre Heros* \ (≈ Helvetica ≈ Arial)], [*FZHei-B01* \ (`FZHTK.TTF`)]
      ),
      ..([123], [ABC], [壹])
        .map(x => (x, box(fill: aqua, x)))
        .flatten()
        .map(x => (text(font: "TeX Gyre Heros", x), text(font: "FZHei-B01", x)))
        .flatten(),
    )
    
    
    #text(font: ("Liberation Serif", "FZHei-B01"))[+ 壹]

    Image

    Code

    debug-font is the function in https://forum.typst.app/t/a-snippet-to-debug-font-by-visualize-baseline-cap-height-etc/4597.

    #import "debug-font.typ": debug-font
    
    #set page(height: auto, width: auto, margin: (left: 1em, right: 3.5em, y: 0.5em))
    
    #show heading: set text(1em / 3, weight: "regular")
    #show heading: pad.with(bottom: 0.4em, top: 0.5em)
    
    = *TeX Gyre Heros* (≈ Helvetica ≈ Arial)
    
    #debug-font({
      set text(font: "TeX Gyre Heros")
      [Typ 123]
    })
    
    = *FZHei-B01* (`FZHTK.TTF`)
    
    #debug-font({
      set text(font: "FZHei-B01")
      [Typ 123 壹]
    })

    Workarounds can be found in 列表符号/编号和内容错位怎么办? | Typst 中文社区导航 (in Chinese), basically set grid(align: bottom) and/or set text(top-edge: "ascender").

  5. YDX-2147483647 commented on May 28, 2026

    @YDX-2147483647
    Contributor

    I confirm that the second line is fixed (probably by #7895), but the first line needs additional work.

    Image
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

    bugneeds-investigationtext

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions