From 5a796db333b1e93342a0be8c69b026cd6c2c1df6 Mon Sep 17 00:00:00 2001 From: Omikhleia Date: Thu, 1 Aug 2024 19:45:12 +0200 Subject: [PATCH] refactor: Compatibility upgrade with SILE 0.15 --- packages/barcodes/ean13/init.lua | 26 ++++++++------- .../barcodes.sile-1.0.0-1.rockspec | 0 .../barcodes.sile-1.1.0-1.rockspec | 0 rockspecs/barcodes.sile-1.2.0-1.rockspec | 32 +++++++++++++++++++ .../barcodes.sile-dev-1.rockspec | 1 + 5 files changed, 47 insertions(+), 12 deletions(-) rename barcodes.sile-1.0.0-1.rockspec => rockspecs/barcodes.sile-1.0.0-1.rockspec (100%) rename barcodes.sile-1.1.0-1.rockspec => rockspecs/barcodes.sile-1.1.0-1.rockspec (100%) create mode 100644 rockspecs/barcodes.sile-1.2.0-1.rockspec rename barcodes.sile-dev-1.rockspec => rockspecs/barcodes.sile-dev-1.rockspec (98%) diff --git a/packages/barcodes/ean13/init.lua b/packages/barcodes/ean13/init.lua index d6762e6..9abe1a8 100644 --- a/packages/barcodes/ean13/init.lua +++ b/packages/barcodes/ean13/init.lua @@ -4,6 +4,8 @@ -- 2022-2024 Omikhleia / Didier Willis -- License: MIT -- +require("silex.types") -- Compatibility shims + local base = require("packages.base") local package = pl.class(base) @@ -209,9 +211,9 @@ function package:registerCommands () local module = SC[scale] if not module then SU.error("Invalid EAN scale (SC0 to SC9): "..scale) end - local X = SILE.length(module.."mm") + local X = SILE.types.length(module.."mm") local H = 69.242424242 -- As per the standard, a minimal 22.85mm at standard X - local offsetcorr = corr and SILE.length("0.020mm") or SILE.length() + local offsetcorr = corr and SILE.types.length("0.020mm") or SILE.types.length() local pattern = ean13(code) @@ -249,14 +251,14 @@ function package:registerCommands () SILE.call("kern", { width = -106 * X }) -- First digit, at the start of the Left Quiet Zone local h = hbox({ code:sub(1,1) }) - h.width = SILE.length() + h.width = SILE.types.length() -- First 6-digit sequence is at 11X LQZ + 3X guard = 14X -- We add a 0.5X displacement from the normal guard (a bar) -- while the central bar starts with a space). SILE.call("kern", { width = 14.5 * X }) SILE.call("kern", { width = deltaFontWidth * X }) h = hbox({ code:sub(2,7) }) -- first sequence - h.width = SILE.length() + h.width = SILE.types.length() -- Second 6-digit sequence is further at 6*7X digits + 5X guard = 47X -- to which we remove the previous 0.5X displacement. -- Substract an additional 0.5X displacement from the central guard @@ -264,15 +266,15 @@ function package:registerCommands () -- hence 46X... SILE.call("kern", { width = 46 * X }) h = hbox({ code:sub(8,13) }) -- last sequence - h.width = SILE.length() + h.width = SILE.types.length() SILE.call("kern", { width = -deltaFontWidth * X }) -- End marker is at 6*7X + 3X guard + 7X RQZ = 52X -- Corrected by the above displacement, hence 52.5X - local l = SILE.length((52.5 - SILE.scratch.ean13.computed.width) * X) + local l = SILE.types.length((52.5 - SILE.scratch.ean13.computed.width) * X) SILE.call("kern", { width = l }) if not addon then h = hbox({ ">" }) -- closing bracket, aligned to the end of the Right Quiet Zone - h.width = SILE.length() + h.width = SILE.types.length() end SILE.call("kern", { width = (SILE.scratch.ean13.computed.width - 7) * X }) end) @@ -305,9 +307,9 @@ function package:registerCommands () local module = SC[scale] if not module then SU.error("Invalid EAN scale (SC0 to SC9): "..scale) end - local X = SILE.length(module.."mm") + local X = SILE.types.length(module.."mm") local H = 66.363636364 -- As per the standard, a minimal 21.90mm at standard X - local offsetcorr = corr and SILE.length("0.020mm") or SILE.length() + local offsetcorr = corr and SILE.types.length("0.020mm") or SILE.types.length() local pattern if #code == 5 then @@ -347,13 +349,13 @@ function package:registerCommands () SILE.call("kern", { width = -9 * #code * X }) for i = 1, #code do local h = hbox({ code:sub(i,i) }) -- Distribute the digits - h.width = SILE.length() + h.width = SILE.types.length() SILE.call("kern", { width = 9 * X }) end - local l = SILE.length((5 - SILE.scratch.ean13.computed.width) * X) + local l = SILE.types.length((5 - SILE.scratch.ean13.computed.width) * X) SILE.call("kern", { width = l }) local h = hbox({ ">" }) -- closing bracket, aligned to the end of the Add-on Right Quiet Zone - h.width = SILE.length() + h.width = SILE.types.length() SILE.call("kern", { width = (SILE.scratch.ean13.computed.width - 5) * X }) end) end) diff --git a/barcodes.sile-1.0.0-1.rockspec b/rockspecs/barcodes.sile-1.0.0-1.rockspec similarity index 100% rename from barcodes.sile-1.0.0-1.rockspec rename to rockspecs/barcodes.sile-1.0.0-1.rockspec diff --git a/barcodes.sile-1.1.0-1.rockspec b/rockspecs/barcodes.sile-1.1.0-1.rockspec similarity index 100% rename from barcodes.sile-1.1.0-1.rockspec rename to rockspecs/barcodes.sile-1.1.0-1.rockspec diff --git a/rockspecs/barcodes.sile-1.2.0-1.rockspec b/rockspecs/barcodes.sile-1.2.0-1.rockspec new file mode 100644 index 0000000..1fbd649 --- /dev/null +++ b/rockspecs/barcodes.sile-1.2.0-1.rockspec @@ -0,0 +1,32 @@ +rockspec_format = "3.0" +package = "barcodes.sile" +version = "1.2.0-1" +source = { + url = "git+https://github.com/Omikhleia/barcodes.sile.git", + tag = "v1.2.0", +} +description = { + summary = "Barcodes package for the SILE typesetting system.", + detailed = [[ + This package for the SILE typesetter allows printing out an EAN-13 barcode + suitable for an ISBN (or ISSN, etc.) + ]], + homepage = "https://github.com/Omikhleia/barcodes.sile", + license = "MIT", +} +dependencies = { + "lua >= 5.1", + "silex.sile >= 0.6.0, < 1.0", +} +build = { + type = "builtin", + modules = { + ["sile.packages.barcodes"] = "packages/barcodes/init.lua", + ["sile.packages.barcodes.ean13"] = "packages/barcodes/ean13/init.lua", + }, + install = { + lua = { + ["sile.packages.barcodes.ean13.fonts.OCRB"] = "packages/barcodes/ean13/fonts/OCRB.otf", + } + } +} diff --git a/barcodes.sile-dev-1.rockspec b/rockspecs/barcodes.sile-dev-1.rockspec similarity index 98% rename from barcodes.sile-dev-1.rockspec rename to rockspecs/barcodes.sile-dev-1.rockspec index 954c81c..9794834 100644 --- a/barcodes.sile-dev-1.rockspec +++ b/rockspecs/barcodes.sile-dev-1.rockspec @@ -14,6 +14,7 @@ description = { } dependencies = { "lua >= 5.1", + "silex.sile", } build = { type = "builtin",