Skip to content

Commit c4e040c

Browse files
authored
Merge pull request #829 from alerque/measurement-stragglers
Cleanup measurement refactoring stragglers
2 parents b52a622 + b3628b8 commit c4e040c

File tree

3 files changed

+31
-20
lines changed

3 files changed

+31
-20
lines changed

packages/pdf.lua

+21-16
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,10 @@ SILE.registerCommand("pdf:bookmark", function (options, _)
2626
-- European languages, we use UTF-16BE for internationalization.
2727
local ustr = SU.utf8_to_utf16be_hexencoded(title)
2828
SILE.typesetter:pushHbox({
29-
value = nil, height = 0, width = 0, depth = 0,
29+
value = nil,
30+
height = SILE.measurement(0),
31+
width = SILE.measurement(0),
32+
depth = SILE.measurement(0),
3033
outputYourself = function ()
3134
local d = "<</Title<" .. ustr .. ">/A<</S/GoTo/D(" .. dest .. ")>>>>"
3235
SILE.outputters.libtexpdf._init()
@@ -50,9 +53,9 @@ end
5053
SILE.registerCommand("pdf:literal", function (_, content)
5154
SILE.typesetter:pushHbox({
5255
value = nil,
53-
height = 0,
54-
width = 0,
55-
depth = 0,
56+
height = SILE.measurement(0),
57+
width = SILE.measurement(0),
58+
depth = SILE.measurement(0),
5659
outputYourself = function (_, _, _)
5760
SILE.outputters.libtexpdf._init()
5861
pdf.add_content(content[1])
@@ -66,12 +69,12 @@ SILE.registerCommand("pdf:link", function (options, content)
6669
local llx, lly
6770
SILE.typesetter:pushHbox({
6871
value = nil,
69-
height = 0,
70-
width = 0,
71-
depth = 0,
72+
height = SILE.measurement(0),
73+
width = SILE.measurement(0),
74+
depth = SILE.measurement(0),
7275
outputYourself = function (_, typesetter, _)
73-
llx = typesetter.frame.state.cursorX
74-
lly = SILE.documentState.paperSize[2] - typesetter.frame.state.cursorY
76+
llx = typesetter.frame.state.cursorX:tonumber()
77+
lly = (SILE.documentState.paperSize[2] - typesetter.frame.state.cursorY):tonumber()
7578
SILE.outputters.libtexpdf._init()
7679
pdf.begin_annotation()
7780
end
@@ -81,12 +84,14 @@ SILE.registerCommand("pdf:link", function (options, content)
8184

8285
SILE.typesetter:pushHbox({
8386
value = nil,
84-
height = 0,
85-
width = 0,
86-
depth = 0,
87+
height = SILE.measurement(0),
88+
width = SILE.measurement(0),
89+
depth = SILE.measurement(0),
8790
outputYourself = function (_, typesetter, _)
8891
local d = "<</Type/Annot/Subtype/Link/C [ 1 0 0 ]/A<<" .. target .. "(" .. dest .. ")>>>>"
89-
pdf.end_annotation(d, llx, lly, typesetter.frame.state.cursorX, SILE.documentState.paperSize[2] -typesetter.frame.state.cursorY + hbox.height)
92+
local x = typesetter.frame.state.cursorX:tonumber()
93+
local y = (SILE.documentState.paperSize[2] - typesetter.frame.state.cursorY + hbox.height):tonumber()
94+
pdf.end_annotation(d, llx, lly, x, y)
9095
end
9196
})
9297
end)
@@ -96,9 +101,9 @@ SILE.registerCommand("pdf:metadata", function (options, _)
96101
local val = SU.required(options, "val", "pdf:metadata")
97102
SILE.typesetter:pushHbox({
98103
value = nil,
99-
height = 0,
100-
width = 0,
101-
depth = 0,
104+
height = SILE.measurement(0),
105+
width = SILE.measurement(0),
106+
depth = SILE.measurement(0),
102107
outputYourself = function (_, _, _)
103108
SILE.outputter._init()
104109
pdf.metadata(key, val)

packages/ruby.lua

+3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
-- Japaneese language support defines units which are useful here
2+
SILE.call("language", { main = "ja" }, {})
3+
14
SILE.registerCommand("ruby:font", function (_, _)
25
SILE.call("font", { size = "0.6zw", weight = 800 })
36
end)

packages/tate.lua

+7-4
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
-- Japaneese language support defines units which are useful here
2+
SILE.call("language", { main = "ja" }, {})
3+
14
SILE.tateFramePrototype = pl.class({
25
_base = SILE.framePrototype,
36
direction = "TTB-RTL",
@@ -37,7 +40,7 @@ local outputLatinInTate = function (self, typesetter, line)
3740
local vorigin = -typesetter.frame.state.cursorY
3841
self:oldOutputYourself(typesetter,line)
3942
typesetter.frame.state.cursorY = -vorigin
40-
typesetter.frame:advanceWritingDirection(self:lineContribution().length)
43+
typesetter.frame:advanceWritingDirection(self:lineContribution())
4144
-- My baseline moved
4245
typesetter.frame:advanceWritingDirection(SILE.measurement("0.5zw") )
4346
typesetter.frame:advancePageDirection(-SILE.measurement("0.25zw"))
@@ -46,9 +49,9 @@ end
4649

4750
local outputTateChuYoko = function (self, typesetter, line)
4851
-- My baseline moved
49-
local em = SILE.toPoints("1zw")
50-
typesetter.frame:advanceWritingDirection(-(em) + em/4 - self:lineContribution()/2)
51-
typesetter.frame:advancePageDirection(2*self.height - self.width.length/2)
52+
local em = SILE.measurement("1zw")
53+
typesetter.frame:advanceWritingDirection(-em + em/4 - self:lineContribution()/2)
54+
typesetter.frame:advancePageDirection(2*self.height - self.width/2)
5255
self:oldOutputYourself(typesetter,line)
5356
typesetter.frame:advanceWritingDirection(-self:lineContribution()*1.5+self.height*3/4)
5457

0 commit comments

Comments
 (0)