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
{{ message }}
Repository navigation
CJK punctuation compression overlaps glyphs in proportional Japanese fonts (e.g. BIZ UDPGothic) #9104
With a proportional Japanese font such as BIZ UDPGothic (free, Google Fonts), adjacent CJK punctuation overlaps. Typst applies its CJK punctuation compression as if every glyph were full-width (1em), but in this font the punctuation is already half-width.
:『: the colon is squeezed under the opening bracket and is almost invisible.
」「, 』第, 、『: the brackets touch or overlap the neighbouring glyph.
BIZ UDGothic, Hiragino Sans and Ryumin (all full-width punctuation) render the same line correctly. The overlap also happens with lang: "en", and region: "tw" does not avoid it.
Cause (as far as I can tell). The punctuation in BIZ UDPGothic has these advances in hmtx (unitsPerEm 2048):
glyph
BIZ UDGothic
BIZ UDPGothic
:『』「」()
2048
1024
、。
2048
1229
In crates/typst-layout/src/inline/shaping.rs, is_cjk_left_aligned_punctuation and is_cjk_right_aligned_punctuation classify :, 『, 」 and similar characters by code point alone. Only ”’“‘ are checked against x_advance + stretchability == Em::one(). base_adjustability then allows shrinking by width / 2, and calculate_adjustability removes width / 2 between consecutive punctuation. For a glyph that is already 0.5em wide, this removes half of the remaining advance, which eats into the ink.
Expected. Punctuation whose advance is already narrower than 1em (proportional fonts, or fonts shaped with palt/halt) should not be compressed again. One option would be to apply the same full-width check used for the curly quotes to all CJK punctuation.
Workaround. Use a full-width face for the Japanese text and the proportional face only for Latin letters and digits:
Activity