Skip to content

Problem with em spaces (or en) with justified paragraphs. #8193

Open

Description

@nessi-bl

Run this code -

`
#set page(width: 5in)
#set par(justify: true)

#lorem(100)

לאחר שנאספו כל ההחלטות שהיו פזורות בכרכי זיכרונות האקדמיה, נפרסה התמונה הכוללת ונחשפו בעיות מסוגים שונים: אי־אחידות בניסוח, כללים ופרטים חסרים, חוסר התאמה למציאות הלשונית, סתירות פנימיות ועוד. עלה אפוא צורך לשקול מחדש החלטות רבות, לשנותן, לתקנן, להשלימן או לעדכנן. ועדת הדקדוק[4] ישבה על מדוכה זו ברבות מישיבותיה בשנים תשנ"ד–תשס"ה ופעלה נמרצות לשיפור הכללים, להשלמתם ולעדכונם. נוסף על כך העמידה הוועדה כללים חדשים רבים – בהם פרקים בנטיית הפועל.

#show " ": sym.space.quad
#lorem(100)

לאחר שנאספו כל ההחלטות שהיו פזורות בכרכי זיכרונות האקדמיה, נפרסה התמונה הכוללת ונחשפו בעיות מסוגים שונים: אי־אחידות בניסוח, כללים ופרטים חסרים, חוסר התאמה למציאות הלשונית, סתירות פנימיות ועוד. עלה אפוא צורך לשקול מחדש החלטות רבות, לשנותן, לתקנן, להשלימן או לעדכנן. ועדת הדקדוק[4] ישבה על מדוכה זו ברבות מישיבותיה בשנים תשנ"ד–תשס"ה ופעלה נמרצות לשיפור הכללים, להשלמתם ולעדכונם. נוסף על כך העמידה הוועדה כללים חדשים רבים – בהם פרקים בנטיית הפועל.

#set text(dir: rtl)
#lorem(100)

לאחר שנאספו כל ההחלטות שהיו פזורות בכרכי זיכרונות האקדמיה, נפרסה התמונה הכוללת ונחשפו בעיות מסוגים שונים: אי־אחידות בניסוח, כללים ופרטים חסרים, חוסר התאמה למציאות הלשונית, סתירות פנימיות ועוד. עלה אפוא צורך לשקול מחדש החלטות רבות, לשנותן, לתקנן, להשלימן או לעדכנן. ועדת הדקדוק[4] ישבה על מדוכה זו ברבות מישיבותיה בשנים תשנ"ד–תשס"ה ופעלה נמרצות לשיפור הכללים, להשלמתם ולעדכונם. נוסף על כך העמידה הוועדה כללים חדשים רבים – בהם פרקים בנטיית הפועל.`

Then look at the results (or just see atached pdf)

demo_y.pdf

for english - look at the yellowed part. For Hebrew text you will seeright away. I would guess that this is also a problem with Arabic.

I'm running current instalation of Archlinux. Typst version is 0.14.2 (b33de9d).

And anyway, thank you for an already excellent tool!

Ben

Activity

  1. MDLC01 commented on May 17, 2026

    @MDLC01
    Collaborator

    Could you clarify exactly what the problem is? What do you expect, and what do you see instead?

  2. added
    bug
    text
    on May 17, 2026
  3. nessi-bl commented on May 17, 2026

    @nessi-bl
    Author

    Please look at the pdf I've attached to my original message. And to clarify - onve spaces are replace with em-spaces, justification becomes batty. It's more prononced in hebrew texts.

    In the code I've psoted above, I'm asking for justification in paragraphs. Then I'm creating 3 sets of texts, each comprised from #lorem(100) followed by hebrew text.

    1st set is normal spaces, everything is just fime.
    2nd set, I'm replacing spaces with em spaces - #show " ": sym.space.quad. In the english text you can see some battines (yellowed in the pdf), but the hebrew text .... all hell breaks loose.
    3rd set iis just like the second but with text direction set to rtl - same problems (but on the left instead of the right side).

    There is something wrong with handling em-spaces. It's MUCH more pronaunced in hebrew (and I guess arabic and othe rtl languages).

  4. MDLC01 commented on May 17, 2026

    @MDLC01
    Collaborator

    I am not surprised that the paragraphs aren't justified properly when using EM spaces: there is no regular space to stretch or shrink to justify the text.

    That Hebrew text is not line wrapped properly is an actual issue though.

    More minimal reproduction, without justification:

    #set page(width: 5in)
    #set text(lang: "he")
    #show " ": sym.space.quad
    
    לאחר שנאספו כל ההחלטות שהיו פזורות בכרכי זיכרונות האקדמיה, נפרסה התמונה הכוללת ונחשפו בעיות מסוגים שונים: אי־אחידות בניסוח, כללים ופרטים חסרים, חוסר התאמה למציאות הלשונית, סתירות פנימיות ועוד. עלה אפוא צורך לשקול מחדש החלטות רבות, לשנותן, לתקנן, להשלימן או לעדכנן. ועדת הדקדוק[4] ישבה על מדוכה זו ברבות מישיבותיה בשנים תשנ"ד–תשס"ה ופעלה נמרצות לשיפור הכללים, להשלמתם ולעדכונם. נוסף על כך העמידה הוועדה כללים חדשים רבים – בהם פרקים בנטיית הפועל.
    Hebrew text with a line that extends beyond the end of the page instead of being wrapped properly.
  5. added
    i18n
    on May 17, 2026
  6. MDLC01 commented on May 17, 2026

    @MDLC01
    Collaborator

    Let's keep this issue open to track the line wrapping problem

  7. reopened this on May 17, 2026
  8. YDX-2147483647 commented on Nov 10, 2026

    @YDX-2147483647
    Contributor

    This issue is caused by the upstream Unicode Line Breaking Algorithm (UAX #14).

    The current line segmenter used by Typst is targeting Unicode 15.1. In this version of the algorithm, LB21a, the rule preventing line breaks after Hebrew hyphens, is so broad that it unconditionally treats em spaces (as an instance of BA) the same as hyphens. As a result, em spaces after Hebrew characters prevent line breaks.

    This mistake has already been corrected in Unicode 16. In the latest algorithm, LB21a is only effective when the hyphen or the em space is followed by a non-Hebrew character. In other words, LB21a no longer interfere with this issue.

    There, this issue can be fixed by upgrading the line segmenter to Unicode 18. See #9002 for the details.

    Questions

    In #9057, I confirm that the lines no longer overflow after the line segmenter is updated to Unicode 18.
    However, I'm not sure if the results are correct for Hebrew.
    Does anyone know Hebrew? Could you take a look at the following two cases?

    1. In the following sentence, if the regular spaces are replaced with em spaces, are the line break opportunities marked by | appropriate? Are there any unwanted or missing opportunities?

    עִבְרִית היא שפה שמית, ממשפחת השפות האפרו-אסייתיות, הידועה כשפתם של היהודים ושל השומרונים.

    |עִבְרִית |היא |שפה |שמית, |ממשפחת |השפות |האפרו-|אסייתיות, |הידועה |כשפתם |של |היהודים |ושל |השומרונים.|

    1. In the following image, the top half uses regular spaces, and the bottom half uses em spaces. Are the results acceptable?
    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

    bugi18ntext

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions