You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feature requestNew feature or requesti18nAbout language- or script-specific features. May need attention from native speakers.textRelated to the text category, which is all about text handling, shaping, etc.
Thai language does not use spaces between words, which causes Typst's justification engine to treat entire sentences as single words. This results in uneven spacing between characters when justify: true is set, as Typst cannot determine valid line-break positions within Thai text.
Use Case
Thai users writing academic papers, theses, or formal documents require proper text justification. Currently, setting #set par(justify: true) with Thai text produces uneven character spacing. Proper Thai justification would make Typst viable for Thai academic and professional document typesetting, which is a significant use case given that LaTeX remains the primary alternative solely due to this limitation.
Reacted by Ian, crystal :3, Nattapon Suta and Aobaun, Parinya
Theoretically we should be able to linebreak Thai text. Typst uses the ICU4X line segmenter and currently constructs it with LineSegmenter::try_new_lstm_with_buffer_provider, whose documentation says:
Constructs a LineSegmenter with an invariant locale, custom LineBreakOptions, and compiled LSTM data for complex scripts (Khmer, Lao, Myanmar, and Thai).
The LSTM, or Long Term Short Memory, is a machine learning model. It is smaller than the full dictionary but more expensive during segmentation (inference).
The current version does use ICU4X v1.4, although we are hoping to upgrade to v2.2, but I don't know whether that has improved any line segmenting for Thai text.
If you could provide a code block of text that doesn't linebreak which should, I can look into this and see if updating the ICU4X version or changing the line segmenter affects it.
Also, is this only an issue with justify: true, or are there issues with linebreaking in the other justification options?
Here are two comparison screenshots: Typst (with justify: true) — notice the large uneven gaps between words, especially visible in lines like "LaTeX ถือเป็น" and "ยาวนาน ด้วย" LibreOffice Writer (same text) — showing the expected Thai justification behavior, where spacing is distributed more evenly
The issue appears with justify: true but I haven't tested other justification options yet.
I investigated this just a bit more with Typst 0.15, and unfortunately there are no magic fixes from upgrading ICU4X.
Here's a Webapp project that has copyable Thai text displaying the bad spacing. I didn't see any real changes from mucking with the other text or par parameters, but inserting zero width spaces in-between characters did improve things.
With plain justify: true, the output is indeed not ideal for Thai text. However, after adjusting justification-limits, the resulting paragraph looks significantly better and much closer to the behavior of LibreOffice or Word.
Based on these results, I don't think the current problem is that Typst completely lacks Thai justification support or treats Thai sentences as unbreakable words. At the very least, the current behavior seems significantly better than what is described in the original report.
Instead, it seems that:
Thai line segmentation appears to be working.
Thai justification already appears possible.
The default justification parameters are often too restrictive for Thai text.
There may still be bugs or undesirable interactions with the optimized line-breaking algorithm (for example, extra spacing near the beginning or end of lines). (see: Wrong spacing for Thai words after a line break. #5543)
I also observed that linebreaks: "simple" sometimes produces more natural-looking Thai paragraphs than the default optimized line breaker.
For reference, I'm attaching the full test document used to generate the screenshots.
Typst source
#setpage(paper: "a4", margin: 30mm)
#settext(font: "Sarabun", size: 12pt)
#setpar(first-line-indent: (amount: 1.27cm, all: true))
#showheading: setblock(below: 1.2em)
#letcontent= [
ในแวดวงการจัดพิมพ์เอกสารทางวิชาการ LaTeX ถือเป็นมาตรฐานหลักที่ได้รับความนิยมมาอย่างยาวนาน ด้วยระบบนิเวศที่แข็งแกร่งและแพ็กเกจที่ครอบคลุมทุกการใช้งาน อย่างไรก็ตาม ผู้ใช้อาจต้องใช้เวลาในการเรียนรู้โครงสร้างโค้ดที่มีความซับซ้อน ในขณะที่ Typst ก้าวเข้ามาเป็นทางเลือกใหม่ที่น่าจับตามอง โดยซูจุด
เด่นเรื่องไวยากรณ์ที่เรียบง่ายคล้าย Markdown ซึ่งช่วยให้เรียนรู้ได้รวดเร็ว พร้อมระบบประมวลผลแบบทันที (Instant Preview) แม้ว่า Typst จะยังอยู่ในช่วงเริ่มต้นและมีชุมชนผู้ใช้งานขนาดเล็ก แต่ก็นับเป็นตัวเลือกที่มีประสิทธิภาพสำหรับผู้ที่มองหาความคล่องตัวในการทำงาน
In the typesetting of academic documents, LaTeX has long been a standard, widely accepted for its robust ecosystem and comprehensive package availability. However, users may need to invest time in learning its complex code structure. In contrast, Typst emerges as an interesting new alternative, offering a simple Markdown-like syntax that facilitates rapid learning. Additionally, it provides an Instant Preview feature. While Typst is still in its early stages and has a smaller user base, it stands out as a capable option for those seeking flexibility in their work.
]
== Original Content#content#setpar(justify: true)
== Justified Content#content#setpar(justify: true, justification-limits: (tracking: (min: 0em, max: 1em)))
== Justified Content with tracking max limit#content#setpar(justification-limits: (tracking: (min: -1em, max: 1em)))
== Justified Content with tracking min & max limit#content#setpar(linebreaks: "simple")
== Simple Line Breaks#content
I also found a potentially unrelated issue involving U+2060 WORD JOINER not preventing line breaks in some Thai cases and may open a separate issue for that.
Adding a related data point on Thai line breaking (not justification), with justify: false, since @isuffix asked for code blocks. Typst 0.15.1, Windows, font Leelawadee UI (Tahoma gives the same breaks).
The default segmenter breaks inside common compound words:
Breaks produced: โรง|พยาบาล (hospital), ทุก|คน (everyone), จัง|หวัด (province), กำลัง|กาย (in ออกกำลังกาย, exercise). A Thai reader sees each of these as a broken word.
What I tried:
ZWSP between words only (from a dictionary segmenter, PyThaiNLP newmm): adds correct break points, but Typst still breaks inside the words as above.
ZWSP between words + U+2060 WORD JOINER between grapheme clusters inside each word: worse. Typst breaks right at some of the joiners, mid-syllable (ออกกำลั|งกาย, ประชุ|ม). This matches the WORD JOINER observation in the comment above.
ZWSP between words + wrap each Thai run in a box: correct in every case I tried, including headings and text that comes from string variables:
#showregex("[\u{0E00}-\u{0E7F}]+"): it=>box(it)
Because ZWSP is outside the Thai block, each regex match is exactly one pre-segmented word, so the box makes it unbreakable and the only remaining break points are the ZWSPs. Keep justify: false with this, because boxes don't stretch.
So a workaround exists, but it needs an external segmenter. It might also be a useful test case if the ICU4X upgrade or a dictionary-based Thai segmenter is evaluated: the LSTM model seems to treat these compounds as separable.
feature requestNew feature or requesti18nAbout language- or script-specific features. May need attention from native speakers.textRelated to the text category, which is all about text handling, shaping, etc.
Activity
isuffix commentedon Jun 3, 2026
Theoretically we should be able to linebreak Thai text. Typst uses the ICU4X line segmenter and currently constructs it with
LineSegmenter::try_new_lstm_with_buffer_provider, whose documentation says:The current version does use ICU4X v1.4, although we are hoping to upgrade to v2.2, but I don't know whether that has improved any line segmenting for Thai text.
If you could provide a code block of text that doesn't linebreak which should, I can look into this and see if updating the ICU4X version or changing the line segmenter affects it.
Also, is this only an issue with
justify: true, or are there issues with linebreaking in the other justification options?pungpondsalami commentedon Jun 4, 2026
Here are two comparison screenshots:


Typst (with justify: true) — notice the large uneven gaps between words, especially visible in lines like "LaTeX ถือเป็น" and "ยาวนาน ด้วย"
LibreOffice Writer (same text) — showing the expected Thai justification behavior, where spacing is distributed more evenly
The issue appears with justify: true but I haven't tested other justification options yet.
isuffix commentedon Jun 23, 2026
I investigated this just a bit more with Typst 0.15, and unfortunately there are no magic fixes from upgrading ICU4X.
Here's a Webapp project that has copyable Thai text displaying the bad spacing. I didn't see any real changes from mucking with the other
textorparparameters, but inserting zero width spaces in-between characters did improve things.admannon commentedon Jul 12, 2026
I did some testing with a recent Typst version and got different results from the original issue report.
For reproducibility, I used:
With plain
justify: true, the output is indeed not ideal for Thai text. However, after adjustingjustification-limits, the resulting paragraph looks significantly better and much closer to the behavior of LibreOffice or Word.Based on these results, I don't think the current problem is that Typst completely lacks Thai justification support or treats Thai sentences as unbreakable words. At the very least, the current behavior seems significantly better than what is described in the original report.
Instead, it seems that:
I also observed that
linebreaks: "simple"sometimes produces more natural-looking Thai paragraphs than the default optimized line breaker.For reference, I'm attaching the full test document used to generate the screenshots.
Typst source
I also found a potentially unrelated issue involving U+2060 WORD JOINER not preventing line breaks in some Thai cases and may open a separate issue for that.
MankhongGarden commentedon Oct 9, 2026
Adding a related data point on Thai line breaking (not justification), with
justify: false, since @isuffix asked for code blocks. Typst 0.15.1, Windows, font Leelawadee UI (Tahoma gives the same breaks).The default segmenter breaks inside common compound words:
Breaks produced:
โรง|พยาบาล(hospital),ทุก|คน(everyone),จัง|หวัด(province),กำลัง|กาย(in ออกกำลังกาย, exercise). A Thai reader sees each of these as a broken word.What I tried:
newmm): adds correct break points, but Typst still breaks inside the words as above.ออกกำลั|งกาย,ประชุ|ม). This matches the WORD JOINER observation in the comment above.Because ZWSP is outside the Thai block, each regex match is exactly one pre-segmented word, so the box makes it unbreakable and the only remaining break points are the ZWSPs. Keep
justify: falsewith this, because boxes don't stretch.So a workaround exists, but it needs an external segmenter. It might also be a useful test case if the ICU4X upgrade or a dictionary-based Thai segmenter is evaluated: the LSTM model seems to treat these compounds as separable.