From aa62d054532e91f988c39dee97c00ce54f18b605 Mon Sep 17 00:00:00 2001 From: Laurenz Date: Sat, 28 Oct 2023 20:05:32 +0200 Subject: [PATCH] Fix justification with hanging indent and negative spacing Fixes #2419 --- crates/typst-library/src/layout/par.rs | 12 +++++++++--- tests/ref/bugs/justify-hanging-indent.png | Bin 0 -> 1864 bytes tests/typ/bugs/justify-hanging-indent.typ | 6 ++++++ 3 files changed, 15 insertions(+), 3 deletions(-) create mode 100644 tests/ref/bugs/justify-hanging-indent.png create mode 100644 tests/typ/bugs/justify-hanging-indent.typ diff --git a/crates/typst-library/src/layout/par.rs b/crates/typst-library/src/layout/par.rs index ee47b5799..9255124e3 100644 --- a/crates/typst-library/src/layout/par.rs +++ b/crates/typst-library/src/layout/par.rs @@ -1015,9 +1015,15 @@ fn linebreak_optimized<'a>(vt: &Vt, p: &'a Preparation<'a>, width: Abs) -> Vec}2Zb=9xz(Y|>`0hl*a*26H6+)Sk+tLUx~!u^Lqe|8klQho zTa9L7Vdau*a!KS;m|K#`d){Bp=l#4tyx$+5&-45P&o|MIU?BxN0s{a5QdXAOivR#n z{O?YJ{v809S(O+703vOLHF1o1zcdCm~_2BLg+rEzE z2n2x7TyjwLkSsWs0!hbGC*OG9IdZPi;F(NU__hZ-G13@uUwiANpKHG262!A=RM6QT zpa-1UrbXuxcpXIDo7Bs%ucsh58IPx8u2qF>Nkx|KypsM!mu+#5Bhc&EFyf6$g$`$k zxgK?1Ymmn4+$%pr)0=Rz4S%Mm5SAI1Lokr%W%lspjBBOh$9uY4K7M=9XcW9^9IHS~ z>-B7Z`O(!0Q ze_k%ImV4^W2@EkPFygEeHy*l_Mup-C{lp#57KRLZ%5uoyu32?0%V9?5u=govumB}h z*ZfL!CQtchE*4u5goTszT>Ica); zS-GSf5df8ohNz@TQL+IdHwlw!8+LKkE~R_ADehlti3xyVH_h5SigY1YS3<7;CrnWL z$og9z-RVY}1bdurPvEMS`9GhnHY*0=X5oD(Sfek-zrDYG-0(u}S72^)%!Q^v*OggN z1O<|XYXAP;d;l1a-!Bwkz3?=Bh1A^(MB<tt%NGDzj`l{p-XXx;Oq+!&IT)ukr)B%cln3J^ z6NURr!aqoK^$8vV8)PpVg*qNkQZB_o^WRF#M12xB@%rI|(H~PgI6p0Ev%Iz<1M@zT zqKaX5KLxB9-6+9L+@+?0bJNA9c6+%jJ+sDp;%p_ZYSRs!*wGr6Je1Ngz~3}{MX8D* z4$J{qgQ&)XAexh!Z~!{RDDQ(Q4grPp*XYyXJKRmMHYGvNTOZr?PSz_aPySmcfw`W7 zGv59RFQuBPJ0n!>?cR~Z(z^pS!-OZ>IIX@B?x>^5)OMVved0-ukx--aY^Ga+Z~R8E1PR= z3R6=D4JkE`NTlLVX@(bbKQxFYmOu@%hWBWdv&=Y5<)0Bgs7Y) zk>@IQw__G;@>O;?K79>yE#E7JCX+=^hD4h8`!{K(@Rvk#^d)50ozY3Z1!#NlZuII} zcw}?Qirne{e#NLmCkCL}HGNPHX;Osfy1k?g61e7sq#kvG7SmW?_IxnSm?!)9vBs1z z;e}LW;7yEN@Jm_M{M7VO_KT4couj|C3`Q`o3HlqaA}h8VJp-cm1is1S@o>0c8T>U9 zh(kH@vBLU_gueAcQ;Ajs{^u5jMN_tE%5yOPxB^)oUYQYc4yE-e{O%|rSQ2X2618># z4d?qD>+KeELCU%u|H4w`wOw=*=lz%q&#FHU`Y3&CFXQ<(Qmsrg;t&t#8g{I;un8&N zbwc>Svi+jeny&$4G!LTa)+FJhHITY8W+kb z5NKaxkcOLD4&uG?8fnG-VUw5M{eha@5JEN2a8 wvD*#UbQ8DS^X7}JXa7ep-&+xse^5$|23nNLT@lgivHww|l{o=hW$G3CZ*OLJP5=M^ literal 0 HcmV?d00001 diff --git a/tests/typ/bugs/justify-hanging-indent.typ b/tests/typ/bugs/justify-hanging-indent.typ new file mode 100644 index 000000000..511aa172e --- /dev/null +++ b/tests/typ/bugs/justify-hanging-indent.typ @@ -0,0 +1,6 @@ +// Test that combination of justification and hanging indent doesn't result in +// an underfull first line. + +--- +#set par(hanging-indent: 2.5cm, justify: true) +#lorem(5)