summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRan Luo <ransixi@gmail.com>2024-04-02 04:22:00 +0800
committerGitHub <noreply@github.com>2024-04-01 20:22:00 +0000
commit16c3af7c92de97d14f52319bd375f842ce37a949 (patch)
tree068ee7612635b7039cbdeb13400336c28ce8434f
parent7b9faa81bf5156819f25ff2d232d63c053483665 (diff)
Fix compression of punctuation marks at line start of end (#3744)
-rw-r--r--crates/typst/src/layout/inline/shaping.rs2
-rw-r--r--tests/ref/layout/par-justify-cjk.pngbin69916 -> 89706 bytes
-rw-r--r--tests/typ/layout/par-justify-cjk.typ13
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
index a9baf14c..25adfcb2 100644
--- a/tests/ref/layout/par-justify-cjk.png
+++ b/tests/ref/layout/par-justify-cjk.png
Binary files differ
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 行首行尾禁则时,就需要对标点符号的宽度进行调整。是否调整取决于……