Skip to content

Commit

Permalink
refactor: Compatibility upgrade with SILE 0.15
Browse files Browse the repository at this point in the history
  • Loading branch information
Omikhleia authored and Didier Willis committed Aug 1, 2024
1 parent 4f3e404 commit 32a34c0
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 5 deletions.
12 changes: 7 additions & 5 deletions packages/qrcode/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
-- Didier Willis, 2022.
-- License: BSD 3-Clause
--
require("silex.types") -- Compatibility shims

local qrencode = require("qrencode")
local base = require("packages.base")

Expand Down Expand Up @@ -32,24 +34,24 @@ function package:registerCommands ()
if options.width then
width = SU.cast("measurement", options.width)
X = width / (#tab_or_message + 2 * safeZone)
if X < SILE.measurement("0.5mm") then
if X < SILE.types.measurement("0.5mm") then
SU.warn("QR code width is too small (minimum recommended module of 0.5mm is not satisfied)")
end
if options.module then
SU.warn("QR code width takes precedence of module option (ignored)")
end
else
X = SU.cast("measurement", options.module or "0.5mm")
if X < SILE.measurement("0.5mm") then
if X < SILE.types.measurement("0.5mm") then
SU.warn("QR code width is too small (minimum recommended module of 0.5mm is not satisfied)")
end
width = X * (#tab_or_message + 8)
end

SILE.typesetter:pushHbox({
width = SILE.length(width),
height = SILE.length(width - safeZone * X),
depth = SILE.length(safeZone * X),
width = SILE.types.length(width),
height = SILE.types.length(width - safeZone * X),
depth = SILE.types.length(safeZone * X),
outputYourself = function(node, typesetter, line)
local X0 = typesetter.frame.state.cursorX
local Y0 = typesetter.frame.state.cursorY
Expand Down
File renamed without changes.
26 changes: 26 additions & 0 deletions rockspecs/qrcode.sile-1.1.0-1.rockspec
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
rockspec_format = "3.0"
package = "qrcode.sile"
version = "1.1.0-1"
source = {
url = "git+https://github.com/Omikhleia/qrcode.sile.git",
tag = "v1.1.0",
}
description = {
summary = "QR code package for the SILE typesetting system.",
detailed = [[
This package for the SILE typesetter allows printing out a QR code.
]],
homepage = "https://github.com/Omikhleia/qrcode.sile",
license = "BSD 3-clause",
}
dependencies = {
"lua >= 5.1",
"silex.sile >= 0.6.0, < 1.0",
}
build = {
type = "builtin",
modules = {
["sile.packages.qrcode"] = "packages/qrcode/init.lua",
["sile.qrencode"] = "lua-libraries/qrencode.lua",
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ description = {
}
dependencies = {
"lua >= 5.1",
"silex.sile",
}
build = {
type = "builtin",
Expand Down

0 comments on commit 32a34c0

Please sign in to comment.