summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/luatex
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2012-03-09 01:33:08 +0000
committerKarl Berry <karl@freefriends.org>2012-03-09 01:33:08 +0000
commitebd5de2be2cfa581ccf2318a23b14362f3bcb006 (patch)
treeecfbae16c7c5745b5932f2e8b18f0271c4a89824 /Master/texmf-dist/tex/luatex
parent1a1835b1fbe4ffb735d55bac3f95554e32c8e2f5 (diff)
lua-visual-debug (8mar12)
git-svn-id: svn://tug.org/texlive/trunk@25586 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/luatex')
-rw-r--r--Master/texmf-dist/tex/luatex/lua-visual-debug/lua-visual-debug.lua42
-rw-r--r--Master/texmf-dist/tex/luatex/lua-visual-debug/lua-visual-debug.sty6
2 files changed, 32 insertions, 16 deletions
diff --git a/Master/texmf-dist/tex/luatex/lua-visual-debug/lua-visual-debug.lua b/Master/texmf-dist/tex/luatex/lua-visual-debug/lua-visual-debug.lua
index e4aae142737..af2f02c93e1 100644
--- a/Master/texmf-dist/tex/luatex/lua-visual-debug/lua-visual-debug.lua
+++ b/Master/texmf-dist/tex/luatex/lua-visual-debug/lua-visual-debug.lua
@@ -51,6 +51,14 @@ local number_sp_in_a_pdf_point = 65782
-- -- the pointer is "nil" if there is no next item
-- end
+function math.round(num, idp)
+ if idp and idp>0 then
+ local mult = 10^idp
+ return math.floor(num * mult + 0.5) / mult
+ end
+ return math.floor(num + 0.5)
+end
+
function show_page_elements(parent)
local head = parent.list
@@ -58,9 +66,9 @@ function show_page_elements(parent)
if head.id == 0 or head.id == 1 then -- hbox / vbox
local rule_width = 0.1
- local wd = head.width / number_sp_in_a_pdf_point - rule_width
- local ht = (head.height + head.depth) / number_sp_in_a_pdf_point - rule_width
- local dp = head.depth / number_sp_in_a_pdf_point - rule_width / 2
+ local wd = math.round(head.width / number_sp_in_a_pdf_point - rule_width ,2)
+ local ht = math.round((head.height + head.depth) / number_sp_in_a_pdf_point - rule_width ,2)
+ local dp = math.round(head.depth / number_sp_in_a_pdf_point - rule_width / 2 ,2)
-- recurse into the contents of the box
show_page_elements(head)
@@ -74,11 +82,15 @@ function show_page_elements(parent)
elseif head.id == 2 then -- rule
- if head.width == 0 then head.width = 0.4 * 2^16 end
- local goback = node.new("kern")
- goback.kern = -head.width
- node.insert_after(parent.list,head,goback)
- head = goback
+ local show_rule = node.new("whatsit","pdf_literal")
+ if head.width == -1073741824 or head.height == -1073741824 or head.depth == -1073741824 then
+ -- ignore for now -- these rules are stretchable
+ else
+ local dp = math.round( head.depth / number_sp_in_a_pdf_point ,2)
+ local ht = math.round( head.height / number_sp_in_a_pdf_point ,2)
+ show_rule.data = string.format("q 1 0 0 RG 1 0 0 rg 0.4 w 0 %g m 0 %g l S Q",-dp,ht)
+ end
+ parent.list = node.insert_before(parent.list,head,show_rule)
elseif head.id == 7 then -- disc
@@ -87,7 +99,7 @@ function show_page_elements(parent)
parent.list = node.insert_before(parent.list,head,hyphen_marker)
- elseif head.id == 10 then -- glue
+ elseif head.id == 10 then -- glue
local wd = head.spec.width
local color = "0.5 G"
if parent.glue_sign == 1 and parent.glue_order == head.spec.stretch_order then
@@ -98,10 +110,11 @@ function show_page_elements(parent)
color = "1 0 1 RG"
end
local pdfstring = node.new("whatsit","pdf_literal")
+ local wd_bp = math.round(wd / number_sp_in_a_pdf_point,2)
if parent.id == 0 then --hlist
- pdfstring.data = string.format("q %s [0.2] 0 d 0.5 w 0 0 m %g 0 l s Q",color,wd / number_sp_in_a_pdf_point)
+ pdfstring.data = string.format("q %s [0.2] 0 d 0.5 w 0 0 m %g 0 l s Q",color,wd_bp)
else -- vlist
- pdfstring.data = string.format("q 0.1 G 0.1 w -0.5 0 m 0.5 0 l -0.5 %g m 0.5 %g l s [0.2] 0 d 0.5 w 0.25 0 m 0.25 %g l s Q",-wd / number_sp_in_a_pdf_point,-wd / number_sp_in_a_pdf_point,-wd / number_sp_in_a_pdf_point)
+ pdfstring.data = string.format("q 0.1 G 0.1 w -0.5 0 m 0.5 0 l -0.5 %g m 0.5 %g l s [0.2] 0 d 0.5 w 0.25 0 m 0.25 %g l s Q",-wd_bp,-wd_bp,-wd_bp)
end
parent.list = node.insert_before(parent.list,head,pdfstring)
@@ -110,13 +123,15 @@ function show_page_elements(parent)
local rectangle = node.new("whatsit","pdf_literal")
local color = "1 1 0 rg"
if head.kern < 0 then color = "1 0 0 rg" end
+ local k = math.round(head.kern / number_sp_in_a_pdf_point,2)
if parent.id == 0 then --hlist
- rectangle.data = string.format("q %s 0 w 0 0 %g 1 re B Q",color, head.kern / number_sp_in_a_pdf_point )
+ rectangle.data = string.format("q %s 0 w 0 0 %g 1 re B Q",color, k )
else
- rectangle.data = string.format("q %s 0 w 0 0 1 %g re B Q",color, -head.kern / number_sp_in_a_pdf_point )
+ rectangle.data = string.format("q %s 0 w 0 0 1 %g re B Q",color, -k )
end
parent.list = node.insert_before(parent.list,head,rectangle)
+
elseif head.id == 12 then -- penalty
local color = "1 g"
local rectangle = node.new("whatsit","pdf_literal")
@@ -128,5 +143,6 @@ function show_page_elements(parent)
end
head = head.next
end
+ return true
end
diff --git a/Master/texmf-dist/tex/luatex/lua-visual-debug/lua-visual-debug.sty b/Master/texmf-dist/tex/luatex/lua-visual-debug/lua-visual-debug.sty
index 72839e48d93..7479e0fc6b9 100644
--- a/Master/texmf-dist/tex/luatex/lua-visual-debug/lua-visual-debug.sty
+++ b/Master/texmf-dist/tex/luatex/lua-visual-debug/lua-visual-debug.sty
@@ -1,11 +1,11 @@
-% Version: 0.2
+% Version: 0.3
% see lua file for copyright information (MIT License)
\expandafter\ifx\csname ProvidesPackage\endcsname\relax
\input ifluatex.sty\relax
\else
\NeedsTeXFormat{LaTeX2e}
- \ProvidesPackage{lua-visual-debug}[2012/02/24 v0.2 Visual debugging in LuaLaTeX (PGU)]
+ \ProvidesPackage{lua-visual-debug}[2012/02/24 v0.3 Visual debugging in LuaLaTeX (PGU)]
\RequirePackage{ifluatex}
\fi
@@ -24,7 +24,7 @@
\fi
\else
\ifluatex
- \RequirePackage{luatexbase,atbegshi}
+ \RequirePackage{atbegshi}
\dothings
\else
\PackageWarning{lua-visual-debug}{You are using this package without LuaTeX. This is not supported, so you don't get any visual debugging.}