I am running MiKTeX 2.9 in windows 10 x64.
After making an fresh basic install with basic-miktex-2.9.6942-x64.exe (to keep the old) I run into a problem with a lualatex program. (correction of sidebearings sidebearings and precision left/right alignment)
- With the new 2019 basic installation I get an error message
warning (node filter): error: [\directlua]:11: attempt to perform arithmetic on field 'xadvance' (a nil value)
and crash.
The program runs fine switching back to the previous 2018 environment.
I found that if I only exchange the entire directory C:\Program Files\MiKTeX 2.9\miktex with the old one (2018), while keeping everything else, the program now works.
In the new installation the exe files are dated 02-Jan-19 In the old one the exe files are dated 26-Jun-18 and 24-Jun-18
Any help?
Main lualatex code
% !TeX TS-program = lualatex
\documentclass[12pt]{article}
\RequirePackage{xcolor}
\usepackage{luacode}
\newcount\dropsidebearings
\input{drop_sidebearing.lua}
\newcommand{\hairlineiv}[1][green]{%
\leavevmode%
\kern-0.1pt %
\smash{\color{#1}\vrule height 5\baselineskip depth 5pt width 0.1pt}%
\kern-0.1pt
}
\begin{document}
\pagestyle{empty}
\newcommand{\longtitles}{Long titles must be exactly aligned with the vertical green bar.}% the main title
\begin{minipage}{5in}
\dropsidebearings=1 %turn on the effect
% \longtitles
\raggedleft\sffamily\fontsize{50}{60}\selectfont\bfseries \longtitles\hairlineiv
\end{minipage}
\end{document}
luatex code (file: drop_sidebearing.lua)
\begin{luacode*}
local function drop_sidebearing(head, groupcode)
if tex.count['dropsidebearings'] == 0 then
return true
end
for n in node.traverse_id(node.id'hlist', head) do
local char = node.has_glyph(n.head)
if char then
local f = font.getfont(char.font)
if f.shared then
local off = f.shared.rawdata.descriptions[char.char].boundingbox[1]*f.size/1000
char.xadvance = char.xadvance - off
char.xoffset = char.xoffset - off
end
end
for ch in node.traverse_id(node.id'glyph', n.head) do
char = ch
end
if char then
local f = font.getfont(char.font)
if f.shared then
local desc = f.shared.rawdata.descriptions[char.char]
char.xadvance = char.xadvance - (desc.width-desc.boundingbox[3])*f.size/1000
end
end
local new_list = node.hpack(n.head, n.width, 'exactly')
new_list.head = nil
n.glue_order = new_list.glue_order
n.glue_set = new_list.glue_set
n.glue_sign = new_list.glue_sign
node.free(new_list)
end
return true
end
luatexbase.add_to_callback('post_linebreak_filter', drop_sidebearing, 'Drop sidebearings after linebreaking')
\end{luacode*}
xadvancewas removed in LuaTeX 1.08.0 and as far as I can see it was never documented. – Henri Menke Jan 10 '19 at 20:57