From ff16f3fb370a1688e59fbbaf8824302d2b2f1a7b Mon Sep 17 00:00:00 2001 From: Peng Guanwen Date: Thu, 13 Apr 2023 16:44:39 +0800 Subject: Refine linebreak algorithm for better Chinese justification (#701) --- tests/ref/layout/par-justify-cjk.png | Bin 0 -> 43928 bytes tests/ref/layout/par-justify.png | Bin 29600 -> 12441 bytes tests/ref/layout/par-knuth.png | Bin 69406 -> 68723 bytes tests/ref/text/linebreak.png | Bin 19142 -> 18973 bytes tests/typ/layout/par-justify-cjk.typ | 23 +++++++++++++++++++++++ tests/typ/layout/par-justify.typ | 6 ------ 6 files changed, 23 insertions(+), 6 deletions(-) create mode 100644 tests/ref/layout/par-justify-cjk.png create mode 100644 tests/typ/layout/par-justify-cjk.typ (limited to 'tests') diff --git a/tests/ref/layout/par-justify-cjk.png b/tests/ref/layout/par-justify-cjk.png new file mode 100644 index 00000000..ee58318a Binary files /dev/null and b/tests/ref/layout/par-justify-cjk.png differ diff --git a/tests/ref/layout/par-justify.png b/tests/ref/layout/par-justify.png index 8a1578fe..a16c3f7b 100644 Binary files a/tests/ref/layout/par-justify.png and b/tests/ref/layout/par-justify.png differ diff --git a/tests/ref/layout/par-knuth.png b/tests/ref/layout/par-knuth.png index afe590b0..f3da1753 100644 Binary files a/tests/ref/layout/par-knuth.png and b/tests/ref/layout/par-knuth.png differ diff --git a/tests/ref/text/linebreak.png b/tests/ref/text/linebreak.png index 64d0d403..c127182c 100644 Binary files a/tests/ref/text/linebreak.png and b/tests/ref/text/linebreak.png differ diff --git a/tests/typ/layout/par-justify-cjk.typ b/tests/typ/layout/par-justify-cjk.typ new file mode 100644 index 00000000..1016b282 --- /dev/null +++ b/tests/typ/layout/par-justify-cjk.typ @@ -0,0 +1,23 @@ +// Test Chinese text in narrow lines. + +// In Chinese typography, line length should be multiples of the character size +// and the line ends should be aligned with each other. +// Most Chinese publications do not use hanging punctuation at line end. +#set page(width: auto) +#set par(justify: true) +#set text(overhang: false, lang: "zh") + +#rect(inset: 0pt, width: 80pt, fill: rgb("eee"))[ + 中文维基百科使用汉字书写,汉字是汉族或华人的共同文字,是中国大陆、新加坡、马来西亚、台湾、香港、澳门的唯一官方文字或官方文字之一。25.9%,而美国和荷兰则分別占13.7%及8.2%。近年來,中国大陆地区的维基百科编辑者正在迅速增加; +] + +--- +// Japanese typography is more complex, make sure it is at least a bit sensible. +#set page(width: auto) +#set par(justify: true) +#set text(lang: "jp") +#rect(inset: 0pt, width: 80pt, fill: rgb("eee"))[ + ウィキペディア(英: Wikipedia)は、世界中のボランティアの共同作業によって執筆及び作成されるフリーの多言語インターネット百科事典である。主に寄付に依って活動している非営利団体「ウィキメディア財団」が所有・運営している。 + + 専門家によるオンライン百科事典プロジェクトNupedia(ヌーペディア)を前身として、2001年1月、ラリー・サンガーとジミー・ウェールズ(英: Jimmy Donal "Jimbo" Wales)により英語でプロジェクトが開始された。 +] \ No newline at end of file diff --git a/tests/typ/layout/par-justify.typ b/tests/typ/layout/par-justify.typ index 24d3ab38..7034a42b 100644 --- a/tests/typ/layout/par-justify.typ +++ b/tests/typ/layout/par-justify.typ @@ -20,12 +20,6 @@ D A B C #linebreak(justify: true) D E F #linebreak(justify: true) ---- -// Test that justificating chinese text is at least a bit sensible. -#set page(width: 200pt) -#set par(justify: true) -中文维基百科使用汉字书写,汉字是汉族或华人的共同文字,是中国大陆、新加坡、马来西亚、台湾、香港、澳门的唯一官方文字或官方文字之一。25.9%,而美国和荷兰则分別占13.7%及8.2%。近年來,中国大陆地区的维基百科编辑者正在迅速增加; - --- // Test that there are no hick-ups with justification enabled and // basically empty paragraph. -- cgit v1.2.3