luatex 节点库:用包含字形的 hlist 替换字形

luatex 节点库:用包含字形的 hlist 替换字形

在尝试用包含字形的 hlist 替换字形节点时,我原本希望看到相同的输出,但我看到框重叠,并收到警告pdf backend。以下是警告消息、屏幕截图和完整代码:

warning  (pdf backend): forcing bad dir -1 to TLT in synch_pos_with_cur

warning  (pdf backend): ignoring bad dir -1 when outputting a character
.
.
.

截屏: 列表重叠

完整代码:

\documentclass[notitlepage,letterpaper]{article}
\usepackage[letterpaper,left=2in,right=2in,top=1in,bottom=1in]{geometry}
\usepackage{blindtext}

\directlua{
    function my_post_lb_filter(head,groupcode)
      local linenumber=1;
      local HLIST = node.id("hlist")
      local GLYPH = node.id("glyph")
      for n in node.traverse(head) do
        if n.id==HLIST then
          if linenumber==3 then
            for g in node.traverse(n.head) do
              if g.id == GLYPH then
                print("character: " .. string.utfcharacter(g.char))
                local gc = node.copy(g);
                local hbox = node.new(HLIST);
                hbox.head = node.insert_after(hbox.list,hbox.head,gc)
                n.head = node.insert_after(n.list,g,hbox)
                n.head = node.remove(n.head,g)
              end
            end
          end
        linenumber=linenumber+1;
        end
      end
      return head
    end
  luatexbase.add_to_callback('post_linebreak_filter', my_post_lb_filter, 'Play with luatex node library')
}

\begin{document}
  \blindtext[1]
\end{document}

相关内容