Skip to content

CJK punctuation at the start of paragraphs are not adjusted sometimes #2348

Open

Description

@balthild

Description

I'm not sure if this is a bug or a feature that haven't been implemented. In #954, I see that CJK right puncts appearing at line start are compressed:

image

However, I found that there're some cases these puncts are not compressed when they appear at paragraph start:

image

This causes the start of the paragraphs to look like misaligned.

Related: #276

Typst code:

#let ccwd = 12pt

// Set the text width to exact 32 Chinese characters.
#set page("iso-b5", margin: (x: 50% - ccwd * 16))

#set text(
  lang: "zh",
  font: ("Source Han Serif"),
  size: ccwd,
  overhang: false,
)

#set par(justify: true, first-line-indent: 2em)

// stripe background
#place(
  top + left,
  repeat(
    stack(
      dir: ltr,
      rect(width: ccwd, height: 24em, stroke: none, fill: rgb("#7092be70")),
      rect(width: ccwd, height: 24em, stroke: none)
    )
  )
)

first paragraph no indent

囗囗囗囗囗囗囗囗囗囗囗囗囗囗囗囗囗囗囗囗囗囗囗囗囗囗囗囗囗囗囗囗囗囗囗囗囗囗囗囗

(囗囗囗囗)囗囗囗囗囗囗囗囗囗囗囗囗囗囗囗囗囗囗囗囗囗囗囗囗囗囗囗囗囗囗囗囗

(囗囗囗囗)囗囗囗囗囗囗囗囗囗囗囗囗囗囗囗囗囗囗囗囗ijk囗囗囗囗囗囗囗囗囗囗囗囗

(囗囗囗囗)囗囗囗囗囗囗囗囗囗囗囗囗囗囗囗囗囗囗囗囗xyz囗囗囗囗囗囗囗囗囗囗囗囗

“囗囗囗囗”囗囗囗囗囗囗囗囗囗囗囗囗囗囗囗囗囗囗囗囗囗囗囗囗囗囗囗囗囗囗囗囗

“囗囗囗囗”囗囗囗囗囗囗囗囗囗囗囗囗囗囗囗囗囗囗囗囗ijk囗囗囗囗囗囗囗囗囗囗囗囗

“囗囗囗囗”囗囗囗囗囗囗囗囗囗囗囗囗囗囗囗囗囗囗囗囗xyz囗囗囗囗囗囗囗囗囗囗囗囗

Use Case

This is a common case in CJK typesetting.

Activity

  1. added
    feature request
    on Oct 10, 2023
  2. Enter-tainer commented on Oct 10, 2023

    @Enter-tainer
    Contributor

    I guess this is expected and comes from the adjustability of these punctuations. Per clreq: https://www.w3.org/TR/clreq/#h-compression_of_punctuation_marks_at_line_start

    For the case of first-line indent, if an opening bracket is set at the beginning of the first line of the paragraph, half a character space can be trimmed before the bracket.

    cc @peng1999

  3. Enter-tainer commented on Oct 10, 2023

    @Enter-tainer
    Contributor

    This causes the start of the paragraphs to look like misaligned.

    The unaligned behavior is indeed weird given that justify: true has been specified.

    It seems that clrep doesn't specify the adjustment amount of punctuations appears at the beginning of the line https://www.w3.org/TR/clreq/#procedures_for_inter-character_spacing_reduction

  4. peng1999 commented on Oct 10, 2023

    @peng1999
    Contributor

    @balthild

    I'm not sure if this is a bug or a feature that haven't been implemented.

    This is likely a bug. See below.

    @Enter-tainer

    It seems that clrep doesn't specify the adjustment amount of punctuations appears at the beginning of the line

    As I understand it, the adjustment described in section 3.1.6.2 and 3.1.6.3 do not contribute to "line adjustment" described in Section 3.5 Line Adjustment of CLREQ. The former adjustments can be thought as "default adjustments" and should always take place. But in typst, when I implement this feature, the two default adjustment is being implemented as part of general line adjustment and becoming optional depending on the line length. I think this is wrong.

    CLREQ section 3.1.6.3 mentioned "can be trimmed". I think it has an all-or-nothing meaning. Maybe we can provide an option in typst.

    After all, I think this issue is not hard to fix. I encourage anyone who interested in it to make a PR.

  5. added
    text
    on Oct 10, 2023
  6. PgBiel commented on Apr 1, 2024

    @PgBiel
    Contributor

    Does #3744 fix this?

  7. balthild commented on Apr 1, 2024

    @balthild
    Author

    No, but the result has changed a little.

    Tested with the current main branch (1e645b3).

    图片

  8. peng1999 commented on Apr 2, 2024

    @peng1999
    Contributor

    This problem now solves for paragraph with no indentation, but still exists otherwise.

  9. added
    bug
    and removed
    feature request
    on Jul 16, 2024
  10. added
    cjk
    on Feb 10, 2025
  11. added a commit that references this issue on Sep 4, 2026
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