Repository navigation
Description
Introduction
Vertical layout remains vital across various cultures and contexts,
particularly in traditional East Asian typesetting.
This RFC proposes the implementation of vertical writing mode support in Typst.
Features to implement
Vertical writing
And figure placement, accordingly:
Vertical text in graph
Latin & formulae in vertical text
All block formulas are rotated 90° to the right of the entire formula block. Alphanumeric characters and mathematical symbols are all folded sideways.
Short inline math that fits into 1x line-height(?) can be upright (tate-chu-yoko).
More Tate-Chu-Yoko (縦中横)
Numbers:
Full-width letters:
https://tategaki.github.io/
https://marumarumarumori.jp/
Compression or not:
Punctuations
Punctuation marks used in Taiwan and Hong Kong are usually positioned in the vertical and horizontal center of the square space left for them; while in vertical writing mode and horizontal writing mode, some of the punctuation marks are positioned in different directions so as to mark the corresponding characters more accurately. In Mainland China, the punctuation marks are usually positioned following the characters they are supposed to mark; while some punctuation marks might be positioned in different directions due to the vertical or horizontal writing mode. Also, different writing modes might require different punctuation marks to fulfill the same function, e.g. horizontal writing mode requires curved quotation marks while vertical writing mode requires corner brackets.
Proposed Solution
The core of this proposal is to extend Typst's text model and layout engine to accommodate vertical writing modes, providing a clear API for controlling and customizing text direction.
API changes
writing-mode text attr
Introduce writing-mode as an attribute for the text element and within style contexts that affect text layout. writing-mode should be a general typesetting instruction, independent of specific script systems. Users should be able to explicitly set the text direction.
Values for writing-mode include:
"horizontal-tb": Horizontal, top-to-bottom line progression (default, current horizontal mode)."vertical-rl": Vertical, right-to-left column progression (traditional East Asian vertical mode)."vertical-lr": Vertical, left-to-right column progression (e.g., Mongolian script).
inline and block axis
Writing mode is the direction of lines of text at the block level. rtl is the direction of text at the inline level. Properties that follows text direction are called logical ones. They will be mapped to physical ones based on writing-mode & rtl.
New functions, params and values
Existing layout functions like h(), v(), align(), move(), hline, etc. need adjustments for vertical writing modes. The proposal advocates for logical APIs that adapt their behavior based on the current writing-mode.
h()andv(): new logical spacing functions (inline-space(),block-space()) that maps toh()/v(). Also,hline()andvline().move(di, db): Modifymove(dx, dy)tomove(di, db), wherediis inline direction movement anddbis block direction movement.move's behavior would then adapt towriting-mode.height,width:block-sizeandinline-size.alignmenttype: we havestartandendfor inline.block-start&block-endare needed.directiontype: maybe we need ste, ets?
Technical issues
Text shaping
Shaping engines are typically designed for horizontal text. In vertical writing mode, many glyphs require a 90-degree clockwise rotation for correct display. Traditional Mongolian (ᠮᠣᠩᠭᠣᠯ), for instance, also involves a 90-degree clockwise rotation. However, because its block axis progresses from left to right, the order of glyphs within each line needs to be reversed as well.
CJK characters and emojis, on the other hand, generally do not require rotation. To correctly display punctuation marks, it may be necessary to enable the vert OpenType feature (although Unicode provides separate code points for rotated punctuation). Currently, there are no known examples of rtl(?) vertical text.
HTML export
Currently, adding a writing-mode property and all things are done.
Style export should use logical properties and values. However, there are still some values that do not have a logical version, so maybe we need to resolve the logical properties into physical ones.
Backward Compatibility
This proposal prioritizes backward compatibility. writing-mode as a new text attribute defaults to "horizontal-tb", ensuring existing Typst documents render unchanged. API modifications will be carefully designed. Retaining physical attributes alongside new logical attributes helps guarantee backward compatibility during the transition.
Resource Prioritization
Given potential resource constraints, we can make the foundational logical API available first (which benefits rtl text as well — For example, we don't need to write dir.sign() or pass the rtl parameter. Instead, we can directly use the logical layout keyword). Or we will find it too late to make breaking changes.


















Activity
SaadiSave commentedon May 26, 2025
@OverflowCat what kind of breaking changes would this require if implemented in the not-so-near future? Is it entirely impossible to implement this as a package? I do agree with your premise though, that vertical writing modes should eventually be available in the compiler. Have you already started designing the implementation, or is it on hold?
vanleefxp commentedon May 27, 2025
I am also looking forward to this feature. In a recent use case of Typst I would like to layout a literary text in Chinese with vertical writing mode. Sadly Typst does not support this natively so I investigated if other tools can do it. Options I've found include UpTeX, Word / LibreOffice Writer, InDesign and HTML + CSS. In the aforementioned methods, I think that HTML + CSS works best, as it is free and programmatic enough to cope with complicated layout. Most importantly, it is an open-source solution like Typst. However, there are still limitations. For example, page headers and footers, layout optimization over pages and creating footnotes corresponding to pages. These features are mostly page related, which Typst can handle well.
So, has it the possibility to implement vertical writing mode by a Typst package? For example, use a function to find all the characters that need to be rotated and rotate them by 90 degrees. Currently I haven't seen such packages in Typst Universe.
Andrew15-5 commentedon May 27, 2025
It's possible as long as the text stays on the same page. Multi-page layout is probably the core issue. Maybe if you know exactly how everything will flow in different situations, then you can try and hack your way through it. I would assume this is very complex and might be impossible, and some research is needed which methods are available and their key points. But Typst might be just powerful enough to pull this off, because a lot of packages use a lot of trickery hacking to be able to build incredible things.
OverflowCat commentedon May 27, 2025
SaadiSave commentedon May 28, 2025
@OverflowCat so how must we go about convincing the project that vertical text layout is something that should be taken care of as quickly as possible?
Andrew15-5 commentedon May 28, 2025
@SaadiSave, there are a lot of other things that have higher priority at the moment. There were no instances where all of a sudden a priority of one thing is completely changed from backlog to urgent, IIRC. The only thing that sounds similar was an addition of decimal data type. And even then, it's way easier to add than a proper vertical/ttb layout. Both, in terms of code and API complexity.
SaadiSave commentedon May 28, 2025
@Andrew15-5
Is there any way to start preliminary design work in the meantime? A proof of concept perhaps? I can help and know Rust, but next to nothing about typesetting (I just use typst and wanted to typeset Japanese vertically the other day), so I cannot do it on my own.
Enivex commentedon May 28, 2025
I would imagine adding vertical text layout requires extensive changes to typst. Not exactly an ideal candidate for a first PR.
It's also the kind of thing I wouldn't start working on without team approval. Otherwise you run the risk of wasting a lot time and energy.
Andrew15-5 commentedon May 28, 2025
I'm more or less the same. I just don't depend on it in any way other than it would be nice to have it and maybe try it out. Also I'm pretty busy most of the time.
If you want a PoC and can't do it on your own, then you can either find someone that has the things that you need or wait for someone to take the initiative themselves.
If you want to talk about API design, then feel free. If someone is interested, they could share their thoughts on it.
Indeed, the PoC or the API design might not be added in the codebase, but as a standalone thing you can do whatever you want.
But spamming a lot of messages is not great if you are the only one posting them. You can edit your messages if that's a problem. (If it becomes a monologue.)
tjwhang commentedon Nov 27, 2025
Here are some more (detailed) references for how the feature should be implemented
Japanese: https://www.w3.org/TR/jlreq/?lang=en
Korean: https://www.w3.org/TR/klreq/?lang=en
Chinese: https://www.w3.org/TR/clreq/?lang=en
https://fantasai.inkedblade.net/style/discuss/vertical-text/paper
https://www.typotheque.com/articles/typesetting-cjk-text
https://www.typotheque.com/blog/collection-of-new-original-cjk-fonts
https://www.w3.org/International/articles/vertical-text/
neruthes commentedon Apr 20, 2026
I did some POC in userland with basic overhang/underhang. Should I make it a package?
forfudan commentedon Apr 20, 2026
Great work! Looks fantastic!
Andrew15-5 commentedon Apr 20, 2026
The https://x.com/kanata201612/status/2027328191757791714 post was shared a few times in the くみはんクラブ server.
Since then there were no updates (on the server). It might not be released as a package, but someone probably can make one from the book that shows how to typeset this.
neruthes commentedon Apr 20, 2026
Package done. PR welcomed. Some implementation choices feel hacky; need help on edge case handling, etc.
kanata2003 commentedon Apr 26, 2026
Hi,
I’m the developer of the vertical writing feature that Mr. Andrew introduced.
I still have a few areas I’d like to improve, and once I’ve sorted those out, I’m thinking of registering it on Typst Universe.
Iktahana commentedon Nov 1, 2026
Hi! I’m the developer of Illusions, a writing application focused on Japanese literary typesetting.
Our document engine is written in Rust, and we’re currently exploring Typst as a possible replacement for Chromium-based PDF generation, particularly to achieve consistent output across platforms.
Native vertical writing support is one of our main requirements.
I’d be happy to contribute to this feature, but before getting started, I’d like to ask:
We also have real-world test cases involving Japanese vertical text, ruby, kinsoku shori, tate-chu-yoko, and warichu that we’d be happy to share.
Thanks for all your work on Typst!