OSDN Git Service

added \ltjghostjachar
authorHironori Kitagawa <h_kitagawa2001@yahoo.co.jp>
Mon, 7 Feb 2022 01:40:47 +0000 (10:40 +0900)
committerHironori Kitagawa <h_kitagawa2001@yahoo.co.jp>
Mon, 7 Feb 2022 01:40:47 +0000 (10:40 +0900)
src/addons/luatexja-adjust.sty
src/ltj-adjust.lua
test/test17-priority.pdf
test/test17-priority.tex

index d325df7..5d37eb6 100644 (file)
@@ -64,7 +64,7 @@
   \expandafter\let\csname ifltj@in@latex\expandafter\endcsname
     \csname iftrue\endcsname
   \NeedsTeXFormat{LaTeX2e}
-  \ProvidesPackage{luatexja-adjust}[2022-01-03]
+  \ProvidesPackage{luatexja-adjust}[2022-02-07]
 \fi                             %</LaTeX>
 
 % Load core module if not yet.
 \define@key[ltj]{japaram}{profile_hgap_factor}{%
   \directlua{luatexja.adjust.profile_hgap_factor = math.abs(#1)}\relax}
 
+\newluafunction\ltj@@ghost@jachar@inner
+\typeout{\the\ltj@@ghost@jachar@inner.}
+\directlua{
+  local t = lua.get_functions_table(); local cgj = luatexja.adjust.create_ghost_jachar_node;
+  t[\the\ltj@@ghost@jachar@inner] = function() cgj(0) end
+}%
+\protected\def\ltjghostjachar{\ifhmode\relax\luafunction\ltj@@ghost@jachar@inner\fi}
+
 
 %%------------------ all done
 \ltj@adjust@AtEnd
index 76a1a68..87c85dd 100644 (file)
@@ -551,4 +551,40 @@ do
   end
 end
 
-
+do
+  local ltja = luatexja.adjust
+  local sid_user = node.subtype 'user_defined'
+  local node_remove = node.direct.remove
+  local node_write = node.direct.write
+  local GHOST_JACHAR = luatexbase.newuserwhatsitid('ghost of a jachar',  'luatexja')
+  luatexja.userid_table.GHOST_JACHAR = GHOST_JACHAR
+  function ltja.create_ghost_jachar_node(cl)
+    local tn = node_new(id_whatsit, sid_user)
+    setfield(tn, 'user_id', GHOST_JACHAR)
+    setfield(tn, 'type', 100)
+    setfield(tn, 'value', cl)
+    node_write(tn)
+  end
+  local function whatsit_callback(Np, lp, Nq)
+    if Np and Np.nuc then return Np
+    elseif Np and getfield(lp, 'user_id') == GHOST_JACHAR then
+      Np.first = lp; Np.nuc = lp; Np.last = lp; Np.class = getfield(lp,'value')
+      if Nq then Np.met = Nq.met; Np.pre = 0; Np.post = 0; Np.xspc = 3 end
+      Np.auto_kspc, Np.auto_xspc = (has_attr(lp, attr_autospc)==1), (has_attr(lp, attr_autoxspc)==1)
+      return Np
+    else return Np end
+  end
+  local function whatsit_after_callback(s, Nq, Np, head)
+    if not s and getfield(Nq.nuc, 'user_id') == GHOST_JACHAR then
+      local x, y = node_prev(Nq.nuc), Nq.nuc
+      Nq.first, Nq.nuc, Nq.last = x, x, x
+      if Np then Nq.met = Np.met end
+      s = node_remove(head, y); node_free(y)
+    end
+    return s
+  end
+  luatexbase.add_to_callback("luatexja.jfmglue.whatsit_getinfo", whatsit_callback,
+                             "ghost of a JACHAR", 1)
+  luatexbase.add_to_callback("luatexja.jfmglue.whatsit_after", whatsit_after_callback,
+                             "ghost of a JACHAR", 1)
+end
index 70de446..bc92755 100644 (file)
Binary files a/test/test17-priority.pdf and b/test/test17-priority.pdf differ
index ce457b8..fdf837d 100644 (file)
@@ -2,6 +2,8 @@
 
 \documentclass{ltjsarticle}
 \usepackage{luatexja-fontspec,luatexja-adjust,xcolor,amsmath,amssymb}
+\DeclareKanjiFamily{JY3}{piyo}{}
+\DeclareFontShape{JY3}{piyo}{m}{n}{<-> s*[\Cjascale] file:ipaexg.ttf:jfm=jlreq}{}
 
 \def\sq{%
   \hbox to 1\zw{\hss\fboxsep=-.5\fboxrule\fbox{%
@@ -285,5 +287,28 @@ xkanjiskip手動挿入.
 
 
 
+\newpage
+
+\def\MYGUARDA#1{ \kern-\zw#1\kern-\zw  \ignorespaces}
+\def\MYGUARDB#1{{\kanjifamily{mc}\selectfont  }%
+        \kern-\zw#1\kern-\zw{\kanjifamily{mc}\selectfont  }\ignorespaces}
+\def\MYGUARDC#1{\ltjghostjachar#1\ltjghostjachar\ignorespaces}
+\def\MYVRULE{\raisebox{-2pt}{漢}}
+
+\paragraph{jfm: ujis}\ 
+
+\leavevmode\hbox to 15\zw{◆\MYVRULE ◆◆◆◆$f$◆}\par
+\leavevmode\hbox to 15\zw{◆\MYGUARDA{\MYVRULE}◆◆◆◆$f$◆} A\par
+\leavevmode\hbox to 15\zw{◆\MYGUARDB{\MYVRULE}◆◆◆◆$f$◆} B\par
+\leavevmode\hbox to 15\zw{◆\MYGUARDC{\MYVRULE}◆◆◆◆$f$◆} C\par
+\leavevmode\hbox to 15\zw{◆◇◆◆◆◆$f$◆} 比較用\par
+
+\paragraph{jfm: jlreq}\ 
 
+\kanjifamily{piyo}\selectfont
+\leavevmode\hbox to 15\zw{◆\MYVRULE ◆◆◆◆$f$◆}\par
+\leavevmode\hbox to 15\zw{◆\MYGUARDA{\MYVRULE}◆◆◆◆$f$◆} A\par
+\leavevmode\hbox to 15\zw{◆\MYGUARDB{\MYVRULE}◆◆◆◆$f$◆} B\par
+\leavevmode\hbox to 15\zw{◆\MYGUARDC{\MYVRULE}◆◆◆◆$f$◆} C\par
+\leavevmode\hbox to 15\zw{◆◇◆◆◆◆$f$◆} 比較用\par
 \end{document}