summaryrefslogtreecommitdiff
path: root/luaotfload.dtx
diff options
context:
space:
mode:
authorKhaled Hosny <khaledhosny@eglug.org>2009-12-31 19:54:23 +0200
committerKhaled Hosny <khaledhosny@eglug.org>2009-12-31 21:33:43 +0200
commit1e73c17385ffdf341b803a2a8edb8c801c3db2e4 (patch)
treed4be77c9740146975ea1bc7d9777f446dbd03860 /luaotfload.dtx
parent21f69a1cb547fc10a4927171de7dddaec5c09b35 (diff)
downloadluaotfload-1e73c17385ffdf341b803a2a8edb8c801c3db2e4.tar.gz
Cosmetic
Diffstat (limited to 'luaotfload.dtx')
-rw-r--r--luaotfload.dtx24
1 files changed, 13 insertions, 11 deletions
diff --git a/luaotfload.dtx b/luaotfload.dtx
index feeeb49..fd6a8b1 100644
--- a/luaotfload.dtx
+++ b/luaotfload.dtx
@@ -668,19 +668,21 @@ local res1 = tex.pdfpageresources
local res2 = '/TransGs1<</ca 1/CA 1>>'
local function hex2dec(hex)
- return tonumber(hex, 16)/255
+ return format("%.3g", tonumber(hex, 16)/255)
end
local function hex_to_rgba(hex)
local r, g, b, a, push, pop, res3
- if hex and #hex == 6 then
- _, _, r, g, b = hex:find('(..)(..)(..)')
- elseif #hex == 8 then
- _, _, r, g, b, a = hex:find('(..)(..)(..)(..)')
- a = format('%1.g', hex2dec(a))
- res3 = format('/TransGs%g<</ca %g/CA %g>>', a, a, a)
- res2 = format('%s%s', res2, res2:find(res3) and "" or res3)
- tex.pdfpageresources = format('%s/ExtGState<<%s>>', res1, res2)
+ if hex then
+ if #hex == 6 then
+ _, _, r, g, b = hex:find('(..)(..)(..)')
+ elseif #hex == 8 then
+ _, _, r, g, b, a = hex:find('(..)(..)(..)(..)')
+ a = hex2dec(a)
+ res3 = format('/TransGs%g<</ca %g/CA %g>>', a, a, a)
+ res2 = format('%s%s', res2, res2:find(res3) and "" or res3)
+ tex.pdfpageresources = format('%s/ExtGState<<%s>>', res1, res2)
+ end
else
return nil
end
@@ -688,10 +690,10 @@ local function hex_to_rgba(hex)
g = hex2dec(g)
b = hex2dec(b)
if a then
- push = format('/TransGs%g gs %.3g %.3g %.3g rg', a, r, g, b)
+ push = format('/TransGs%g gs %s %s %s rg', a, r, g, b)
pop = '0 g /TransGs1 gs'
else
- push = format('%.3g %.3g %.3g rg', r, g, b)
+ push = format('%s %s %s rg', r, g, b)
pop = '0 g'
end
return push, pop