5 %% Avoid multiple loading.
6 \csname\if11luatexjaadjustLoaded\fi\endcsname
8 \catcode32=\the\catcode32%
9 \catcode33=\the\catcode33%
10 \catcode35=\the\catcode35%
11 \catcode40=\the\catcode40%
12 \catcode41=\the\catcode41%
13 \catcode42=\the\catcode42%
14 \catcode43=\the\catcode43%
15 \catcode44=\the\catcode44%
16 \catcode45=\the\catcode45%
17 \catcode46=\the\catcode46%
18 \catcode58=\the\catcode58%
19 \catcode59=\the\catcode59%
20 \catcode60=\the\catcode60%
21 \catcode61=\the\catcode61%
22 \catcode62=\the\catcode62%
23 \catcode64=\the\catcode64%
24 \catcode91=\the\catcode91%
25 \catcode93=\the\catcode93%
26 \catcode94=\the\catcode94%
27 \catcode95=\the\catcode95%
28 \catcode126=\the\catcode126%
29 \endlinechar=\the\endlinechar
54 \edef\ltj@adjust@AtEnd{\x
55 \noexpand\let\noexpand\ltj@adjust@AtEnd\relax}
56 \def\luatexjaadjustLoaded{\endinput}
58 %% Check if LaTeX is used.
59 \begingroup\expandafter\expandafter\expandafter\endgroup
60 \expandafter\ifx\csname RequirePackage\endcsname\relax %<*!LaTeX>
61 \expandafter\let\csname ifltj@in@latex\expandafter\endcsname
62 \csname iffalse\endcsname
64 \expandafter\let\csname ifltj@in@latex\expandafter\endcsname
65 \csname iftrue\endcsname
66 \NeedsTeXFormat{LaTeX2e}
67 \ProvidesPackage{luatexja-adjust}[2018/07/24]
70 % Load core module if not yet.
71 % xkeyval.sty is already required in luatexja.sty.
72 \ifx\luatexjacoreLoaded\@undefined
73 \ifltj@in@latex %<*LaTeX>
74 \RequirePackage{luatexja}
80 %% When environment check fails, exit now.
81 \ifx\LuaTeXjaAvailable\@undefined
83 \expandafter\endinput\fi\relax
87 %! Main part of luatexja-adjust
88 \RequireLuaTeXjaSubmodule{adjust}
90 \newcount\ltjadj@status@le
91 \newcount\ltjadj@status@pr
92 \let\ltjadj@method@profile\@empty
93 \let\ltjadj@method@lineskip\@empty
94 \let\ltj@adjust@temp=\relax
95 \define@choicekey[ltj]{adjust}{lineend}[\@@temp\ltj@adjust@temp]%
96 {false,true,extended}[true]{%
97 \ifnum\ltj@adjust@temp=-1 \else\ltjadj@status@le=\ltj@adjust@temp\fi\relax}
98 \define@boolkey[ltj]{adjust}{priority}[true]{%
99 \ltjadj@status@pr=\ifltj@adjust@priority1\else0\fi\relax}
100 \define@key[ltj]{adjust}{profile}[]{%
101 \def\ltjadj@method@profile{#1}\ltjadj@set@lineskip\relax}
102 \define@key[ltj]{adjust}{lineskip}[]{%
103 \def\ltjadj@method@lineskip{#1}\ltjadj@set@lineskip\relax}
104 \protected\def\ltjadj@set@lineskip{%
105 \directlua{luatexja.lineskip.setting('\ltjadj@method@profile','\ltjadj@method@lineskip')}\relax
107 \protected\def\@@ltjenableadjust[#1]{%
108 \setkeys[ltj]{adjust}{#1}%
109 \directlua{luatexja.adjust.enable_cb(\the\ltjadj@status@le, \the\ltjadj@status@pr)}\ignorespaces
111 \protected\def\ltjdisableadjust{\ltjenableadjust[lineend=false,priority=false]}
112 \protected\def\ltjenableadjust{%
113 \ltx@ifnextchar[{\@@ltjenableadjust}{\@@ltjenableadjust[lineend,priority]}}%]
118 \define@key[ltj]{adjpri}{kanjiskip}{%
119 \directlua{luatexja.adjust.priority_table[\the\count@][1] = token.scan_int()}#1\relax}
120 \define@key[ltj]{adjpri}{xkanjiskip}{%
121 \directlua{luatexja.adjust.priority_table[\the\count@][2] = token.scan_int()}#1\relax}
122 \define@key[ltj]{adjpri}{others}{%
123 \directlua{luatexja.adjust.priority_table[\the\count@][3] = token.scan_int()}#1\relax}
124 \define@key[ltj]{japaram}{stretch_priority}{%
125 \begingroup\count@=1 \setkeys[ltj]{adjpri}{#1}\relax
126 \directlua{luatexja.adjust.make_priority_table(1)}\endgroup}
127 \define@key[ltj]{japaram}{shrink_priority}{%
128 \begingroup\count@=2 \setkeys[ltj]{adjpri}{#1}\relax
129 \directlua{luatexja.adjust.make_priority_table(2)}\endgroup}
131 stretch_priority={kanjiskip=-35, xkanjiskip=-25, others=50},
132 shrink_priority={kanjiskip=-35, xkanjiskip=-25, others=50},
136 %%------------------ all done