[latex3-commits] [git/LaTeX3-latex3-luaotfload] harf-dev: Small stuff (05e14aa)
Marcel Fabian Krüger
tex at 2krueger.de
Tue Sep 17 13:55:03 CEST 2019
Repository : https://github.com/latex3/luaotfload
On branch : harf-dev
Link : https://github.com/latex3/luaotfload/commit/05e14aa2e6140ee0190cd7de10e0405234b953ec
>---------------------------------------------------------------
commit 05e14aa2e6140ee0190cd7de10e0405234b953ec
Author: Marcel Fabian Krüger <tex at 2krueger.de>
Date: Mon Sep 16 23:35:56 2019 +0200
Small stuff
>---------------------------------------------------------------
05e14aa2e6140ee0190cd7de10e0405234b953ec
src/harf/harf-node.lua | 31 ++++++++++++++-----------------
1 file changed, 14 insertions(+), 17 deletions(-)
diff --git a/src/harf/harf-node.lua b/src/harf/harf-node.lua
index bc72775..1ca16ef 100644
--- a/src/harf/harf-node.lua
+++ b/src/harf/harf-node.lua
@@ -166,25 +166,24 @@ local function itemize(head, direction)
local currdir = direction or "TLT"
local currfontid = nil
- for n in direct.traverse(head) do
- local id = getid(n)
+ for n, id, subtype in direct.traverse(head) do
local code = 0xFFFC -- OBJECT REPLACEMENT CHARACTER
local script = sc_common
local skip = false
if id == glyphid then
currfontid = getfont(n)
- if getsubtype(n) > 255 then
+ if subtype > 255 then
skip = true
else
code = getchar(n)
script = getscript(code)
end
- elseif id == glueid and getsubtype(n) == spaceskip then
+ elseif id == glueid and subtype == spaceskip then
code = 0x0020 -- SPACE
elseif id == discid
- and (getsubtype(n) == explicitdisc -- \-
- or getsubtype(n) == regulardisc) -- \discretionary
+ and (subtype == explicitdisc -- \-
+ or subtype == regulardisc) -- \discretionary
then
code = 0x00AD -- SOFT HYPHEN
elseif id == dirid then
@@ -790,17 +789,15 @@ local function validate_color(s)
return s
end
-local function hex_to_rgba(s)
- if not validate_color(s) then return end
- local r = tonumber(s:sub(1, 2), 16) / 255
- local g = tonumber(s:sub(3, 4), 16) / 255
- local b = tonumber(s:sub(5, 6), 16) / 255
- if #s == 8 then
- local a = tonumber(s:sub(7, 8), 16) / 255
- -- XXX: alpha
- return format('%s %s %s rg', r, g, b)
- else
- return format('%s %s %s rg', r, g, b)
+local hex_to_rgba do
+ local hex = lpeg.R'09' + lpeg.R'AF' + lpeg.R'af'
+ local twohex = hex * hex / function(s) return tonumber(s, 16) / 255 end
+ local color_expr = twohex * twohex * twohex * twohex^-1 * -1
+ function hex_to_rgba(s)
+ local r, g, b, a = color_expr:match(s)
+ if r then
+ return format('%s %s %s rg', r, g, b)
+ end
end
end
More information about the latex3-commits
mailing list