-- Note that another node_next will be executed outside this if-statement.
else
found_visible_node = true
- if find_first_char then
- find_first_char = false
- else
- last_char = nil
- end
+ find_first_char = false; last_char = nil
end
elseif pid==id_hlist then
if PACKED == get_attr_icflag(p) then
else
if getfield(p, 'shift')==0 then
if check_box(getlist(p), nil) then found_visible_node = true end
- else if find_first_char then
- find_first_char = false
- else
- last_char = nil
- end
+ else
+ find_first_char = false; last_char = nil
end
end
elseif pid==id_math then
or pid==id_adjust or pid==id_whatsit
or pid==id_penalty) then
found_visible_node = true
- if find_first_char then
- find_first_char = false
- else
- last_char = nil
- end
+ find_first_char = false; last_char = nil
end
p = node_next(p)
end
end
end
-local function calc_np_pbox(lp, last)
+local function calc_np_pbox(lp)
Np.first = Np.first or lp; Np.id = id_pbox
- local lpa = KINSOKU -- dummy=
+ local lpa, nc = KINSOKU, nil
set_attr(lp, attr_icflag, get_attr_icflag(lp));
- while lp~=last and lpa>=PACKED and lpa<BOXBDD do
- Np.nuc = lp;
- lp = node_next(lp); lpa = has_attr(lp, attr_icflag) or 0
- -- get_attr_icflag() ではいけない!
+ while lp and (lpa>=PACKED) and (lpa<BOXBDD) do
+ nc, lp = lp, node_next(lp); lpa = has_attr(lp, attr_icflag) or 0
+ -- get_attr_icflag() ではいけない!
end
+ Np.nuc = nc
return check_next_ickern(lp)
end
calc_np_auxtable[id_disc] = calc_np_auxtable.discglue
calc_np_auxtable[id_glue] = calc_np_auxtable.discglue
-function calc_np(lp, last)
+function calc_np(lp)
local k
-- We assume lp = node_next(Np.last)
Np, Nq, ihb_flag = Nq, Np, nil
for k in pairs(Np) do Np[k] = nil end
for k = 1,#Bp do Bp[k] = nil end
- while lp ~= last do
+ while lp do
local lpa = has_attr(lp, attr_icflag) or 0
-- unbox 由来ノードの検出
if lpa>=PACKED then
if lpa%PROCESSED_BEGIN_FLAG == BOXBDD then
local lq = node_next(lp)
head = node_remove(head, lp); node_free(lp); lp = lq
- else return calc_np_pbox(lp, last)
+ else return calc_np_pbox(lp)
end -- id_pbox
else
k, lp = calc_np_auxtable[getid(lp)](lp)
-------------------- 開始・終了時の処理
+do
-- リスト末尾の処理
local JWP = luatexja.stack_table_index.JWP
or ((lpi==id_hlist) and (lps==3))) do
if (lpi==id_hlist) and (lps==3) then par_indented = 'parbdd' end
lp=node_next(lp); lpi, lps = getid(lp), getsubtype(lp) end
- return lp, node_tail(head), par_indented
+ return lp, par_indented
+ -- return lp, node_tail(head), par_indented
else
-- the current list is the contents of a hbox:
- -- insert a sentinel
- local g = node_new(id_kern)
- insert_after(head, node_tail(head), g); last = g
- return head, g, 'boxbdd'
+ return head, 'boxbdd'
end
end
-local function cleanup(mode, last)
+local function cleanup(mode)
-- adjust attr_icflag for avoiding error
tex.setattribute('global', attr_icflag, 0)
node_free(kanji_skip); node_free(xkanji_skip)
end
return head
else
- head = node_remove(head, last); node_free(last);-- remove the sentinel
set_attr(head, attr_icflag,
get_attr_icflag(head) + PROCESSED_BEGIN_FLAG);
return head
function main(ahead, mode)
if not ahead then return ahead end
head = ahead;
- local lp, last, par_indented = init_var(mode);
+ local lp, par_indented = init_var(mode);
lp = calc_np(lp, last)
if Np then
extract_np(); handle_list_head(par_indented)
else
return cleanup(mode, last)
end
- lp = calc_np(lp, last)
+ lp = calc_np(lp)
while Np do
extract_np();
adjust_nq();
if Nq.id==id_hlist then handle_nq_ja_hlist()
else handle_nq_jachar() end
end
- lp = calc_np(lp, last)
+ lp = calc_np(lp)
end
handle_list_tail(mode)
- return cleanup(mode, last)
+ return cleanup(mode)
+end
end
do
------ used in ltjp.suppress_hyphenate_ja callback
function replace_altfont(pf, pc)
- return (alt_font_table[pf] and alt_font_table[pf][pc])
- and alt_font_table[pf][pc] or pf
+ local a = alt_font_table[pf]
+ return a and a[pc] or pf
end
------ for LaTeX interface
-- ここから先は 新 \selectfont の内部でしか実行されない
do
local alt_font_base, alt_font_base_num
-
--- EXT
- function print_aftl_address(bbase)
- local t = alt_font_table_latex[bbase]
- if not t then t = {}; alt_font_table_latex[bbase] = t end
- tex.sprint(cat_lp, (tostring(t):gsub('table: ','ltjaltfont')))
+ local aftl_base
+ -- EXT
+ function does_alt_set(bbase)
+ aftl_base = alt_font_table_latex[bbase]
+ tex.sprint(cat_lp, '\\if' .. (aftl_base and 'true' or 'false'))
end
+ -- EXT
+ function print_aftl_address()
+ tex.sprint(cat_lp, ';ltjaltfont' .. tostring(aftl_base):sub(8))
+ end
+
-- EXT
function output_alt_font_cmd(bbase)
alt_font_base = bbase
alt_font_base_num = tex.getattribute(attr_curjfnt)
local t = alt_font_table[alt_font_base_num]
if t then
- for i,_ in pairs(t) do t[i]=nil end
+ for i,_ in pairs(t) do t[i]=nil end
end
t = alt_font_table_latex[bbase]
if t then
- for i,_ in pairs(t) do
- tex.sprint(cat_lp, '\\ltj@pickup@altfont@aux{' .. i .. '}')
- end
+ for i,_ in pairs(t) do
+ tex.sprint(cat_lp, '\\ltj@pickup@altfont@aux{' .. i .. '}')
+ end
end
end
function pickup_alt_font_a(size_str)
local t = alt_font_table_latex[alt_font_base]
if t then
- for i,v in pairs(t) do
- tex.sprint(cat_lp, '\\expandafter\\ltj@pickup@altfont@copy'
- .. '\\csname ' .. i .. '/' .. size_str .. '\\endcsname{' .. i .. '}')
- end
+ for i,v in pairs(t) do
+ tex.sprint(cat_lp, '\\expandafter\\ltj@pickup@altfont@copy'
+ .. '\\csname ' .. i .. '/' .. size_str .. '\\endcsname{' .. i .. '}')
+ end
end
- end
+ end
local function pickup_alt_font_class(class, afnt_num, afnt_chars)
local t = alt_font_table[alt_font_base_num]
local tx = font_metric_table[alt_font_base_num].chars
for i,v in pairs(tx) do
- if v==class and afnt_chars[i] then t[i]=afnt_num end
+ if v==class and afnt_chars[i] then t[i]=afnt_num end
end
end
local ac = font_getfont(afnt_num).characters
if not t then t = {}; alt_font_table[alt_font_base_num] = t end
for i,v in pairs(alt_font_table_latex[alt_font_base]) do
- if i == afnt_base then
- for j,_ in pairs(v) do
- if j>=0 then
- if ac[j] then t[j]=afnt_num end
- else -- -n (n>=1) means that the character class n,
- -- which is defined in the JFM
- pickup_alt_font_class(-j, afnt_num, ac)
- end
- end
- return
- end
+ if i == afnt_base then
+ for j,_ in pairs(v) do
+ if j>=0 then
+ if ac[j] then t[j]=afnt_num end
+ else -- -n (n>=1) means that the character class n,
+ -- which is defined in the JFM
+ pickup_alt_font_class(-j, afnt_num, ac)
+ end
+ end
+ return
+ end
end
end
{Package loading is aborted now.\MessageBreak}
\expandafter\endinput\fi\relax
+ \@PackageInfo{luatexja-core}
+ {This LuaTeX-ja uses\space%
+ \directlua{if node.direct==node then tex.write('traditional node')
+ else tex:write('DIRECT') end} access model for accessing nodes.}
+
%! なお、luatexbase-compat の説明に従うと、LuaTeX 拡張プリミティブは
%! plain/LaTeX の両方で \luatex 付の名前(\directlua はそのまま)
%! で使えると考えてよい。
\newluatexattribute\ltj@yablshift % attribute for \yabaselineshift
\newluatexattribute\ltj@ykblshift % attribute for \ykbaselineshift
\newluatexattribute\jfam % index for current jfam
-\ltj@icflag=0\ltj@origchar=0\ltj@charclass=0
+\ltj@icflag=0
+\ltj@origchar=0
+\ltj@charclass=0
+\ltj@curjfnt=-1
%%%%%%%% Attributes for character ranges
\newcount\ltj@tempcnta
% 異なる和文 enc/fam/ser/shape からは異なるフォント番号が振られるように
% わざと「ゴミをつける」
\def\ltj@@patch@external@font#1 at{%
- #1;\directlua{luatexja.jfont.print_aftl_address(%
- '\luatexluaescapestring{\f@encoding/\f@family/\f@series/\f@shape}')}\space at%
+ #1\directlua{luatexja.jfont.print_aftl_address()}\space at%
}
\def\extract@jfont{%
\get@external@font
- \edef\external@font{\expandafter\ltj@@patch@external@font\external@font}%
+ \ltj@@does@alt@set{\f@encoding/\f@family/\f@series/\f@shape}%
+ \edef\external@font{\expandafter\ltj@@patch@external@font\external@font}%
+ \fi
\expandafter\globaljfont\font@name\external@font\relax
\font@name%\global\zw=\zw\global\zh=\zh
\csname \f@encoding+\f@family\endcsname
\let\ltj@@alt@selectfont@orig=\selectfont
\def\selectfont{%
\ltj@@alt@selectfont@orig
- % alt fonts の定義
- \directlua{luatexja.jfont.output_alt_font_cmd('\luatexluaescapestring{\curr@kfontshape}')}%
- % 定義した alt fonts のデータを \ltjdeclarealtfont に渡すのと同等の処理をする
- \directlua{luatexja.jfont.pickup_alt_font_a('\f@size')}%
+ \ltj@@does@alt@set{\curr@kfontshape}
+ % alt fonts の定義
+ \directlua{luatexja.jfont.output_alt_font_cmd('\luatexluaescapestring{\curr@kfontshape}')}%
+ % 定義した alt fonts のデータを \ltjdeclarealtfont に渡すのと同等の処理をする
+ \directlua{luatexja.jfont.pickup_alt_font_a('\f@size')}%
+ \fi
}
+%\let\selectfont=\ltj@@alt@selectfont@orig
+
\def\ltj@pickup@altfont@aux#1{%
{\edef\font@name{\csname #1/\f@size\endcsname}\pickup@jfont}%
}
\directlua{luatexja.jfont.pickup_alt_font_b(\the\ltj@tempcntc,'\luatexluaescapestring{#2}')}%
}
+\def\ltj@@does@alt@set#1{%
+ \directlua{luatexja.jfont.does_alt_set'\luatexluaescapestring{#1}'}}
+
\endinput