Repository navigation
Closed
Labels
feature requestNew feature or requestgood contributionSuitable for contribution, but unlike "good first issue", it may need prior experiencelayoutRelated to the layout category, which is about composing, positioning, etc.
Description
Description
Typst currently has https://typst.app/docs/reference/layout/rotate/ and https://typst.app/docs/reference/layout/scale/, but no skew transform. While it can be expressed using a combination of the former, it's not trivial to get right
#let skew(angle,vscale: 1,body) = {
let (a,b,c,d)= (1,vscale*calc.tan(angle),0,vscale)
let E = (a + d)/2
let F = (a - d)/2
let G = (b + c)/2
let H = (c - b)/2
let Q = calc.sqrt(E*E + H*H)
let R = calc.sqrt(F*F + G*G)
let sx = Q + R
let sy = Q - R
let a1 = calc.atan2(F,G)
let a2 = calc.atan2(E,H)
let theta = (a2 - a1) /2
let phi = (a2 + a1)/2
set rotate(origin: bottom+center)
set scale(origin: bottom+center)
rotate(phi,scale(x: sx*100%, y: sy*100%,rotate(theta,body)))
}
(The vscale parameter is strictly speaking unnecessary)
Use Case
A couple of trivial examples are fake italic text and shadows
#let fake-italic(body) = skew(-12deg,body)
#let shadowed(body) = box(place(skew(-50deg, vscale: 0.8, text(fill:luma(200),body)))+place(body))
#fake-italic[This is fake italic text]
#shadowed[This is some fancy text with a shadow]
Reacted by Myriad-Dreamin, sitandr, Wenzhuo Liu, Sébastien d'Herbais de Thun, Florian Sihler, Sky126, Andrew Voynov and OrangeX4
Metadata
Metadata
Assignees
Labels
feature requestNew feature or requestgood contributionSuitable for contribution, but unlike "good first issue", it may need prior experiencelayoutRelated to the layout category, which is about composing, positioning, etc.

Activity
csimide commentedon Mar 20, 2024
Hello, I would like to use the skew transform implementation code in this issue to add fake italics support to cuti, a package released under the MIT license. Would it be possible for me to utilize this code for that purpose?
Enivex commentedon Mar 20, 2024
Feel free
laurmaedje commentedon Sep 2, 2024
Resolved by #4803