diff options
| author | Ran Luo <ransixi@gmail.com> | 2024-04-02 04:22:00 +0800 |
|---|---|---|
| committer | Laurenz <laurmaedje@gmail.com> | 2024-05-17 14:27:58 +0200 |
| commit | 2c6b69ff6d078439e6c3018e901d6bbbb614419a (patch) | |
| tree | 73a7141e554f82cab11a37734436bea6ce025a77 | |
| parent | cdd8d167cf70c859f933dd93fb41a7e967d64663 (diff) | |
Fix compression of punctuation marks at line start of end (#3744)
| -rw-r--r-- | crates/typst/src/layout/inline/shaping.rs | 2 | ||||
| -rw-r--r-- | tests/ref/layout/par-justify-cjk.png | bin | 69916 -> 89706 bytes | |||
| -rw-r--r-- | tests/typ/layout/par-justify-cjk.typ | 13 |
3 files changed, 13 insertions, 2 deletions
diff --git a/crates/typst/src/layout/inline/shaping.rs b/crates/typst/src/layout/inline/shaping.rs index c346233e..82a33f9b 100644 --- a/crates/typst/src/layout/inline/shaping.rs +++ b/crates/typst/src/layout/inline/shaping.rs @@ -189,14 +189,12 @@ impl ShapedGlyph { self.x_offset -= amount; self.x_advance -= amount; self.adjustability.shrinkability.0 -= amount; - self.adjustability.stretchability.0 += amount; } /// Shrink the width of glyph on the right side. pub fn shrink_right(&mut self, amount: Em) { self.x_advance -= amount; self.adjustability.shrinkability.1 -= amount; - self.adjustability.stretchability.1 += amount; } } diff --git a/tests/ref/layout/par-justify-cjk.png b/tests/ref/layout/par-justify-cjk.png Binary files differindex a9baf14c..25adfcb2 100644 --- a/tests/ref/layout/par-justify-cjk.png +++ b/tests/ref/layout/par-justify-cjk.png diff --git a/tests/typ/layout/par-justify-cjk.typ b/tests/typ/layout/par-justify-cjk.typ index 51c86c7b..d0fef644 100644 --- a/tests/typ/layout/par-justify-cjk.typ +++ b/tests/typ/layout/par-justify-cjk.typ @@ -49,3 +49,16 @@ #set text(lang: "zh", region: "hk", font: "Noto Serif CJK TC") 孔雀最早见于《山海经》中的《海内经》:「有孔雀。」东汉杨孚著《异物志》记载,岭南:「孔雀,其大如大雁而足高,毛皆有斑纹彩,捕而蓄之,拍手即舞。」 + +--- +// Test punctuation marks adjustment in justified paragraph. + +// The test case includes the following scenarios: +// - Compression of punctuation marks at line start or line end +// - Adjustment of adjacent punctuation marks + +#set page(width: 110pt + 10pt, margin: (x: 5pt)) +#set text(lang: "zh", font: "Noto Serif CJK SC") +#set par(justify: true) + +标注在字间的标点符号(乙式括号省略号以外)通常占一个汉字宽度,使其易于识别、适合配置及排版,有些排版风格完全不对标点宽度进行任何调整。但是为了让文字体裁更加紧凑易读,,,以及执行3.1.4 行首行尾禁则时,就需要对标点符号的宽度进行调整。是否调整取决于…… |
