From: Hironori Kitagawa Date: Sun, 22 Jul 2018 08:17:47 +0000 (+0900) Subject: test27-lineprofile.tex: 行間計算方法のテスト X-Git-Tag: 20180825.0~41 X-Git-Url: http://git.osdn.jp/view?a=commitdiff_plain;h=9e0a70071d6e9a10891c483cf4f7a48d0f7b5e3f;p=luatex-ja%2Fluatexja.git 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)