Skip to content

Commit

Permalink
Merge pull request #914 from alerque/issue-912
Browse files Browse the repository at this point in the history
  • Loading branch information
alerque committed Jul 8, 2020
2 parents 09a653a + 0613ab1 commit aceb805
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
12 changes: 6 additions & 6 deletions packages/rotate.lua
@@ -1,16 +1,15 @@
local pdf = require("justenoughlibtexpdf")

local enter = function(self)
local enter = function (self)
if not self.rotate then return end
local x = -math.rad(self.rotate)
-- Keep center point the same
pdf:gsave()
local cx = self:left()
local cy = -self:bottom()

pdf.setmatrix(1,0,0,1,cx + math.sin(x) * self:height(),cy)
local cx = self:left():tonumber()
local cy = -self:bottom():tonumber()
pdf.setmatrix(1, 0, 0, 1, cx + math.sin(x) * self:height():tonumber(), cy)
pdf.setmatrix(math.cos(x), math.sin(x), -math.sin(x), math.cos(x), 0, 0)
pdf.setmatrix(1,0,0,1,-cx,-cy)
pdf.setmatrix(1, 0, 0, 1, -cx, -cy)
end

local leave = function(self)
Expand Down Expand Up @@ -46,6 +45,7 @@ local outputRotatedHbox = function (self, typesetter, line)

local horigin = (typesetter.frame.state.cursorX + origbox.width.length / 2):tonumber()
local vorigin = -(typesetter.frame.state.cursorY + origbox.height / 2):tonumber()
SILE.outputters.libtexpdf._init()
pdf:gsave()
pdf.setmatrix(1, 0, 0, 1, horigin, vorigin)
pdf.setmatrix(math.cos(x), math.sin(x), -math.sin(x), math.cos(x), 0, 0)
Expand Down
8 changes: 8 additions & 0 deletions tests/rotate.sil
@@ -0,0 +1,8 @@
\begin[papersize=a6]{document}
\frame[id=folio,left=10pt,top=10pt,rotate=-15]
\script[src=packages/rotate]
\noindent
\rotate[angle=90]{issue 913}

issue \rotate[angle=35]{912 \rotate[angle=35]{foo}}
\end{document}

0 comments on commit aceb805

Please sign in to comment.