From 1e73c17385ffdf341b803a2a8edb8c801c3db2e4 Mon Sep 17 00:00:00 2001 From: Khaled Hosny Date: Thu, 31 Dec 2009 19:54:23 +0200 Subject: Cosmetic --- luaotfload.dtx | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) (limited to 'luaotfload.dtx') 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<>' 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<>', 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<>', 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 -- cgit v1.2.3