\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
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
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)
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
node.free(f)
end
end
- end
+ until true end
return head
end
\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}
}
\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
}
+++ /dev/null
-#!/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
+++ /dev/null
-#!/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