OSDN Git Service

Special treatment for pdf_{start,end}_{link,thread} whatsits.(ドキュメントまだ)
authorHironori Kitagawa <h_kitagawa2001@yahoo.co.jp>
Thu, 26 Apr 2012 14:29:57 +0000 (23:29 +0900)
committerHironori Kitagawa <h_kitagawa2001@yahoo.co.jp>
Thu, 26 Apr 2012 14:29:57 +0000 (23:29 +0900)
src/ltj-jfmglue.lua
test/test04a-jfm-hyper.pdf [new file with mode: 0644]
test/test04a-jfm-hyper.tex [new file with mode: 0644]

index 4d9c59a..041426e 100644 (file)
@@ -52,6 +52,11 @@ local id_pbox = node.id('hlist') + 512        -- already processed nodes (by \un
 local id_pbox_w = node.id('hlist') + 513      -- cluster which consists of a whatsit
 local sid_user = node.subtype('user_defined')
 
+local sid_start_link = node.subtype('pdf_start_link')
+local sid_start_thread = node.subtype('pdf_start_thread')
+local sid_end_link = node.subtype('pdf_end_link')
+local sid_end_thread = node.subtype('pdf_end_thread')
+
 local ITALIC = 1
 local PACKED = 2
 local KINSOKU = 3
@@ -273,7 +278,7 @@ end
 
 local function calc_np_pbox()
    local uid = has_attr(lp, attr_uniqid)
-   Np.first = lp; Np.id = id_pbox
+   Np.first = Np.first or lp; Np.id = id_pbox
    lpa = KINSOKU -- dummy=
    while lp~=last and lpa>=PACKED and lpa~=BOXBDD
       and has_attr(lp, attr_uniqid) == uid do
@@ -285,17 +290,17 @@ end
 
 local calc_np_auxtable = {
    [id_glyph] = function() 
-                  Np.first = lp
+                  Np.first = Np.first or lp
                   if lp.font == has_attr(lp, attr_curjfnt) then 
                      Np.id = id_jglyph 
                   else 
                      Np.id = id_glyph 
                   end
-                  Np.first = lp; Np.nuc = lp; set_attr_icflag_processed(lp)
+                  Np.nuc = lp; set_attr_icflag_processed(lp)
                   lp = node_next(lp); check_next_ickern(); return true
                end,
    [id_hlist] = function() 
-                  Np.first = lp; Np.last = lp; Np.nuc = lp; 
+                  Np.first = Np.first or lp; Np.last = lp; Np.nuc = lp; 
                   set_attr_icflag_processed(lp)
                   if lp.shift~=0 then 
                      Np.id = id_box_like
@@ -305,12 +310,12 @@ local calc_np_auxtable = {
                   lp = node_next(lp); return true
                end,
    [id_vlist] = function()
-                  Np.first = lp; Np.nuc = lp; Np.last = lp;
+                  Np.first = Np.first or lp; Np.nuc = lp; Np.last = lp;
                   Np.id = id_box_like; set_attr_icflag_processed(lp); 
                   lp = node_next(lp); return true
                end,
    [id_rule] = function()
-                 Np.first = lp; Np.nuc = lp; Np.last = lp;
+                 Np.first = Np.first or lp; Np.nuc = lp; Np.last = lp;
                  Np.id = id_box_like; set_attr_icflag_processed(lp); 
                  lp = node_next(lp); return true
               end,
@@ -327,7 +332,8 @@ local calc_np_auxtable = {
                    return false
                 end,
    [id_disc] = function()
-                 Np.first = lp; Np.nuc = lp; set_attr_icflag_processed(lp); 
+                 Np.first = Np.first or lp; 
+          Np.nuc = lp; set_attr_icflag_processed(lp); 
                  Np.last = lp; Np.id = id_disc; lp = node_next(lp); return true
               end,
    [id_whatsit] = function() 
@@ -345,12 +351,18 @@ local calc_np_auxtable = {
                        end
                     end
                  else
+             -- we do special treatment for these whatsit nodes.
+             if lp.subtype == sid_start_link or lp.subtype == sid_start_thread then
+                Np.first = lp 
+             elseif lp.subtype == sid_end_link or lp.subtype == sid_end_thread then
+                Nq.last = lp; Np.first = nil
+             end
                     set_attr_icflag_processed(lp); lp = node_next(lp)
                  end
                  return false
                  end,
    [id_math] = function()
-                 Np.first = lp; Np.nuc = lp; 
+                 Np.first = Np.first or lp; Np.nuc = lp; 
                  set_attr_icflag_processed(lp); lp  = node_next(lp) 
                  while lp.id~=id_math do 
                     set_attr_icflag_processed(lp); lp  = node_next(lp) 
@@ -360,11 +372,11 @@ local calc_np_auxtable = {
                  return true
               end,
    [id_glue] = function()
-                 Np.first = lp; Np.nuc = lp; set_attr_icflag_processed(lp); 
+                 Np.first = Np.first or lp; Np.nuc = lp; set_attr_icflag_processed(lp); 
                  Np.last = lp; Np.id = id_glue; lp = node_next(lp); return true
               end,
    [id_kern] = function() 
-                 Np.first = lp
+                 Np.first = Np.first or lp
                  if lp.subtype==2 then
                     set_attr_icflag_processed(lp); lp = node_next(lp)
                     set_attr_icflag_processed(lp); lp = node_next(lp)
@@ -387,7 +399,7 @@ local calc_np_auxtable = {
                     lp = node_next(lp); return false
                  end,
    [13] = function()
-                 Np.first = lp; Np.nuc = lp; Np.last = lp;
+                 Np.first = Np.first or lp; Np.nuc = lp; Np.last = lp;
                  Np.id = id_box_like; set_attr_icflag_processed(lp); 
                  lp = node_next(lp); return true
               end,
diff --git a/test/test04a-jfm-hyper.pdf b/test/test04a-jfm-hyper.pdf
new file mode 100644 (file)
index 0000000..ee5e655
Binary files /dev/null and b/test/test04a-jfm-hyper.pdf differ
diff --git a/test/test04a-jfm-hyper.tex b/test/test04a-jfm-hyper.tex
new file mode 100644 (file)
index 0000000..ebf4597
--- /dev/null
@@ -0,0 +1,28 @@
+%#!lualatex
+\documentclass{article}
+\usepackage{luatexja}
+\usepackage[pdfborder={0 0 0.1}]{hyperref}
+% \usepackage{hyperref,luatexja} ではなぜかダメ
+\def\dumplist#1{\par\noindent\leavevmode
+\hbox to 0.2\hsize{\copy#1\hss}%
+\vbox{\hsize=0.6\hsize\scriptsize\tt\baselineskip=7.2pt\let\\=\relax
+\directlua{luatexja.ext_show_node_list(tex.getbox(#1).head, '\\par ', tex.print)}\hrule}}
+
+\def\thesubsection{.}
+\def\thesubsubsection{あ}
+\DeclareFontShape{JY3}{mc}{h}{n}{<-> s*[0.962212] psft:GothicBBB-Medium:jfm=hang}{}
+\ltjsetparameter{xkanjiskip=10pt}% わざと大きくする
+\begin{document}
+\section{hoge}\label{hoge}
+
+\subsection{piyo}\label{piyo}
+
+\subsubsection{fuga}\label{fuga}
+
+\setbox0=\hbox{あ\ref{hoge}い}\dumplist0
+\setbox0=\hbox{)\ref{hoge}(}\dumplist0
+\setbox0=\hbox{\kanjiseries{h}\selectfont あ\ref{piyo}い}\dumplist0
+\setbox0=\hbox{あ\ref{piyo}い}\dumplist0
+\setbox0=\hbox{)\ref{hoge}\ref{fuga}}\dumplist0
+
+\end{document}