From 9e0a70071d6e9a10891c483cf4f7a48d0f7b5e3f Mon Sep 17 00:00:00 2001 From: Hironori Kitagawa Date: Sun, 22 Jul 2018 17:17:47 +0900 Subject: [PATCH] =?utf8?q?test27-lineprofile.tex:=20=E8=A1=8C=E9=96=93?= =?utf8?q?=E8=A8=88=E7=AE=97=E6=96=B9=E6=B3=95=E3=81=AE=E3=83=86=E3=82=B9?= =?utf8?q?=E3=83=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- test/test27-lineprofile.tex | 150 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 150 insertions(+) create mode 100644 test/test27-lineprofile.tex diff --git a/test/test27-lineprofile.tex b/test/test27-lineprofile.tex new file mode 100644 index 0000000..471a6bb --- /dev/null +++ b/test/test27-lineprofile.tex @@ -0,0 +1,150 @@ +\documentclass[10ptj]{ltjsarticle} +\usepackage[width=40\zw, lines=40,centering]{geometry} +\usepackage{amsmath,luacode,xcolor} +\begin{luacode} + lineskip = {} +do + local insert = table.insert + local rangedimensions, max = node.rangedimensions, math.max + function lineskip.p_profile(before, after) + local t = {} + do + local w_acc, d_before = 0, 0 + local x = before.head; local xn = x.next + while x do + local w, d + if xn then w, _, d= rangedimensions(before,x,xn) + else w, _, d= rangedimensions(before,x) end + if d~=d_before then + d_before = d; t[w_acc] = t[w_acc] or {} + if t[w_acc][1] then t[w_acc][1]=max(t[w_acc][1],d) + else t[w_acc][1]=d end + end + w_acc = w_acc + w + x = xn; if x then xn = x.next end + end + end + do + local w_acc, h_before = 0, 0 + local x = after.head; local xn = x.next + while x do + local w, h + if xn then w, h = rangedimensions(after,x,xn) + else w, h = rangedimensions(after,x) end + if h~=h_before then + h_before = h; t[w_acc] = t[w_acc] or {} + if t[w_acc][2] then t[w_acc][2]=max(t[w_acc][2],h) + else t[w_acc][2]=h end + end + w_acc = w_acc + w + x = xn; if x then xn = x.next end + end + end + local t2 = {} + for i,v in pairs(t) do insert(t2, { i, v[1], v[2] } ) end + table.sort(t2, function(a,b) return a[1]dmax then dmax=d end + if h>hmax then hmax=h end + if (bls-h-d)