LuaTeX 中何時黏合節點的類型為「xspaceskip」?

LuaTeX 中何時黏合節點的類型為「xspaceskip」?

我正在使用 TeX Live 2017,並且目前 luatex 膠水節點文檔表示subtype黏合節點的欄位有以下可能值:

0 = 使用者跳過、1 = 行跳過、2 = 基線跳過、3 = 部分跳過、4 = 上方顯示跳過、5 = 下方顯示跳過、6 = 上方顯示短跳、7 = 下方顯示短跳、8 = 左跳、9 = 右跳、10 = 頂跳、11 = 分割頂跳、12 = tabskip、13=spaceskip、14=xspaceskip、15=parfillskip、16=mathskip、17=thinmuskip、18=medmuskip 、19=thickmuskip、98=conditionalmathskip、99=muglue、100=領導者、101=cleaders、102=xleaders、 103 = 滑冰者

我試圖了解 LuaTeX 並編寫了以下簡單的程式碼來輸出有關每個段落的一些資訊性輸出:

\documentclass{article}
\directlua{dofile("parinfo.lua")}
\begin{document}

Word1, word2 office. Word3. End.
\end{document}

哪裡parinfo.lua

function traverse_paragraph(head)
   while head do
      print(string.format('In paragraph: %s %s', node.type(head.id), debugstr_node(head)))
      head = head.next
   end
  return true
end
luatexbase.add_to_callback('pre_linebreak_filter', traverse_paragraph, 'Info for debugging')

function debugstr_node(n)
   if node.type(n.id) == "glue" then
      return debugstr_glue(n)
   elseif node.type(n.id) == "glyph" then
      return n.char < 128 and string.char(n.char) or string.format('[char %s]', n.char)
   elseif node.type(n.id) == "kern" then
      return string.format('%s', n.kern)
   elseif node.type(n.id) == "penalty" then
      return string.format('%s', n.penalty)
   else
      return ''
   end
end

function debugstr_glue(n)
   if n.subtype == 13 then
      subtype = 'spaceskip'
   elseif n.subtype == 14 then
      subtype = 'xspaceskip'
   elseif n.subtype == 15 then
      subtype = 'parfillskip'
   else
      subtype = '' .. n.subtype
   end
   return string.format('<%s: %s plus %s(%s) minus %s(%s)', subtype, n.width, n.stretch, n.stretch_order, n.shrink, n.shrink_order)
end

因此,當.tex使用 編譯檔案時lualatex,我們會得到以下輸出:

In paragraph: local_par 
In paragraph: hlist 
In paragraph: glyph W
In paragraph: kern -54395
In paragraph: glyph o
In paragraph: glyph r
In paragraph: glyph d
In paragraph: glyph 1
In paragraph: glyph ,
In paragraph: glue <spaceskip: 218235 plus 136396(0) minus 58196(0)
In paragraph: glyph w
In paragraph: kern -18350
In paragraph: glyph o
In paragraph: glyph r
In paragraph: glyph d
In paragraph: glyph 2
In paragraph: glue <spaceskip: 218235 plus 109117(0) minus 72745(0)
In paragraph: glyph o
In paragraph: glyph [char 64259]
In paragraph: glyph c
In paragraph: glyph e
In paragraph: glyph .
In paragraph: glue <spaceskip: 290980 plus 327351(0) minus 24248(0)
In paragraph: glyph W
In paragraph: kern -54395
In paragraph: glyph o
In paragraph: glyph r
In paragraph: glyph d
In paragraph: glyph 3
In paragraph: glyph .
In paragraph: glue <spaceskip: 290980 plus 327351(0) minus 24248(0)
In paragraph: glyph E
In paragraph: glyph n
In paragraph: glyph d
In paragraph: glyph .
In paragraph: penalty 10000
In paragraph: glue <parfillskip: 0 plus 65536(2) minus 0(0)

請注意,逗號後面的黏合(具有較大的拉伸)和後面的黏合.(具有較大的寬度和較大的拉伸)仍然顯示為具有子類型spaceskip,而不是xspaceskip。 (正如預期的那樣,段落末尾的膠水俱有 subtype parfillskip。)

這是預期的嗎?我們什麼時候才能看到膠水有字呢xspaceskip\nonfrenchspacing除了追蹤最近看到的詞間黏合並比較差異之外,在 pre_linebreak 過濾器中是否還有其他方法可以檢測標點符號或句末(帶有 )後面的較大黏合?

即使對於非 LuaTeX,我也不完全理解這些的工作原理,所以我可能只是感到困惑:-) 萬一它很重要,luatex --version

這是 LuaTeX,版本 1.0.4 (TeX Live 2017)

答案1

當你設定\xspaceskip

\documentclass{article}
\directlua{dofile("parinfo.lua")}
\setlength\xspaceskip{10pt}
\begin{document}

Word1, word2 office. Word3. End.
\end{document}

In paragraph: glyph 3
In paragraph: glyph .
In paragraph: glue <xspaceskip: 655360 plus 0(0) minus 0(0)
In paragraph: glyph E

相關內容