\expandafter\let\csname ifltj@in@latex\expandafter\endcsname
\csname iftrue\endcsname
\NeedsTeXFormat{LaTeX2e}
- \ProvidesPackage{luatexja-adjust}[2019-01-06]
+ \ProvidesPackage{luatexja-adjust}[2021-12-27]
\fi %</LaTeX>
% Load core module if not yet.
\newcount\ltjadj@status@lp
\newcount\ltjadj@status@pr
\newcount\ltjadj@status@ls
+\newcount\ltjadj@status@cd
\let\ltj@adjust@temp=\relax
\define@choicekey[ltj]{adjust}{lineend}[\@@temp\ltj@adjust@temp]%
{false,true,extended}[true]{%
\ltjadj@status@lp=\ifltj@adjust@profile1\else0\fi\relax}
\define@boolkey[ltj]{adjust}{linestep}[true]{%
\ltjadj@status@ls=\ifltj@adjust@linestep1\else0\fi\relax}
+\define@boolkey[ltj]{adjust}{combinevoicedkana}[true]{%
+ \ltjadj@status@cd=\ifltj@adjust@combinevoicedkana1\else0\fi\relax}
\protected\def\@@ltjenableadjust[#1]{%
\setkeys[ltj]{adjust}{#1}%
\directlua{luatexja.adjust.enable_cb(
\the\ltjadj@status@le, \the\ltjadj@status@pr,
- \the\ltjadj@status@lp, \the\ltjadj@status@ls)}\ignorespaces
+ \the\ltjadj@status@lp, \the\ltjadj@status@ls,\the\ltjadj@status@cd)}\ignorespaces
}
\protected\def\ltjdisableadjust{%
- \ltjenableadjust[lineend=false,priority=false,profile=false,linestep=false]}
+ \ltjenableadjust[lineend=false,priority=false,profile=false,linestep=false,combinevoicedkana=false]}
\protected\def\ltjenableadjust{%
\ltx@ifnextchar[{\@@ltjenableadjust}{\@@ltjenableadjust[lineend,priority]}}%]
luatexja.load_module 'lineskip'; local ltjl = luatexja.lineskip
luatexja.adjust = luatexja.adjust or {}
+----
+local combine_voiced_kana
+do
+ local uchar = utf.char
+ local cd, cp = uchar(0x3099), uchar(0x309A)
+ local substituter = (utf.substituter or utf.subtituter) -- typo in lualibs?
+ {
+ ['ウ'..cd] = 'ヴ', ['う'..cd] = uchar(0x30F4),
+ ['か'..cd] = 'が', ['カ'..cd] = 'ガ',
+ ['き'..cd] = 'ぎ', ['キ'..cd] = 'ギ',
+ ['く'..cd] = 'ぐ', ['ク'..cd] = 'グ',
+ ['け'..cd] = 'げ', ['ケ'..cd] = 'ゲ',
+ ['こ'..cd] = 'ご', ['コ'..cd] = 'ゴ',
+ --
+ ['さ'..cd] = 'ざ', ['サ'..cd] = 'ザ',
+ ['し'..cd] = 'じ', ['シ'..cd] = 'ジ',
+ ['す'..cd] = 'ず', ['ス'..cd] = 'ズ',
+ ['せ'..cd] = 'ぜ', ['セ'..cd] = 'ゼ',
+ ['そ'..cd] = 'ぞ', ['ソ'..cd] = 'ゾ',
+ --
+ ['た'..cd] = 'だ', ['タ'..cd] = 'ダ',
+ ['ち'..cd] = 'ぢ', ['チ'..cd] = 'ヂ',
+ ['つ'..cd] = 'づ', ['ツ'..cd] = 'ヅ',
+ ['て'..cd] = 'で', ['テ'..cd] = 'デ',
+ ['と'..cd] = 'ど', ['ト'..cd] = 'ド',
+ --
+ ['は'..cd] = 'ば', ['ハ'..cd] = 'バ', ['は'..cp] = 'ぱ', ['ハ'..cp] = 'パ',
+ ['ひ'..cd] = 'び', ['ヒ'..cd] = 'ビ', ['ひ'..cp] = 'ぴ', ['ヒ'..cp] = 'ピ',
+ ['ふ'..cd] = 'ぶ', ['フ'..cd] = 'ブ', ['ふ'..cp] = 'ぷ', ['フ'..cp] = 'プ',
+ ['へ'..cd] = 'べ', ['ヘ'..cd] = 'ベ', ['へ'..cp] = 'ぺ', ['ヘ'..cp] = 'ペ',
+ ['ほ'..cd] = 'ぼ', ['ホ'..cd] = 'ボ', ['ほ'..cp] = 'ぽ', ['ホ'..cp] = 'ポ',
+ --
+ ['ゝ'..cd] = 'ゞ', ['ヽ'..cd] = 'ヾ',
+ ['ワ'..cp] = uchar(0x30F7), ['ヰ'..cp] = uchar(0x30F8),
+ ['ヱ'..cp] = uchar(0x30F9), ['ヲ'..cp] = uchar(0x30FA),
+ }
+ combine_voiced_kana = function(buffer) return substituter(buffer) end
+end
+----
+
local to_node = node.direct.tonode
local to_direct = node.direct.todirect
return to_node(head)
end
local is_reg = false
- local function enable_cb(status_le, status_pr, status_lp, status_ls)
+ local function enable_cb(status_le, status_pr, status_lp, status_ls, status_cd)
if (status_le>0 or status_pr>0) and (not is_reg) then
ltjb.add_to_callback('post_linebreak_filter',
adjust_width, 'Adjust width',
luatexja.lineskip.setting(
status_lp>0 and 'profile' or 'dummy',
status_ls>0 and 'step' or 'dummy'
- )
+ )
+ if status_cd==1 then
+ if not luatexbase.in_callback('process_input_buffer', 'Combine voiced kana-syllables') then
+ ltjb.add_to_callback('process_input_buffer', combine_voiced_kana, 'Combine voiced kana-syllables')
+ end
+ else
+ if luatexbase.in_callback('process_input_buffer', 'Combine voiced kana-syllables') then
+ luatexbase.remove_from_callback('process_input_buffer', 'Combine voiced kana-syllables')
+ end
+ end
end
local function disable_cb() -- only for compatibility
- enable_cs(0,0,0,0)
+ enable_cs(0,0,0,0,0)
end
luatexja.adjust.enable_cb=enable_cb
luatexja.adjust.disable_cb=disable_cb
--- /dev/null
+\documentclass{ltjarticle}\usepackage{luatexja-adjust}
+\usepackage[margin=15mm]{geometry}\begin{document}\large FALSE
+{\obeylines\ttfamily
+U+304x ぁ あ ぃ い ぅ う ぇ え ぉ お か が き ぎ く
+U+305x ぐ け げ こ ご さ ざ し じ す ず せ ぜ そ ぞ た
+U+306x だ ち ぢ っ つ づ て で と ど な に ぬ ね の は
+U+307x ば ぱ ひ び ぴ ふ ぶ ぷ へ べ ぺ ほ ぼ ぽ ま み
+U+308x む め も ゃ や ゅ ゆ ょ よ ら り る れ ろ ゎ わ
+U+309x ゐ ゑ を ん ゔ ゕ ゖ ゙ ゚ ゛ ゜ ゝ ゞ ゟ
+U+30Ax ゠ ァ ア ィ イ ゥ ウ ェ エ ォ オ カ ガ キ ギ ク
+U+30Bx グ ケ ゲ コ ゴ サ ザ シ ジ ス ズ セ ゼ ソ ゾ タ
+U+30Cx ダ チ ヂ ッ ツ ヅ テ デ ト ド ナ ニ ヌ ネ ノ ハ
+U+30Dx バ パ ヒ ビ ピ フ ブ プ ヘ ベ ペ ホ ボ ポ マ ミ
+U+30Ex ム メ モ ャ ヤ ュ ユ ョ ヨ ラ リ ル レ ロ ヮ ワ
+U+30Fx ヰ ヱ ヲ ン ヴ ヵ ヶ ワ゚ ヰ゚ ヱ゚ ヲ゚ ・ ー ヽ ヾ ヿ
+\par}
+
+\par
+\newpage\ltjenableadjust[combinevoicedkana] TRUE
+{\obeylines\ttfamily
+U+304x ぁ あ ぃ い ぅ う ぇ え ぉ お か が き ぎ く
+U+305x ぐ け げ こ ご さ ざ し じ す ず せ ぜ そ ぞ た
+U+306x だ ち ぢ っ つ づ て で と ど な に ぬ ね の は
+U+307x ば ぱ ひ び ぴ ふ ぶ ぷ へ べ ぺ ほ ぼ ぽ ま み
+U+308x む め も ゃ や ゅ ゆ ょ よ ら り る れ ろ ゎ わ
+U+309x ゐ ゑ を ん ゔ ゕ ゖ ゙ ゚ ゛ ゜ ゝ ゞ ゟ
+U+30Ax ゠ ァ ア ィ イ ゥ ウ ェ エ ォ オ カ ガ キ ギ ク
+U+30Bx グ ケ ゲ コ ゴ サ ザ シ ジ ス ズ セ ゼ ソ ゾ タ
+U+30Cx ダ チ ヂ ッ ツ ヅ テ デ ト ド ナ ニ ヌ ネ ノ ハ
+U+30Dx バ パ ヒ ビ ピ フ ブ プ ヘ ベ ペ ホ ボ ポ マ ミ
+U+30Ex ム メ モ ャ ヤ ュ ユ ョ ヨ ラ リ ル レ ロ ヮ ワ
+U+30Fx ヰ ヱ ヲ ン ヴ ヵ ヶ ワ゚ ヰ゚ ヱ゚ ヲ゚ ・ ー ヽ ヾ ヿ
+\par}
+
+\par
+\newpage\ltjenableadjust[combinevoicedkana=false] FALSE
+{\obeylines\ttfamily
+U+304x ぁ あ ぃ い ぅ う ぇ え ぉ お か が き ぎ く
+U+305x ぐ け げ こ ご さ ざ し じ す ず せ ぜ そ ぞ た
+U+306x だ ち ぢ っ つ づ て で と ど な に ぬ ね の は
+U+307x ば ぱ ひ び ぴ ふ ぶ ぷ へ べ ぺ ほ ぼ ぽ ま み
+U+308x む め も ゃ や ゅ ゆ ょ よ ら り る れ ろ ゎ わ
+U+309x ゐ ゑ を ん ゔ ゕ ゖ ゙ ゚ ゛ ゜ ゝ ゞ ゟ
+U+30Ax ゠ ァ ア ィ イ ゥ ウ ェ エ ォ オ カ ガ キ ギ ク
+U+30Bx グ ケ ゲ コ ゴ サ ザ シ ジ ス ズ セ ゼ ソ ゾ タ
+U+30Cx ダ チ ヂ ッ ツ ヅ テ デ ト ド ナ ニ ヌ ネ ノ ハ
+U+30Dx バ パ ヒ ビ ピ フ ブ プ ヘ ベ ペ ホ ボ ポ マ ミ
+U+30Ex ム メ モ ャ ヤ ュ ユ ョ ヨ ラ リ ル レ ロ ヮ ワ
+U+30Fx ヰ ヱ ヲ ン ヴ ヵ ヶ ワ゚ ヰ゚ ヱ゚ ヲ゚ ・ ー ヽ ヾ ヿ
+\par}
+
+\end{document}