OSDN Git Service

Updated tests
authorHironori Kitagawa <h_kitagawa2001@yahoo.co.jp>
Mon, 4 Sep 2017 09:20:35 +0000 (18:20 +0900)
committerHironori Kitagawa <h_kitagawa2001@yahoo.co.jp>
Mon, 4 Sep 2017 09:20:35 +0000 (18:20 +0900)
test/test17-totenwidth.pdf
test/test17-totenwidth.tex
test/test21-kanjiskip.pdf
test/test22-ltjs-mag.tex
test/test54-res.pdf [deleted file]
test/test54.sh [deleted file]
test/test54a-res.pdf [deleted file]
test/test54a.sh [deleted file]

index 341c2ce..6aa9988 100644 (file)
Binary files a/test/test17-totenwidth.pdf and b/test/test17-totenwidth.pdf differ
index f9ad382..07ad828 100644 (file)
@@ -6,11 +6,12 @@
 \usepackage{luatexja,luacode}
 \begin{luacode}
 local id_hlist = node.id('hlist')
+local id_penalty = node.id('penalty')
 local id_glue  = node.id('glue')
 local id_glue_spec = node.id('glue_spec')
 local attr_icflag = luatexbase.attributes['ltj@icflag']
-local PACKED = 2
-local PROCESSED_BEGIN_FLAG = 32
+local PACKED = luatexja.icflag_table.PACKED
+local PROCESSED_BEGIN_FLAG = luatexja.icflag_table.PROCESSED_BEGIN_FLAG
 
 local function get_attr_icflag(p)
    return (node.has_attribute(p, attr_icflag) or 0) % PROCESSED_BEGIN_FLAG
@@ -22,7 +23,7 @@ local function compute_total_stretched(p)
   if gs ~= 1 and gs ~= 2 then return 0 end
   local a = 0
   for q in node.traverse_id(id_glue, p.head) do
-    local qs = q.spec
+    local qs = q
     if gs == 1 then -- stretching
       if qs.stretch_order == go then a = a + qs.stretch end
     else -- shrinking
@@ -34,13 +35,17 @@ end
 
 function adjust_width_toten(head) 
   if not head then return head end
-  for p in node.traverse_id(id_hlist, head) do
+  for p in node.traverse_id(id_hlist, head) do repeat
     local t = node.tail(p.head) -- \rightskip glue
     local x = node.prev(t)      -- 本当の行末の node を格納
+    if not x then break end
     if x.id == id_glue and x.subtype == 15 then
       -- 段落最終行のときの補正
       x = node.prev(node.prev(x))
     end
+    while x do
+      if x.id == id_penalty then x = node.prev(x) else break end
+    end
     if x.id == id_hlist and get_attr_icflag(x) == PACKED then
        local xc = x.head
        local xcs = tex.round(font.fonts[xc.font].size*0.5)
@@ -49,9 +54,8 @@ function adjust_width_toten(head)
        local cts = compute_total_stretched(p)
        if (xcc == ','  or xcc == '、' or xcc == '.'  or xcc == '。') and cts>=0 then
          local ag  = node.new(id_glue) -- additional glue
-         local ags = node.new(id_glue_spec)
-         ag.spec, ags.width = ags, math.min(xcs, cts)
-         ags.shrink, ags.stretch, ags.shrink_order, ags.stretch_order = 0, 0, 0, 0
+         ag.width = math.min(xcs, cts)
+         ag.shrink, ag.stretch, ag.shrink_order, ag.stretch_order = 0, 0, 0, 0
          node.insert_after(p.head, x, ag)
          local f = node.hpack(p.head, p.width, 'exactly')
          f.head, p.glue_set, p.glue_sign, p.glue_order 
@@ -59,7 +63,7 @@ function adjust_width_toten(head)
          node.free(f)
        end
     end
-  end
+  until true end
   return head
 end
 
@@ -71,15 +75,14 @@ luatexbase.add_to_callback('post_linebreak_filter',
 \parindent0pt
 \leavevmode
 \vrule\setbox0=\vbox{\hsize=20\zw 
-0123456789あいうえおかきくけ,%
-0123456789あいうえおかきくけ.%
-0123456789あいうえおかきく\hskip .25\zw こ.%
-0123456789あいうえおかきく\hskip .5 \zw け,%
-012345678\hskip0\zw 9あいうえおかきくけ,%
+012345678\hskip-0.25\zw 9あいうえおかきくけ,\break
+012345678\hskip0\zw 9あいうえおかきくけ,\break
+012345678\hskip0.25\zw 9あいうえおかきくけ,\break
+012345678\hskip0.5\zw 9あいうえおかきくけ,\break
+012345678\hskip0.75\zw 9あいうえおかきくけ,\break
+012345678\hskip1\zw 9あいうえおかきくけ,\break
 
 0123456789あいうえおかきくけこ%
 }\copy0\vrule
 
-\directlua{luatexja.ext_show_node_list(tex.box[0], '  ', print)}
-
-\end{document}
\ No newline at end of file
+\end{document}
index 10f6ccd..4d54384 100644 (file)
Binary files a/test/test21-kanjiskip.pdf and b/test/test21-kanjiskip.pdf differ
index e0aecc0..c5f356b 100644 (file)
@@ -3,7 +3,8 @@
 }
 \ifdefined\fsize\else\def\fsize{10pt}\fi
 \edef\head{\noexpand\documentclass[\fsize,xreal]{ltjsarticle}}
-\head\usepackage{type1cm}
+\head\usepackage[OT1]{fontenc}\def\rmdefault{cmr}
+\usepackage{type1cm}\normalfont\noralsize
 \makeatletter
 \let\ltj@selectfont@patch\relax
 \newcount\cI\newcount\cF\newdimen\szd
    \fi
 }
 \def\S#1{%
-  \setbox0\hbox{\fontsize{#1\js@mpt}{10}\selectfont
-    \@tempdimb=#1\js@mpt
+  \setbox0\hbox{\fontsize{#1\jsc@mpt}{10}\selectfont
+    \@tempdimb=#1\jsc@mpt
     \edef\@tempa{\scantextokens\expandafter{\fontname\font}\space at\space at}%
     \expandafter\S@\@tempa\@nil
   }%
 }
 \def\js@setfontsize#1#2#3{%
   \edef\Fsize{\the\dimexpr\directlua{tex.sprint(#2*\js@magscale)}pt}%
-  \@setfontsize#1{#2\js@mpt}{#3\js@mpt}}
+  \@setfontsize#1{#2\jsc@mpt}{#3\jsc@mpt}}
 \def\R#1{{%
   #1\message{^^J\string#1: \fontname\font\space (ideal: \Fsize)}%
 }}
 
 \def\T@#1#2#3{\global\count@=}
 \def\T#1#2{%
-  \setbox0\hbox{\fontsize{#1\js@mpt}{10}\selectfont
+  \setbox0\hbox{\fontsize{#1\jsc@mpt}{10}\selectfont
     \expandafter\T@\romannumeral-`0\fontname\font
   }%
   \ifnum\count@=#2\else
-    \typeout{@FAIL: #1\string\js@mpt\space selects cmr\the\count@
+    \typeout{@FAIL: #1\string\jsc@mpt\space selects cmr\the\count@
     \space(should be cmr#2)}\szd=1pt%
   \fi
 }
diff --git a/test/test54-res.pdf b/test/test54-res.pdf
deleted file mode 100644 (file)
index 8e39249..0000000
Binary files a/test/test54-res.pdf and /dev/null differ
diff --git a/test/test54.sh b/test/test54.sh
deleted file mode 100755 (executable)
index a7cbd87..0000000
+++ /dev/null
@@ -1,34 +0,0 @@
-#!/bin/bash
-
-platex -jobname test54-p test54-lltjext
-dvipdfmx test54-p
-luajitlatex -jobname test54-l test54-lltjext
-
-cat <<EOF > test54-res.tex
-\documentclass{article}
-\pdfpageattr {/Group << /S /Transparency /I true /CS /DeviceRGB>>}
-\pdfoptionpdfminorversion 7
-\usepackage[a6paper,landscape,margin=0mm]{geometry}
-\usepackage{xcolor,graphicx}
-\usepackage{transparent}
-
-\def\E#1{\newpage\leavevmode
-\hbox to 0pt{\transparent{0.5}\textcolor{red}{%
-\includegraphics[width=\textwidth,page=#1]{test54-p.pdf}}\hss}%
-\hbox to 0pt{\transparent{0.5}\textcolor{blue}{%
-\includegraphics[width=\textwidth,page=#1]{test54-l.pdf}}\hss}%
-}
-
-\begin{document}
-\parindent0pt
-
-\newcount\D
-\D=1
-\loop\ifnum\D<25
-  \E{\the\D}\advance\D1
- \repeat
-
-\end{document}
-EOF
-
-pdflatex test54-res
diff --git a/test/test54a-res.pdf b/test/test54a-res.pdf
deleted file mode 100644 (file)
index 6ce2aa2..0000000
Binary files a/test/test54a-res.pdf and /dev/null differ
diff --git a/test/test54a.sh b/test/test54a.sh
deleted file mode 100755 (executable)
index f4ef5bf..0000000
+++ /dev/null
@@ -1,34 +0,0 @@
-#!/bin/bash
-
-platex -jobname test54a-p test54a-lltjext
-dvipdfmx test54a-p
-luajitlatex -jobname test54a-l test54a-lltjext
-
-cat <<EOF > test54a-res.tex
-\documentclass{article}
-\pdfpageattr {/Group << /S /Transparency /I true /CS /DeviceRGB>>}
-\pdfoptionpdfminorversion 7
-\usepackage[a6paper,landscape,margin=0mm]{geometry}
-\usepackage{xcolor,graphicx}
-\usepackage{transparent}
-
-\def\E#1{\newpage\leavevmode
-\hbox to 0pt{\transparent{0.5}\textcolor{red}{%
-\includegraphics[width=\textwidth,page=#1]{test54a-p.pdf}}\hss}%
-\hbox to 0pt{\transparent{0.5}\textcolor{blue}{%
-\includegraphics[width=\textwidth,page=#1]{test54a-l.pdf}}\hss}%
-}
-
-\begin{document}
-\parindent0pt
-
-\newcount\D
-\D=1
-\loop\ifnum\D<49
-  \E{\the\D}\advance\D1
- \repeat
-
-\end{document}
-EOF
-
-pdflatex test54a-res