ltjb.ltj_warning_no_line = ltj_warning_no_line
ltjb.ltj_error = ltj_error
+---- deterministic version of luatexbase.add_to_callback
+function ltjb.add_to_callback(name,fun,description,priority)
+ local priority= priority
+ if priority==nil then
+ priority=#luatexbase.callback_descriptions(name)+1
+ end
+ if(luatexbase.callbacktypes[name] == 3 and
+ priority == 1 and
+ #luatexbase.callback_descriptions(name)==1) then
+ luatexbase.module_warning("luatexbase",
+ "resetting exclusive callback: " .. name)
+ luatexbase.reset_callback(name)
+ end
+ local saved_callback={},ff,dd
+ for k,v in ipairs(luatexbase.callback_descriptions(name)) do
+ if k >= priority then
+ ff,dd= luatexbase.remove_from_callback(name, v)
+ saved_callback[#saved_callback+1]={ff,dd}
+ end
+ end
+ luatexbase.base_add_to_callback(name,fun,description)
+ for _,v in ipairs(saved_callback) do
+ luatexbase.base_add_to_callback(name,v[1],v[2])
+ end
+ return
+end
+
-------------------- mock of debug logger
if not ltjb.out_debug then
local function no_op() end
end
end
- luatexbase.add_to_callback('hpack_filter',
+ ltjb.add_to_callback('hpack_filter',
create_dir_whatsit_hpack, 'ltj.create_dir_whatsit', 10000)
end
ensure_tex_attr(attr_dir, 0)
return h
end
- luatexbase.add_to_callback('post_linebreak_filter',
+ ltjb.add_to_callback('post_linebreak_filter',
create_dir_whatsit_parbox, 'ltj.create_dir_whatsit', 10000)
end
stop_time_measure('direction_vpack')
return to_node(hd)
end
- luatexbase.add_to_callback('vpack_filter',
+ ltjb.add_to_callback('vpack_filter',
dir_adjust_vpack,
'ltj.direction', 10000)
end
local function dir_adjust_pre_output(h, gc)
return to_node(create_dir_whatsit_vbox(to_direct(h), gc))
end
- luatexbase.add_to_callback('pre_output_filter',
+ ltjb.add_to_callback('pre_output_filter',
dir_adjust_pre_output,
'ltj.direction', 10000)
end
end
end
- luatexbase.add_to_callback('buildpage_filter',
+ ltjb.add_to_callback('buildpage_filter',
dir_adjust_buildpage,
'ltj.direction', 10000)
end
return to_node(head)
end
-luatexbase.add_to_callback('hpack_filter', extract,
- 'ltj.otf',
- luatexbase.priority_in_callback('pre_linebreak_filter',
- 'ltj.main'))
-luatexbase.add_to_callback('pre_linebreak_filter', extract,
- 'ltj.otf',
- luatexbase.priority_in_callback('pre_linebreak_filter',
- 'ltj.main'))
-
+ltjb.add_to_callback('hpack_filter', extract,'ltj.otf',
+ luatexbase.priority_in_callback('hpack_filter', 'ltj.main'))
+ltjb.add_to_callback('pre_linebreak_filter', extract,'ltj.otf',
+ luatexbase.priority_in_callback('pre_linebreak_filter', 'ltj.main'))
-- additional callbacks
-- 以下は,LuaTeX-ja に用意された callback のサンプルになっている.
-- JFM の文字クラスの指定の所で,"AJ1-xxx" 形式での指定を可能とした.
ltjb.package_warning('luatexja-otf',
'luatexja.otf.enable_ivs() was already called, so this call is ignored', '')
else
- luatexbase.add_to_callback('hpack_filter',
- do_ivs_repr, 'ltj.do_ivs',
- luatexbase.priority_in_callback('hpack_filter',
- 'ltj.set_stack_level')+1)
- luatexbase.add_to_callback('pre_linebreak_filter',
- do_ivs_repr, 'ltj.do_ivs',
- luatexbase.priority_in_callback('pre_linebreak_filter',
- 'ltj.set_stack_level')+1)
+ ltjb.add_to_callback('hpack_filter', do_ivs_repr, 'ltj.do_ivs',
+ luatexbase.priority_in_callback('hpack_filter', 'luaotfload.node_processor'))
+ ltjb.add_to_callback('pre_linebreak_filter', do_ivs_repr, 'ltj.do_ivs',
+ luatexbase.priority_in_callback('pre_linebreak_filter', 'luaotfload.node_processor'))
is_ivs_enabled = true
end
end
return h
end
- luatexbase.add_to_callback('hyphenate',
+ ltjb.add_to_callback('hyphenate',
function (head,tail)
return suppress_hyphenate_ja(head)
end,'ltj.hyphenate')
if ltjs.list_dir == dir_tate then
for p in Dnode.traverse_id(id_glyph,to_direct(head)) do
if (has_attr(p, attr_icflag) or 0)<=0 and getfield(p, 'lang')==lang_ja then
- local pfn = has_attr(p, attr_curtfnt) or getfont(p)
local pc = ltjs_orig_char_table[p]
- local nf = ltjf_replace_altfont(pfn, pc)
+ local nf = ltjf_replace_altfont( has_attr(p, attr_curtfnt) or getfont(p) , pc)
setfield(p, 'font', nf)
if ltjf_font_metric_table[nf].vert_activated then
pc = ltjf_vert_form_table [getchar(p)]
end
-- CALLBACKS
-luatexbase.add_to_callback('hpack_filter',
+ltjb.add_to_callback('hpack_filter',
function (head)
return set_box_stack_level(head, true)
end,'ltj.set_stack_level',1)
-luatexbase.add_to_callback('pre_linebreak_filter',
+ltjb.add_to_callback('pre_linebreak_filter',
function (head)
return set_box_stack_level(head, false)
end,'ltj.set_stack_level',1)
end
-- callbacks
- luatexbase.add_to_callback(
+ ltjb.add_to_callback(
'pre_linebreak_filter',
function (head,groupcode)
return main_process(head, true, tex.textdir, groupcode)
end,'ltj.main',
- luatexbase.priority_in_callback('pre_linebreak_filter',
- 'luaotfload.node_processor')+1)
- luatexbase.add_to_callback(
+ luatexbase.priority_in_callback('pre_linebreak_filter', 'luaotfload.node_processor')+1)
+ ltjb.add_to_callback(
'hpack_filter',
function (head,groupcode,size,packtype, dir)
return main_process(head, false, dir, groupcode)
end,'ltj.main',
- luatexbase.priority_in_callback('hpack_filter',
- 'luaotfload.node_processor') + 1)
- luatexbase.add_to_callback('pre_linebreak_filter', adjust_icflag, 'ltj.adjust_icflag', 1)
- luatexbase.add_to_callback('hpack_filter', adjust_icflag, 'ltj.adjust_icflag', 1)
+ luatexbase.priority_in_callback('hpack_filter', 'luaotfload.node_processor')+1)
+ ltjb.add_to_callback('pre_linebreak_filter', adjust_icflag, 'ltj.adjust_icflag', 1)
+ ltjb.add_to_callback('hpack_filter', adjust_icflag, 'ltj.adjust_icflag', 1)
end
--- /dev/null
+\RequirePackage{luatex85}
+\documentclass{ltjarticle}
+\usepackage[margin=20mm]{geometry}
+\usepackage{luatexja-otf}
+\usepackage[kozuka-pr6n]{luatexja-preset}
+\normalsize
+\def\test{ある日、モモちゃんが初めて「お使い」に行ったとき,
+ 彼女は道に迷って泣きました。医学,芦屋}
+\def\CB{\par{\catcode`_=12\ttfamily PR\directlua{
+ for i,v in pairs(luatexbase.callback_descriptions('hpack_filter')) do
+ tex.sprint(v .. ', ')
+ end
+}}\par{\catcode`_=12\ttfamily HP\directlua{
+ for i,v in pairs(luatexbase.callback_descriptions('pre_linebreak_filter')) do
+ tex.sprint(v .. ', ')
+ end
+}}\par}
+
+\begin{document}
+\CB
+\addjfontfeatures{RawFeature={+trad;+jp04}}\test
+\medskip
+
+\vbox{\tate\Large\hsize=9\zw\test}
+\medskip
+
+\directlua{luatexja.otf.enable_ivs()}
+\CB
+\vbox{\tate\Large\hsize=9\zw\test}
+\medskip
+
+\directlua{luatexja.otf.disable_ivs()}
+\CB
+\vbox{\tate\Large\hsize=9\zw\test}
+\medskip
+
+\test
+\end{document}
+