Debian Codegraph @

texmf-dist/tex/luatex/luatexko/luatexko.sty

raw
1 % luatexko.sty
2 %
3 % Copyright (c) 2013-2026 Dohyun Kim <nomosnomos at gmail com>
4 % Soojin Nam <jsunam at gmail com>
5 %
6 % This work may be distributed and/or modified under the
7 % conditions of the LaTeX Project Public License, either version 1.3c
8 % of this license or (at your option) any later version.
9 % The latest version of this license is in
10 % http://www.latex-project.org/lppl.txt
11 % and version 1.3c or later is part of all distributions of LaTeX
12 % version 2006/05/20 or later.
13
14 \ifdefined\luatexkohangulfontattr \endinput\fi
15 \ifdefined\ProvidesPackage
16 \NeedsTeXFormat{LaTeX2e}[2025/06/01]
17 \ProvidesPackage{luatexko}[2026/02/20 v5.7 typesetting Korean with LuaTeX]
18 \RequirePackage{fontspec}[2020/02/03]
19 \let\luatexkoselectfont\selectfont
20 \else
21 \input luaotfload.sty
22 \input atbegshi.sty
23 \chardef\luatexkoatcatcode=\catcode`\@
24 \catcode`\@=11
25 \fi
26 \newlanguage\koreanlanguage
27 \newattribute\luatexkohangulfontattr
28 \newattribute\luatexkohanjafontattr
29 \newattribute\luatexkofallbackfontattr
30 \newattribute\luatexkoautojosaattr
31 \newattribute\luatexkoclassicattr
32 \newattribute\luatexkodotemphattr
33 \newattribute\luatexkorubyattr \chardef\luatexkorubyalloc\allocationnumber
34 \newattribute\luatexkohangulbyhangulattr
35 \newattribute\luatexkohanjabyhanjaattr
36 \directlua{ require"luatexko" }
37 % classics
38 % 0: horizontal KO, JP
39 % 1: vertical KO, SC
40 % 2: horizontal SC
41 % 3: horizontal TC
42 % 4: vertical TC
43 % 5: vertical JP
44 \chardef\luatexkolangCJK=\z@ % 0:KO, 1:JP, 2:SC, 3:TC
45 \protected\def\typesetclassic{%
46 \ifnum\luatexkoclassicattr<\z@
47 \luatexkoclassicattr\z@
48 \parindent1em
49 \fi
50 }
51 \protected\def\typesetvertical{% 1, 4, 5
52 \ifcase\luatexkolangCJK
53 \luatexkoclassicattr\@ne
54 \parindent1em
55 \or
56 \luatexkoclassicattr=5\relax
57 \parindent1em
58 \or
59 \luatexkoclassicattr\@ne
60 \parindent2em
61 \or
62 \luatexkoclassicattr=4\relax
63 \parindent2em
64 \else
65 \luatexkoclassicattr\@ne
66 \parindent1em
67 \fi
68 }
69 \protected\def\typesetmodern{\unsetattribute\luatexkoclassicattr}
70 \protected\def\japanese{% 0, 5
71 \chardef\luatexkolangCJK=\@ne
72 \ifcase\luatexkoclassicattr
73 \or
74 \luatexkoclassicattr=5\relax
75 \or
76 \luatexkoclassicattr\z@
77 \or
78 \luatexkoclassicattr\z@
79 \or
80 \luatexkoclassicattr=5\relax
81 \or
82 \else
83 \luatexkoclassicattr\z@
84 \fi
85 \parindent1em
86 }
87 \protected\def\Schinese{% 2, 1
88 \chardef\luatexkolangCJK=\tw@
89 \ifcase\luatexkoclassicattr
90 \luatexkoclassicattr\tw@
91 \or
92 \or
93 \or
94 \luatexkoclassicattr\tw@
95 \or
96 \luatexkoclassicattr\@ne
97 \or
98 \luatexkoclassicattr\@ne
99 \else
100 \luatexkoclassicattr\tw@
101 \fi
102 \parindent2em
103 }
104 \protected\def\Tchinese{% 3, 4
105 \chardef\luatexkolangCJK=\thr@@
106 \ifcase\luatexkoclassicattr
107 \luatexkoclassicattr\thr@@
108 \or
109 \luatexkoclassicattr=4\relax
110 \or
111 \luatexkoclassicattr\thr@@
112 \or
113 \or
114 \or
115 \luatexkoclassicattr=4\relax
116 \else
117 \luatexkoclassicattr\thr@@
118 \fi
119 \parindent2em
120 }
121 \let\korean\typesetmodern \let\chinese\Schinese
122 % josa
123 \count@"AC00
124 \loop
125 \catcode\count@ 12
126 \ifnum\count@<"D7A3 \advance\count@\@ne \repeat
127 \newcount\josaignoreparens
128 \def\luatexkojosaactivate{%
129 \ifx\luatexkojosaactive\relax
130 \else
131 \directlua{ luatexko.activate("autojosa") }%
132 \global\let\luatexkojosaactive\relax
133 \fi
134 \luatexkoautojosaattr\josaignoreparens }
135 \protected\def\은{\begingroup\luatexkojosaactivate 은\endgroup}
136 \let\는\은
137 \protected\def\을{\begingroup\luatexkojosaactivate 을\endgroup}
138 \let\를\을
139 \protected\def\와{\begingroup\luatexkojosaactivate 와\endgroup}
140 \let\과\와
141 \protected\def\가{\begingroup\luatexkojosaactivate 가\endgroup}
142 \protected\def\이{\begingroup\luatexkojosaactivate 이\endgroup}
143 \protected\def\라{\이라}
144 \protected\def\으{\begingroup\luatexkojosaactivate 으\endgroup}
145 \protected\def\로{\으로}
146 % force hangul font
147 \def\luatexkotoks@appendchars#1,{%
148 \ifx\empty#1\empty
149 \expandafter\luatexkotoks@appendchars
150 \else
151 \ifx*#1\else
152 \expandafter\ifx\expandafter\empty\the\toks@\empty
153 \etoksapp0{\number#1}%
154 \else
155 \etoksapp0{,\number#1}%
156 \fi
157 \expandafter\expandafter\expandafter\luatexkotoks@appendchars
158 \fi
159 \fi }
160 \def\luatexkodoluacode#1{\luatexkobsphack\directlua{
161 \ifhmode luatexko.updateforcehangul(function() \fi
162 #1
163 \ifhmode end) \fi }\luatexkoesphack}
164 \ifcsname @bsphack\endcsname
165 \let\luatexkobsphack\@bsphack
166 \let\luatexkoesphack\@esphack
167 \else
168 \let\luatexkobsphack\relax
169 \let\luatexkoesphack\relax
170 \fi
171 \protected\def\registerpunctuations#1{%
172 \toks@{}\luatexkotoks@appendchars#1,*,\luatexkodoluacode{
173 local t = luatexko.forcehangulchars
174 for _,v in ipairs{\the\toks@} do t[v]=true end }}
175 \let\registerhangulpunctuations\registerpunctuations
176 \protected\def\unregisterpunctuations#1{%
177 \toks@{}\luatexkotoks@appendchars#1,*,\luatexkodoluacode{
178 local t = luatexko.forcehangulchars
179 for _,v in ipairs{\the\toks@} do t[v]=nil end }}
180 \let\unregisterhangulpunctuations\unregisterpunctuations
181 \protected\def\hangulpunctuations{%
182 \afterassignment\luatexkohangulpunctuations\count@ }
183 \def\luatexkohangulpunctuations{\luatexkodoluacode{
184 local t = luatexko.forcehangulchars
185 for i in pairs(t) do t[i]=\ifcase\count@ false \else true \fi end }}
186 % breakable before/after (affects entire paragraph and all after)
187 \protected\def\registerbreakableafter#1{%
188 \toks@{}\luatexkotoks@appendchars#1,*,\directlua{
189 local t = luatexko.breakableafter
190 for _,v in ipairs{\the\toks@} do t[v]=true end }}
191 \protected\def\registerbreakablebefore#1{%
192 \toks@{}\luatexkotoks@appendchars#1,*,\directlua{
193 local t = luatexko.breakablebefore
194 for _,v in ipairs{\the\toks@} do t[v]=true end }}
195 % hangulbyhangul/hanjabyhanja font
196 \protected\def\hangulbyhangulfont{%
197 \afterassignment\luatexkohangulbyhangulfont\count@ }
198 \def\luatexkohangulbyhangulfont{%
199 \ifcase\count@ \unsetattribute\luatexkohangulbyhangulattr
200 \else \luatexkohangulbyhangulattr\count@
201 \fi }
202 \protected\def\hanjabyhanjafont{%
203 \afterassignment\luatexkohanjabyhanjafont\count@ }
204 \def\luatexkohanjabyhanjafont{%
205 \ifcase\count@ \unsetattribute\luatexkohanjabyhanjaattr
206 \else \luatexkohanjabyhanjaattr\count@
207 \fi }
208 % dotemph
209 \newcount\luatexkodotemphcount
210 \def\dotemphraise{1ex }
211 \edef\dotemphchar{\expandafter\noexpand\ifdefined\bfseries\bfseries\else\bf\fi ^^^^02d9}
212 \protected\def\dotemph#1{%
213 \global\advance\luatexkodotemphcount\@ne
214 \ifnum\luatexkodotemphcount=\@ne \directlua{ luatexko.activate"dotemph" }\fi
215 \begingroup
216 \count@=\luatexkodotemphcount
217 \setbox\z@\hbox{\raise\dotemphraise\hbox{\luatexkodotemphchar}}%
218 \directlua{ local n, hbox, getnext = tex.getbox(0).head, node.id"hlist", node.getnext
219 while n and n.id \csstring\~= hbox do n = getnext(n) end
220 luatexko.dotemphbox[\number\count@] = node.copy(n) }%
221 \luatexkodotemphattr\count@ #1\relax
222 \directlua{ luatexko.dotemphboundary(\number\count@) }%
223 \endgroup }
224 \def\luatexkodotemphchar{\dotemphchar}
225 % uline
226 \newcount\luatexkoulinecount
227 \def\ulinedown{0.5ex }\def\ulinewidth{0.04em }
228 \protected\def\markoverwith#1#{%
229 \ifx\empty#1\empty
230 \def\luatexkoleaderstype{101}% cleaders
231 \else
232 \def\luatexkoleaderstype{102}% xleaders
233 \fi
234 \luatexkomarkoverwith }
235 \def\luatexkomarkoverwith#1#2{%
236 \global\advance\luatexkoulinecount\@ne
237 \ifnum\luatexkoulinecount=\@ne \directlua{ luatexko.activate"uline" }\fi
238 \begingroup
239 \ifx\luatexko@prev@ulinedown\ulinedown
240 \edef\ulinedown{\dimexpr\ulinedown+\ulinewidth+.15ex\relax}\fi
241 \let\luatexko@prev@ulinedown\ulinedown
242 \count@=\luatexkoulinecount
243 \leavevmode
244 \setbox\z@\hbox{#1}%
245 \directlua{ luatexko.ulboundary(\number\count@, tex.box[0].list, \luatexkoleaderstype) }%
246 #2\relax
247 \directlua{ luatexko.ulboundary(\number\count@) }%
248 \endgroup }
249 \protected\def\uline{\markoverwith{%
250 \vrule width\z@ height-\ulinedown depth\dimexpr\ulinedown+\ulinewidth\relax }}
251 \protected\def\dashuline{\markoverwith*{%
252 \hbox{\kern.125em
253 \vrule width.3em height-\ulinedown depth\dimexpr\ulinedown+\ulinewidth\relax
254 \kern.125em }}}
255 \protected\def\dotuline{\markoverwith*{%
256 \lower\dimexpr\ulinedown+.2ex\relax\hbox{\kern.07em .\kern.07em }}}
257 \protected\def\uuline{\markoverwith{%
258 \lower\ulinedown\vtop{%
259 \hrule width .2em height\z@ depth\ulinewidth
260 \kern .15ex
261 \hrule width .2em height\z@ depth\ulinewidth
262 }%
263 }}
264 \protected\def\sout#1{%
265 \begingroup
266 \setbox\z@\hbox{#1}%
267 \edef\soutdown{%
268 \the\dimexpr
269 \directlua{ tex.sprint(luatexko.get_strike_out_down(tex.box[0])) }sp
270 -.5\dimexpr\ulinewidth\relax \relax
271 }%
272 \markoverwith{%
273 \vrule width \z@
274 height-\soutdown
275 depth \dimexpr\soutdown+\ulinewidth\relax
276 }%
277 {#1}%
278 \endgroup
279 }
280 \protected\def\xout{\markoverwith{\hbox to.4em{\hss/\hss}}}
281 \protected\def\uwave{\font\luatexkofontsixly=lasy6\relax
282 \markoverwith{\lower4\p@\hbox{\luatexkofontsixly\char58}}}
283 % ruby
284 \def\rubysize{0.6} % size of ruby compared to base chars
285 \def\rubysep{0.1ex} % distance between base chars and ruby
286 \def\luatexkostretchfactor{.0125} % .5em/20/2 is hard coded.
287 \newif\ifruby@overlap
288 \let\rubyoverlap\ruby@overlaptrue
289 \let\rubynooverlap\ruby@overlapfalse
290 \rubyoverlap % ruby may hangover neighboring chars
291 \newcount\luatexkorubycount
292 \protected\def\ruby#1#2{%
293 \global\advance\luatexkorubycount\@ne
294 \ifnum\luatexkorubycount=\@ne \directlua{ luatexko.activate"ruby" }\fi
295 \begingroup
296 \count@=\luatexkorubycount
297 \leavevmode
298 \setbox\z@\hbox attr\luatexkorubyalloc=\count@{#1}% base
299 \setbox\tw@\hbox{% ruby
300 \ifdefined\rubyfont \rubyfont \fi
301 \ifcsname [email protected]\endcsname % <- latex
302 \dimen@\dimexpr\rubysize em\relax
303 \fontsize\dimen@\dimen@\luatexkoselectfont
304 \fi
305 #2}%
306 \hbadness\@M % supress underfull warning
307 \dimen@ii\dimexpr\rubysize em\relax % ruby font size
308 \directlua{ luatexko.getrubystretchfactor(tex.box[2]) }% for intercharstretch
309 \ifdim\wd\z@ < \wd\tw@ % ruby is wider
310 \ifruby@overlap
311 \dimen@\dimexpr\wd\tw@-\wd\z@-\dimen@ii\relax % overhang .5 rubysize
312 \ifdim\dimen@ > \z@
313 \setbox\z@\hbox attr\luatexkorubyalloc=\count@ spread\dimen@{%
314 \hskip\z@ plus \luatexkostretchfactor em\relax
315 \unhbox\z@
316 \hskip\z@ plus \luatexkostretchfactor em\relax }%
317 \fi
318 \else
319 \setbox\z@\hbox attr\luatexkorubyalloc=\count@ to\wd\tw@{%
320 \hskip\z@ plus \luatexkostretchfactor em\relax
321 \unhbox\z@
322 \hskip\z@ plus \luatexkostretchfactor em\relax }%
323 \fi
324 \else
325 \ifdim\rubysize\wd\z@ > 2\wd\tw@ % ruby is far shorter
326 \setbox\tw@\hbox to\wd\z@{%
327 \hskip\dimen@ii plus 1sp\relax
328 \unhbox\tw@
329 \hskip\dimen@ii plus 1sp\relax }%
330 \else
331 \setbox\tw@\hbox to\wd\z@{%
332 \hskip\z@ plus \luatexkostretchfactor \dimen@ii\relax
333 \unhbox\tw@
334 \hskip\z@ plus \luatexkostretchfactor \dimen@ii\relax }%
335 \fi
336 \fi
337 \directlua{
338 luatexko.rubybox[\number\count@] = {
339 node.copy(tex.box[2]),
340 \number\numexpr\dimexpr\rubysep\relax\relax,
341 \ifruby@overlap true\else false\fi, }}%
342 \box\z@
343 \endgroup }
344 % vertical writing
345 \protected\def\vertical#1{%
346 \leavevmode
347 \ifx\empty#1\empty
348 \setbox\z@\hbox\bgroup
349 \else
350 \setbox\z@\vbox\bgroup \hsize#1\relax
351 \fi
352 \typesetvertical }
353 \protected\def\endvertical{%
354 \ifinner\else \par\fi
355 \egroup
356 \luatexkorotatebox\z@
357 \box\z@ }
358 \protected\def\luatexkorotatebox#1{%
359 \dimen@\dimexpr\ht#1+\dp#1\relax
360 \setbox#1\hbox to\dimen@\bgroup
361 \hfil
362 \vbox to\wd#1\bgroup
363 \wd#1\z@
364 \ifnum\outputmode > 0
365 \pdfextension save\relax
366 \pdfextension setmatrix{0 -1 1 0}\relax
367 \else
368 \special{pdf:btrans rotate -90}\relax
369 \fi
370 \box#1\relax
371 \kern-\dimen@
372 \ifnum\outputmode > 0
373 \pdfextension restore\relax
374 \else
375 \special{pdf:etrans}\relax
376 \fi
377 \vfil
378 \egroup
379 \egroup
380 }
381 % horizontal box inside vertical writing
382 \def\luatexkohorizboxmoveright{0.5ex}
383 \protected\def\horizontal#1{%
384 \directlua{ luatexko.gethorizboxmoveright() }%
385 \leavevmode
386 \ifx\empty#1\empty
387 \setbox\z@\hbox\bgroup
388 \else
389 \setbox\z@\vbox\bgroup \hsize#1\relax
390 \fi
391 \typesetmodern }
392 \protected\def\endhorizontal{%
393 \ifinner\else \par\fi
394 \egroup
395 \luatexkounrotatebox\z@
396 \raise\luatexkohorizboxmoveright
397 \box\z@ }
398 \protected\def\luatexkounrotatebox#1{%
399 \dimen@\dimexpr\ht#1+\dp#1\relax
400 \setbox#1\hbox to\dimen@\bgroup
401 \lower.5\wd#1\vbox to\wd#1\bgroup
402 \vfil
403 \wd#1\z@
404 \ifnum\outputmode > 0
405 \pdfextension save\relax
406 \pdfextension setmatrix{0 1 -1 0}\relax
407 \else
408 \special{pdf:btrans rotate 90}\relax
409 \fi
410 \box#1\relax
411 \kern-\dimen@
412 \ifnum\outputmode > 0
413 \pdfextension restore\relax
414 \else
415 \special{pdf:etrans}\relax
416 \fi
417 \egroup
418 \hfil
419 \egroup
420 }
421 % hangul normalize
422 \def\luatexhangulnormalize{%
423 \directlua{require"luatexko-normalize"}%
424 \afterassignment\luatexkohangulnormalize\count@}
425 \def\luatexkohangulnormalize{%
426 \ifcase\count@ \directlua{ luatexko.normalize.unload() }% 0: none
427 \or \directlua{ luatexko.normalize.compose() }% 1: nfc
428 \else \directlua{ luatexko.normalize.decompose() }% 2: nfd
429 \fi }
430 % convert uhc to utf8
431 \def\luatexuhcinputencoding{%
432 \directlua{require"luatexko-uhc2utf8"}%
433 \afterassignment\luatexkouhcinputencoding\count@}
434 \def\luatexkouhcinputencoding{%
435 \ifcase\count@ \directlua{ luatexko.uhc2utf8.stopconvert() }%
436 \else \directlua{ luatexko.uhc2utf8.startconvert() }%
437 \fi}
438 % math hangul
439 \def\setmathhangulblock#1#2{%
440 \count@="#1
441 \loop
442 \Umathcode\count@ = 7 \symmathhangul\count@
443 \ifnum\count@<"#2 \advance\count@\@ne \repeat}
444 % font fallback
445 \newif\ifluatexkorunningselectfont
446 \def\luatexkohangulselectfont{%
447 \ifluatexkorunningselectfont \else
448 \ifdefined\luatexkohangulfont
449 \begingroup
450 \luatexkorunningselectfonttrue
451 \luatexkohangulfont
452 \expandafter\expandafter\expandafter\endgroup
453 \expandafter\luatexkohangulfontattr\fontid\font\relax
454 \fi
455 \fi }
456 \def\luatexkohanjaselectfont{%
457 \ifluatexkorunningselectfont \else
458 \ifdefined\luatexkohanjafont
459 \begingroup
460 \luatexkorunningselectfonttrue
461 \luatexkohanjafont
462 \expandafter\expandafter\expandafter\endgroup
463 \expandafter\luatexkohanjafontattr\fontid\font\relax
464 \fi
465 \fi }
466 \def\luatexkofallbackselectfont{%
467 \ifluatexkorunningselectfont \else
468 \ifdefined\luatexkofallbackfont
469 \begingroup
470 \luatexkorunningselectfonttrue
471 \luatexkofallbackfont
472 \expandafter\expandafter\expandafter\endgroup
473 \expandafter\luatexkofallbackfontattr\fontid\font\relax
474 \fi
475 \fi }
476 % plain
477 \ifcsname [email protected]\endcsname\else
478 % do not verticalize headline/footline.
479 \def\verticaltypesetting{%
480 \dimen@\hsize \hsize\vsize \vsize\dimen@
481 \edef\plainoutput{\dimen@\hsize \hsize\vsize \vsize\dimen@
482 \unexpanded\expandafter{\plainoutput}}%
483 \def\pagebody{\setbox\z@\vbox to\hsize{\boxmaxdepth=\maxdepth \pagecontents}%
484 \luatexkorotatebox\z@\box\z@}%
485 \typesetvertical
486 \let\verticaltypesetting\relax % prevent multiple running
487 }
488 \def\beginverticaltypesetting{\vfill\supereject \begingroup \verticaltypesetting}
489 \def\endverticaltypesetting{\vfill\supereject \endgroup}
490 % hangul fonts
491 \protected\def\hangulfont{%
492 \afterassignment\luatexkohangulselectfont\font\luatexkohangulfont}
493 \protected\def\hanjafont{%
494 \afterassignment\luatexkohanjaselectfont\font\luatexkohanjafont}
495 \protected\def\fallbackfont{%
496 \afterassignment\luatexkofallbackselectfont\font\luatexkofallbackfont}
497 \def\sethangulfont#1{%
498 \def\@tempa{#1}\edef\@tempb{\csstring#1}%
499 \expandafter\afterassignment\expandafter\luatexko@sethangulfont
500 \expandafter\font\csname luatexko.hangulfont.\@tempb\endcsname }
501 \def\luatexko@sethangulfont{%
502 \expandafter\protected\expandafter\edef\@tempa{%
503 \luatexkohangulfontattr\fontid\csname luatexko.hangulfont.\@tempb\endcsname\relax }}
504 \def\sethanjafont#1{%
505 \def\@tempa{#1}\edef\@tempb{\csstring#1}%
506 \expandafter\afterassignment\expandafter\luatexko@sethanjafont
507 \expandafter\font\csname luatexko.hanjafont.\@tempb\endcsname }
508 \def\luatexko@sethanjafont{%
509 \expandafter\protected\expandafter\edef\@tempa{%
510 \luatexkohanjafontattr\fontid\csname luatexko.hanjafont.\@tempb\endcsname\relax }}
511 \def\setfallbackfont#1{%
512 \def\@tempa{#1}\edef\@tempb{\csstring#1}%
513 \expandafter\afterassignment\expandafter\luatexko@setfallbackfont
514 \expandafter\font\csname luatexko.fallbackfont.\@tempb\endcsname }
515 \def\luatexko@setfallbackfont{%
516 \expandafter\protected\expandafter\edef\@tempa{%
517 \luatexkofallbackfontattr\fontid\csname luatexko.fallbackfont.\@tempb\endcsname\relax }}
518 \hangulfont={UnBatang:mode=node;script=hang;+tlig} at 10pt % default: unbatang
519 \protected\def\setmathhangulfonts#1#2#3{% font identifiers
520 \ifnum\Umathcodenum"AC00="AC00\relax
521 \csname newfam\endcsname\symmathhangul
522 \setmathhangulblock{AC00}{D7A3}%
523 \fi
524 \textfont\symmathhangul=#1\relax
525 \scriptfont\symmathhangul=#2\relax
526 \scriptscriptfont\symmathhangul=#3\relax }
527 \protected\def\mathhangulfont{%
528 \afterassignment\luatexkosetmathhangulfonts\font\textmathhangul}
529 \def\luatexkosetmathhangulfonts{%
530 \toks@\expandafter{\directlua{
531 local n = tex.fontname(font.id"textmathhangul"):gsub(" at .+", "")
532 tex.sprint(string.unquoted(n)) }}%
533 \dimen@\fontdimen 6 \textmathhangul
534 \font\scriptmathhangul= {\the\toks@} at .7\dimen@
535 \font\scriptscriptmathhangul = {\the\toks@} at .5\dimen@
536 \setmathhangulfonts\textmathhangul\scriptmathhangul\scriptscriptmathhangul}
537 \catcode`\@=\luatexkoatcatcode
538 \endinput\fi
539 % latex
540 % do not verticalize headline/footline
541 \def\verticaltypesetting{%
542 \ifx\@nodocument\relax % not in the preamble
543 \clearpage
544 \begingroup
545 \fi
546 \hsize\textheight \vsize\textwidth
547 \textwidth\hsize \textheight\vsize
548 \@colroom\vsize \@colht\vsize
549 \if@twocolumn
550 \columnwidth=.5\dimexpr\textwidth-\columnsep\relax
551 \linewidth\columnwidth \hsize\columnwidth
552 \else
553 \linewidth\hsize \columnwidth\hsize
554 \fi
555 \AddToHook{build/page/before}[luatexko/beforeOR]{%
556 \luatexkorotatebox\@outputbox
557 \textwidth\textheight
558 }%
559 \typesetvertical
560 \let\verticaltypesetting\relax % prevent multiple running
561 }
562 \def\endverticaltypesetting{%
563 \clearpage
564 \RemoveFromHook{build/page/before}[luatexko/beforeOR]%
565 \endgroup
566 \global\@colroom\textheight
567 \global\@colht\textheight
568 \global\vsize\textheight
569 }
570 % hangul fonts
571 \AddToHook{selectfont}{%
572 \luatexkohangulselectfont
573 \luatexkohanjaselectfont
574 \luatexkofallbackselectfont
575 }
576 \AddToHook{rmfamily}{%
577 \let\luatexkohangulfont \luatexkomainhangulfont
578 \let\luatexkohanjafont \luatexkomainhanjafont
579 \let\luatexkofallbackfont\luatexkomainfallbackfont
580 }
581 \AddToHook{sffamily}{%
582 \let\luatexkohangulfont \luatexkosanshangulfont
583 \let\luatexkohanjafont \luatexkosanshanjafont
584 \let\luatexkofallbackfont\luatexkosansfallbackfont
585 }
586 \AddToHook{ttfamily}{%
587 \let\luatexkohangulfont \luatexkomonohangulfont
588 \let\luatexkohanjafont \luatexkomonohanjafont
589 \let\luatexkofallbackfont\luatexkomonofallbackfont
590 }
591 \AddToHook{normalfont}{%
592 \let\luatexkohangulfont \luatexkodefaulthangulfont
593 \let\luatexkohanjafont \luatexkodefaulthanjafont
594 \let\luatexkofallbackfont\luatexkodefaultfallbackfont
595 }
596 % fontspec-like
597 \ExplSyntaxOn
598 \DeclareDocumentCommand \setmainhangulfont { O{} m O{} }
599 {
600 \fontspec_set_family:Nnn \luatexkomainhangulfamily { Ligatures=TeX, #1, #3 } { #2 }
601 \cs_set_protected_nopar:Npn \luatexkomainhangulfont
602 {
603 \fontencoding \g_fontspec_encoding_tl
604 \fontfamily \luatexkomainhangulfamily \luatexkoselectfont
605 }
606 \str_if_eq:eeT \familydefault \rmdefault
607 {
608 \cs_set_eq:NN \luatexkodefaulthangulfont \luatexkomainhangulfont
609 \cs_set_eq:NN \luatexkohangulfont \luatexkomainhangulfont
610 \luatexkohangulselectfont
611 }
612 \ignorespaces
613 }
614 \DeclareDocumentCommand \setsanshangulfont { O{} m O{} }
615 {
616 \fontspec_set_family:Nnn \luatexkosanshangulfamily { Ligatures=TeX, #1, #3 } { #2 }
617 \cs_set_protected_nopar:Npn \luatexkosanshangulfont
618 {
619 \fontencoding \g_fontspec_encoding_tl
620 \fontfamily \luatexkosanshangulfamily \luatexkoselectfont
621 }
622 \str_if_eq:eeT \familydefault \sfdefault
623 {
624 \cs_set_eq:NN \luatexkodefaulthangulfont \luatexkosanshangulfont
625 \cs_set_eq:NN \luatexkohangulfont \luatexkosanshangulfont
626 \luatexkohangulselectfont
627 }
628 \ignorespaces
629 }
630 \DeclareDocumentCommand \setmonohangulfont { O{} m O{} }
631 {
632 \fontspec_set_family:Nnn \luatexkomonohangulfamily { #1, #3 } { #2 }
633 \cs_set_protected_nopar:Npn \luatexkomonohangulfont
634 {
635 \fontencoding \g_fontspec_encoding_tl
636 \fontfamily \luatexkomonohangulfamily \luatexkoselectfont
637 }
638 \str_if_eq:eeT \familydefault \ttdefault
639 {
640 \cs_set_eq:NN \luatexkodefaulthangulfont \luatexkomonohangulfont
641 \cs_set_eq:NN \luatexkohangulfont \luatexkomonohangulfont
642 \luatexkohangulselectfont
643 }
644 \ignorespaces
645 }
646 \DeclareDocumentCommand \newhangulfontfamily { m O{} m O{} }
647 {
648 \fontspec_set_family:cnn { luatexko_user_family_ \cs_to_str:N #1 } { #2, #4 } { #3 }
649 \cs_set_protected_nopar:Npn #1
650 {
651 \cs_set_nopar:Npn \luatexkohangulfont
652 {
653 \fontencoding \g_fontspec_encoding_tl
654 \exp_args:Nc \fontfamily { luatexko_user_family_ \cs_to_str:N #1 } \luatexkoselectfont
655 }
656 \luatexkohangulselectfont
657 }
658 \ignorespaces
659 }
660 \DeclareDocumentCommand \newhangulfontface { m O{} m O{} }
661 {
662 \newhangulfontfamily #1 { #3 } [ BoldFont={}, ItalicFont={}, SmallCapsFont={}, #2, #4 ]
663 }
664 \DeclareDocumentCommand \hangulfontspec { O{} m O{} }
665 {
666 \fontspec_set_family:Nnn \luatexkohangulfontfamily { #1, #3 } { #2 }
667 \cs_set_nopar:Npn \luatexkohangulfont
668 {
669 \fontencoding \g_fontspec_encoding_tl
670 \fontfamily \luatexkohangulfontfamily \luatexkoselectfont
671 }
672 \luatexkohangulselectfont
673 \ignorespaces
674 }
675 \DeclareDocumentCommand \setmainhanjafont { O{} m O{} }
676 {
677 \fontspec_set_family:Nnn \luatexkomainhanjafamily { Ligatures=TeX, #1, #3 } { #2 }
678 \cs_set_protected_nopar:Npn \luatexkomainhanjafont
679 {
680 \fontencoding \g_fontspec_encoding_tl
681 \fontfamily \luatexkomainhanjafamily \luatexkoselectfont
682 }
683 \str_if_eq:eeT \familydefault \rmdefault
684 {
685 \cs_set_eq:NN \luatexkodefaulthanjafont \luatexkomainhanjafont
686 \cs_set_eq:NN \luatexkohanjafont \luatexkomainhanjafont
687 \luatexkohanjaselectfont
688 }
689 \ignorespaces
690 }
691 \DeclareDocumentCommand \setsanshanjafont { O{} m O{} }
692 {
693 \fontspec_set_family:Nnn \luatexkosanshanjafamily { Ligatures=TeX, #1, #3 } { #2 }
694 \cs_set_protected_nopar:Npn \luatexkosanshanjafont
695 {
696 \fontencoding \g_fontspec_encoding_tl
697 \fontfamily \luatexkosanshanjafamily \luatexkoselectfont
698 }
699 \str_if_eq:eeT \familydefault \sfdefault
700 {
701 \cs_set_eq:NN \luatexkodefaulthanjafont \luatexkosanshanjafont
702 \cs_set_eq:NN \luatexkohanjafont \luatexkosanshanjafont
703 \luatexkohanjaselectfont
704 }
705 \ignorespaces
706 }
707 \DeclareDocumentCommand \setmonohanjafont { O{} m O{} }
708 {
709 \fontspec_set_family:Nnn \luatexkomonohanjafamily { #1, #3 } { #2 }
710 \cs_set_protected_nopar:Npn \luatexkomonohanjafont
711 {
712 \fontencoding \g_fontspec_encoding_tl
713 \fontfamily \luatexkomonohanjafamily \luatexkoselectfont
714 }
715 \str_if_eq:eeT \familydefault \ttdefault
716 {
717 \cs_set_eq:NN \luatexkodefaulthanjafont \luatexkomonohanjafont
718 \cs_set_eq:NN \luatexkohanjafont \luatexkomonohanjafont
719 \luatexkohanjaselectfont
720 }
721 \ignorespaces
722 }
723 \DeclareDocumentCommand \newhanjafontfamily { m O{} m O{} }
724 {
725 \fontspec_set_family:cnn { luatexko_user_family_ \cs_to_str:N #1 } { #2, #4 } { #3 }
726 \cs_set_protected_nopar:Npn #1
727 {
728 \cs_set_nopar:Npn \luatexkohanjafont
729 {
730 \fontencoding \g_fontspec_encoding_tl
731 \exp_args:Nc \fontfamily { luatexko_user_family_ \cs_to_str:N #1 } \luatexkoselectfont
732 }
733 \luatexkohanjaselectfont
734 }
735 \ignorespaces
736 }
737 \DeclareDocumentCommand \newhanjafontface { m O{} m O{} }
738 {
739 \newhanjafontfamily #1 { #3 } [ BoldFont={}, ItalicFont={}, SmallCapsFont={}, #2, #4 ]
740 }
741 \DeclareDocumentCommand \hanjafontspec { O{} m O{} }
742 {
743 \fontspec_set_family:Nnn \luatexkohanjafontfamily { #1, #3 } { #2 }
744 \cs_set_nopar:Npn \luatexkohanjafont
745 {
746 \fontencoding \g_fontspec_encoding_tl
747 \fontfamily \luatexkohanjafontfamily \luatexkoselectfont
748 }
749 \luatexkohanjaselectfont
750 \ignorespaces
751 }
752
753 \DeclareDocumentCommand \setmainfallbackfont { O{} m O{} }
754 {
755 \fontspec_set_family:Nnn \luatexkomainfallbackfamily { Ligatures=TeX, #1, #3 } { #2 }
756 \cs_set_protected_nopar:Npn \luatexkomainfallbackfont
757 {
758 \fontencoding \g_fontspec_encoding_tl
759 \fontfamily \luatexkomainfallbackfamily \luatexkoselectfont
760 }
761 \str_if_eq:eeT \familydefault \rmdefault
762 {
763 \cs_set_eq:NN \luatexkodefaultfallbackfont \luatexkomainfallbackfont
764 \cs_set_eq:NN \luatexkofallbackfont \luatexkomainfallbackfont
765 \luatexkofallbackselectfont
766 }
767 \ignorespaces
768 }
769 \DeclareDocumentCommand \setsansfallbackfont { O{} m O{} }
770 {
771 \fontspec_set_family:Nnn \luatexkosansfallbackfamily { Ligatures=TeX, #1, #3 } { #2 }
772 \cs_set_protected_nopar:Npn \luatexkosansfallbackfont
773 {
774 \fontencoding \g_fontspec_encoding_tl
775 \fontfamily \luatexkosansfallbackfamily \luatexkoselectfont
776 }
777 \str_if_eq:eeT \familydefault \sfdefault
778 {
779 \cs_set_eq:NN \luatexkodefaultfallbackfont \luatexkosansfallbackfont
780 \cs_set_eq:NN \luatexkofallbackfont \luatexkosansfallbackfont
781 \luatexkofallbackselectfont
782 }
783 \ignorespaces
784 }
785 \DeclareDocumentCommand \setmonofallbackfont { O{} m O{} }
786 {
787 \fontspec_set_family:Nnn \luatexkomonofallbackfamily { #1, #3 } { #2 }
788 \cs_set_protected_nopar:Npn \luatexkomonofallbackfont
789 {
790 \fontencoding \g_fontspec_encoding_tl
791 \fontfamily \luatexkomonofallbackfamily \luatexkoselectfont
792 }
793 \str_if_eq:eeT \familydefault \ttdefault
794 {
795 \cs_set_eq:NN \luatexkodefaultfallbackfont \luatexkomonofallbackfont
796 \cs_set_eq:NN \luatexkofallbackfont \luatexkomonofallbackfont
797 \luatexkofallbackselectfont
798 }
799 \ignorespaces
800 }
801 \DeclareDocumentCommand \newfallbackfontfamily { m O{} m O{} }
802 {
803 \fontspec_set_family:cnn { luatexko_user_family_ \cs_to_str:N #1 } { #2, #4 } { #3 }
804 \cs_set_protected_nopar:Npn #1
805 {
806 \cs_set_nopar:Npn \luatexkofallbackfont
807 {
808 \fontencoding \g_fontspec_encoding_tl
809 \exp_args:Nc \fontfamily { luatexko_user_family_ \cs_to_str:N #1 } \luatexkoselectfont
810 }
811 \luatexkofallbackselectfont
812 }
813 \ignorespaces
814 }
815 \DeclareDocumentCommand \newfallbackfontface { m O{} m O{} }
816 {
817 \newfallbackfontfamily #1 { #3 } [ BoldFont={}, ItalicFont={}, SmallCapsFont={}, #2, #4 ]
818 }
819 \DeclareDocumentCommand \fallbackfontspec { O{} m O{} }
820 {
821 \fontspec_set_family:Nnn \luatexkofallbackfontfamily { #1, #3 } { #2 }
822 \cs_set_nopar:Npn \luatexkofallbackfont
823 {
824 \fontencoding \g_fontspec_encoding_tl
825 \fontfamily \luatexkofallbackfontfamily \luatexkoselectfont
826 }
827 \luatexkofallbackselectfont
828 \ignorespaces
829 }
830 \DeclareDocumentCommand \setmathhangulfont { O{} m O{} }
831 {
832 \fontspec_set_family:Nnn \luatexkomathhangulfamily { #1, #3 } { #2 }
833 \DeclareSymbolFont { mathhangul }
834 \g_fontspec_encoding_tl \luatexkomathhangulfamily \seriesdefault \shapedefault
835 \int_compare:nNnF { \Umathcharfam"AC00 } = { \symmathhangul }
836 {
837 \setmathhangulblock{AC00}{D7A3}
838 }
839 \ignorespaces
840 }
841 \ExplSyntaxOff
842 \let\adhochangulfont\hangulfontspec
843 \let\adhochanjafont\hanjafontspec
844 \let\adhocfallbackfont\fallbackfontspec
845 % interhangul, interlatincjk, charraise
846 \protected\def\addhangulfontfeature#1{%
847 \begingroup
848 \ifdefined\luatexkohangulfont
849 \fontseries\seriesdefault\fontshape\shapedefault \luatexkohangulfont \fi
850 \addfontfeature{#1}%
851 \edef\x{\endgroup
852 \def\noexpand\luatexkohangulfont{%
853 \noexpand\fontencoding{\UTFencname}%
854 \noexpand\fontfamily{\f@family}\noexpand\luatexkoselectfont}}\x
855 \luatexkohangulselectfont
856 \ignorespaces}
857 \let\addhangulfontfeatures\addhangulfontfeature
858 \protected\def\addhanjafontfeature#1{%
859 \begingroup
860 \ifdefined\luatexkohanjafont
861 \fontseries\seriesdefault\fontshape\shapedefault \luatexkohanjafont \fi
862 \addfontfeature{#1}%
863 \edef\x{\endgroup
864 \def\noexpand\luatexkohanjafont{%
865 \noexpand\fontencoding{\UTFencname}%
866 \noexpand\fontfamily{\f@family}\noexpand\luatexkoselectfont}}\x
867 \luatexkohanjaselectfont
868 \ignorespaces}
869 \let\addhanjafontfeatures\addhanjafontfeature
870 \protected\def\addfallbackfontfeature#1{%
871 \begingroup
872 \ifdefined\luatexkofallbackfont
873 \fontseries\seriesdefault\fontshape\shapedefault \luatexkofallbackfont \fi
874 \addfontfeature{#1}%
875 \edef\x{\endgroup
876 \def\noexpand\luatexkofallbackfont{%
877 \noexpand\fontencoding{\UTFencname}%
878 \noexpand\fontfamily{\f@family}\noexpand\luatexkoselectfont}}\x
879 \luatexkofallbackselectfont
880 \ignorespaces}
881 \let\addfallbackfontfeatures\addfallbackfontfeature
882 \newfontfeature{InterHangul}{interhangul=#1}
883 \newfontfeature{InterLatinCJK}{interlatincjk=#1}
884 \newfontfeature{CharRaise}{charraise=#1}
885 \newfontfeature{RemoveClassicSpaces}{+removeclassicspaces}
886 \newfontfeature{CompressPunctuations}{+compresspunctuations}
887 \newfontfeature{Expansion}{expansion=\ifx\empty#1\empty default\else #1\fi }
888 \newfontfeature{Protrusion}{protrusion=\ifx\empty#1\empty default\else #1\fi }
889 \newfontfeature{InterCharacter}{intercharacter=#1}
890 \newfontfeature{InterCharStretch}{intercharstretch=#1}
891 \newfontfeature{InterCharPenalty}{intercharpenalty=#1}
892 % italic correction
893 \def\nocorrlist{,.^^^^3001^^^^3002^^^^ff0c^^^^ff0e^^^^ff61^^^^ff64}
894 % package options
895 \newif\if@hangul
896 \newif\if@hanja
897 \DeclareOption{hangul}{\@hangultrue}
898 \DeclareOption{hanja}{\@hangultrue\@hanjatrue}
899 \ProcessOptions\relax
900 \AtBeginDocument{
901 % default hangul fonts
902 \ifdefined\luatexkomainhangulfont\else
903 \begingroup\rmfamily\expandafter\endgroup
904 \iffontchar\font"AC00 \else
905 \IfFontExistsTF{UnBatang.ttf}
906 {\setmainhangulfont{UnBatang}[Script=Hangul,Language=Korean]}
907 {}
908 \fi
909 \fi
910 \ifdefined\luatexkosanshangulfont\else
911 \begingroup\sffamily\expandafter\endgroup
912 \iffontchar\font"AC00 \else
913 \IfFontExistsTF{UnDotum.ttf}{\setsanshangulfont{UnDotum}}{}
914 \fi
915 \fi
916 \ifdefined\luatexkomonohangulfont\else
917 \begingroup\ttfamily\expandafter\endgroup
918 \iffontchar\font"AC00 \else
919 \def\@tempa{lmtt}\def\@tempb{LatinModernMono(0)}
920 \ifnum 0\ifx\ttdefault\@tempa 1\else\ifx\ttdefault\@tempb 1\fi\fi >\z@
921 \IfFontExistsTF{UnDotum.ttf}
922 {\setmonohangulfont{UnDotum}[
923 UprightFeatures={SizeFeatures={
924 {Size={-8.5}, FakeStretch=1.062},
925 {Size={8.5-11}, FakeStretch=1.05 },
926 {Size={11-}, FakeStretch=1.03 }}},
927 BoldFeatures={SizeFeatures={
928 {Size={-}, FakeStretch=1.05}}},
929 WordSpace={1.66667,0,0}]
930 }
931 {\let\luatexkomonohangulfont\luatexkosanshangulfont }
932 \else
933 \let\luatexkomonohangulfont\luatexkosanshangulfont
934 \fi
935 \fi
936 \fi
937 % just in case, reset luatexkodefault...font
938 \edef\famdef@ult{\familydefault}
939 \ifx\famdef@ult\sfdefault
940 \let\luatexkodefaulthangulfont \luatexkosanshangulfont
941 \let\luatexkodefaulthanjafont \luatexkosanshanjafont
942 \let\luatexkodefaultfallbackfont\luatexkosansfallbackfont
943 \else\ifx\famdef@ult\ttdefault
944 \let\luatexkodefaulthangulfont \luatexkomonohangulfont
945 \let\luatexkodefaulthanjafont \luatexkomonohanjafont
946 \let\luatexkodefaultfallbackfont\luatexkomonofallbackfont
947 \else
948 \let\luatexkodefaulthangulfont \luatexkomainhangulfont
949 \let\luatexkodefaulthanjafont \luatexkomainhanjafont
950 \let\luatexkodefaultfallbackfont\luatexkomainfallbackfont
951 \fi\fi
952 }
953 % hyperref
954 \AddToHook{package/hyperref/after}{\pdfstringdefDisableCommands{%
955 \let\ruby\@firstoftwo
956 \let\xxruby\@firstoftwo
957 \let\dotemph\@firstofone
958 \let\markoverwith\@secondoftwo
959 \let\uline\@firstofone
960 \let\sout\@firstofone
961 \let\uuline\@firstofone
962 \let\xout\@firstofone
963 \let\uwave\@firstofone
964 \let\dashuline\@firstofone
965 \let\dotuline\@firstofone
966 \let\typesetclassic\empty
967 \let\typesetmodern\empty
968 \let\inhibitglue\empty
969 \let\hangulpunctuations\count@
970 \let\registerpunctuations\@gobble
971 \let\unregisterpunctuations\@gobble
972 \let\registerhangulpunctuations\@gobble
973 \let\unregisterhangulpunctuations\@gobble
974 \let\registerbreakableafter\@gobble
975 \let\registerbreakablebefore\@gobble
976 \let\hangulbyhangulfont\count@
977 \let\hanjabyhanjafont\count@
978 \let\addhangulfontfeature\@gobble
979 \let\addhangulfontfeatures\@gobble
980 \let\addhanjafontfeature\@gobble
981 \let\addhanjafontfeatures\@gobble
982 \let\addfallbackfontfeature\@gobble
983 \let\addfallbackfontfeatures\@gobble
984 \def\는{는}\def\은{은}\def\을{을}\def\를{를}\def\와{와}\def\과{과}%
985 \def\가{가}\def\이{이}\def\라{라}\def\으{으}\def\로{로}%
986 \def\hellipsis{...}}}
987 \AddToHook{package/pxrubrica/after}{\let\ruby\jruby}
988 % misc
989 \RequirePackage{kolabels-utf}
990 \protected\def\hellipsis{\char"2026\char"2026 }
991 \if@hangul
992 \RequirePackage{konames-utf}
993 \linespread{1.38889}
994 \footnotesep=1.38889\footnotesep
995 \skip\footins=\glueexpr\skip\footins/72*100\relax
996 \frenchspacing
997 \fi
998 %%% Tagged PDF
999 \ifcsname [email protected]\endcsname\else \endinput\fi
1000 \ExplSyntaxOn
1001 \socket_new:nn{tagsupport/luatexko/artifact/begin}{0}
1002 \socket_new:nn{tagsupport/luatexko/artifact/end}{0}
1003 \socket_new_plug:nnn{tagsupport/luatexko/artifact/begin}{default}
1004 {
1005 \tag_mc_end:
1006 \tag_mc_begin:n{artifact}
1007 }
1008 \socket_new_plug:nnn{tagsupport/luatexko/artifact/end}{default}
1009 {
1010 \tag_mc_end:
1011 \tag_mc_begin:n{}
1012 }
1013 \socket_assign_plug:nn{tagsupport/luatexko/artifact/begin}{default}
1014 \socket_assign_plug:nn{tagsupport/luatexko/artifact/end}{default}
1015 % dotemph
1016 \socket_new:nn{tagsupport/luatexko/dotemph/begin}{0}
1017 \socket_new:nn{tagsupport/luatexko/dotemph/end}{0}
1018 \socket_new_plug:nnn{tagsupport/luatexko/dotemph/begin}{default}
1019 {
1020 \leavevmode
1021 \tag_mc_end_push:
1022 \tag_struct_begin:n{tag=Strong}
1023 \tag_mc_begin:n{}
1024 }
1025 \socket_new_plug:nnn{tagsupport/luatexko/dotemph/end}{default}
1026 {
1027 \tag_mc_end:
1028 \tag_struct_end:
1029 \tag_mc_begin_pop:n{}
1030 }
1031 \socket_assign_plug:nn{tagsupport/luatexko/dotemph/begin}{default}
1032 \socket_assign_plug:nn{tagsupport/luatexko/dotemph/end}{default}
1033 \AddToHook{cmd/dotemph/before}
1034 {
1035 \tag_socket_use:n{luatexko/dotemph/begin}
1036 }
1037 \AddToHook{cmd/dotemph/after}
1038 {
1039 \tag_socket_use:n{luatexko/dotemph/end}
1040 }
1041 \AddToHook{cmd/luatexkodotemphchar/before}
1042 {
1043 \tag_socket_use:n{luatexko/artifact/begin}
1044 \tag_suspend:n\dotemph
1045 }
1046 \AddToHook{cmd/luatexkodotemphchar/after}
1047 {
1048 \tag_resume:n\dotemph
1049 \tag_socket_use:n{luatexko/artifact/end}
1050 }
1051 % uline etc.
1052 \tagpdfsetup
1053 {
1054 role/new-tag = StrikeOut/Span,
1055 role/new-attribute = {TextDeco-underline}{/O~/Layout~/TextDecorationType~(Underline)},
1056 role/new-attribute = {TextDeco-strikeout}{/O~/Layout~/TextDecorationType~(LineThrough)},
1057 }
1058 \socket_new:nn{tagsupport/luatexko/markoverwith/begin}{0}
1059 \socket_new:nn{tagsupport/luatexko/markoverwith/end}{0}
1060 \socket_new_plug:nnn{tagsupport/luatexko/markoverwith/begin}{underline}
1061 {
1062 \leavevmode
1063 \tag_mc_end_push:
1064 \tag_struct_begin:n{tag=Em, attribute=TextDeco-underline}
1065 \tag_mc_begin:n{}
1066 }
1067 \socket_new_plug:nnn{tagsupport/luatexko/markoverwith/begin}{strikeout}
1068 {
1069 \leavevmode
1070 \tag_mc_end_push:
1071 \tag_struct_begin:n{tag=StrikeOut, attribute=TextDeco-strikeout}
1072 \tag_mc_begin:n{}
1073 }
1074 \socket_new_plug:nnn{tagsupport/luatexko/markoverwith/begin}{doubleunderline}
1075 {
1076 \leavevmode
1077 \tag_mc_end_push:
1078 \tag_struct_begin:n{tag=Em, attribute=TextDeco-underline}
1079 \tag_struct_begin:n{tag=Em, attribute=TextDeco-underline}
1080 \tag_mc_begin:n{}
1081 }
1082 \socket_new_plug:nnn{tagsupport/luatexko/markoverwith/end}{common}
1083 {
1084 \tag_mc_end:
1085 \tag_struct_end:
1086 \tag_mc_begin_pop:n{}
1087 }
1088 \socket_new_plug:nnn{tagsupport/luatexko/markoverwith/end}{doubleunderline}
1089 {
1090 \tag_mc_end:
1091 \tag_struct_end:
1092 \tag_struct_end:
1093 \tag_mc_begin_pop:n{}
1094 }
1095 \socket_assign_plug:nn{tagsupport/luatexko/markoverwith/begin}{underline}
1096 \socket_assign_plug:nn{tagsupport/luatexko/markoverwith/end}{common}
1097 \cs_set_eq:NN \luatexko_markoverwith_original:nn \luatexkomarkoverwith
1098 \RenewDocumentCommand\luatexkomarkoverwith{ m m }
1099 {
1100 \tag_socket_use:n{luatexko/markoverwith/begin}
1101 \luatexko_markoverwith_original:nn
1102 {
1103 \tag_socket_use:n{luatexko/artifact/begin}
1104 \tag_suspend:n\markoverwith
1105 #1
1106 \tag_resume:n\markoverwith
1107 \tag_socket_use:n{luatexko/artifact/end}
1108 }
1109 {
1110 #2
1111 }
1112 \tag_socket_use:n{luatexko/markoverwith/end}
1113 }
1114 \AddToHook{cmd/uuline/before}
1115 {
1116 \begingroup
1117 \socket_assign_plug:nn{tagsupport/luatexko/markoverwith/begin}{doubleunderline}
1118 \socket_assign_plug:nn{tagsupport/luatexko/markoverwith/end}{doubleunderline}
1119 \AddToHookNext{cmd/luatexkomarkoverwith/after}{\endgroup}
1120 }
1121 \AddToHook{cmd/sout/before}
1122 {
1123 \begingroup
1124 \socket_assign_plug:nn{tagsupport/luatexko/markoverwith/begin}{strikeout}
1125 \AddToHookNext{cmd/luatexkomarkoverwith/after}{\endgroup}
1126 }
1127 \AddToHook{cmd/xout/before}
1128 {
1129 \begingroup
1130 \socket_assign_plug:nn{tagsupport/luatexko/markoverwith/begin}{strikeout}
1131 \AddToHookNext{cmd/luatexkomarkoverwith/after}{\endgroup}
1132 }
1133 % ruby
1134 \socket_new:nn{tagsupport/luatexko/ruby/begin}{0}
1135 \socket_new:nn{tagsupport/luatexko/ruby/end}{0}
1136 \socket_new:nn{tagsupport/luatexko/ruby/text/begin}{1}
1137 \socket_new:nn{tagsupport/luatexko/ruby/text/end}{0}
1138 \socket_new_plug:nnn{tagsupport/luatexko/ruby/begin}{default}
1139 {
1140 \leavevmode
1141 \tag_mc_end_push:
1142 \tag_struct_begin:n{tag=Ruby}
1143 }
1144 \socket_new_plug:nnn{tagsupport/luatexko/ruby/end}{default}
1145 {
1146 \tag_struct_end:
1147 \tag_mc_begin_pop:n{}
1148 }
1149 \socket_new_plug:nnn{tagsupport/luatexko/ruby/text/begin}{default}
1150 {
1151 \tag_struct_begin:n{tag=#1}
1152 \tag_mc_begin:n{}
1153 }
1154 \socket_new_plug:nnn{tagsupport/luatexko/ruby/text/end}{default}
1155 {
1156 \tag_mc_end:
1157 \tag_struct_end:
1158 }
1159 \socket_assign_plug:nn{tagsupport/luatexko/ruby/begin}{default}
1160 \socket_assign_plug:nn{tagsupport/luatexko/ruby/end}{default}
1161 \socket_assign_plug:nn{tagsupport/luatexko/ruby/text/begin}{default}
1162 \socket_assign_plug:nn{tagsupport/luatexko/ruby/text/end}{default}
1163 \cs_set_eq:NN \luatexko_ruby_original:nn \ruby
1164 \RenewDocumentCommand\ruby{ m m }
1165 {
1166 \tag_socket_use:n{luatexko/ruby/begin}
1167 \luatexko_ruby_original:nn
1168 {
1169 \tag_socket_use:nn{luatexko/ruby/text/begin}{RB}
1170 #1
1171 \tag_socket_use:n{luatexko/ruby/text/end}
1172 }
1173 {
1174 \tag_socket_use:nn{luatexko/ruby/text/begin}{RT}
1175 #2
1176 \tag_socket_use:n{luatexko/ruby/text/end}
1177 }
1178 \tag_socket_use:n{luatexko/ruby/end}
1179 }
1180 % vertical environment
1181 \tagpdfsetup{
1182 role/new-tag = Vertical/Div,
1183 role/new-tag = Horizontal/Div,
1184 role/new-attribute = {WritingMode-TbRl}{/O~/Layout~/WritingMode~(TbRl)},
1185 role/new-attribute = {WritingMode-LrTb}{/O~/Layout~/WritingMode~(LrTb)},
1186 }
1187 \socket_new:nn{tagsupport/luatexko/writingmode/begin}{1}
1188 \socket_new:nn{tagsupport/luatexko/writingmode/end}{0}
1189 \socket_new_plug:nnn{tagsupport/luatexko/writingmode/begin}{inline}
1190 {
1191 \tag_mc_end_push:
1192 \tag_struct_begin:n{tag=Span, attribute=WritingMode-#1}
1193 \tag_mc_begin:n{}
1194 }
1195 \socket_new_plug:nnn{tagsupport/luatexko/writingmode/end}{inline}
1196 {
1197 \tag_mc_end:
1198 \tag_struct_end:
1199 \tag_mc_begin_pop:n{}
1200 }
1201 \socket_new_plug:nnn{tagsupport/luatexko/writingmode/begin}{block}
1202 {
1203 \tag_mc_end_push:
1204 \str_if_eq:nnTF {#1} {TbRl}
1205 { \tag_struct_begin:n{tag=Vertical, attribute=WritingMode-#1} }
1206 { \tag_struct_begin:n{tag=Horizontal, attribute=WritingMode-#1} }
1207 }
1208 \socket_new_plug:nnn{tagsupport/luatexko/writingmode/end}{block}
1209 {
1210 \tag_struct_end:
1211 \tag_mc_begin_pop:n{}
1212 }
1213 \socket_assign_plug:nn{tagsupport/luatexko/writingmode/begin}{block}
1214 \socket_assign_plug:nn{tagsupport/luatexko/writingmode/end}{block}
1215 \socket_new_plug:nnn{tagsupport/minipage/before}{luatexko/vertical}
1216 {
1217 \tag_mc_end_push:
1218 \bool_if:NT \l__tag_para_bool {\tag_struct_end:}
1219 \tag_struct_begin:n{tag=Vertical, attribute=WritingMode-TbRl}
1220 }
1221 \socket_new_plug:nnn{tagsupport/minipage/before}{luatexko/horizontal}
1222 {
1223 \tag_mc_end_push:
1224 \bool_if:NT \l__tag_para_bool {\tag_struct_end:}
1225 \tag_struct_begin:n{tag=Horizontal, attribute=WritingMode-LrTb}
1226 }
1227 \RenewDocumentEnvironment{vertical}{m}
1228 {
1229 \leavevmode
1230 \ifx\empty#1\empty
1231 \socket_assign_plug:nn{tagsupport/luatexko/writingmode/begin}{inline}
1232 \socket_assign_plug:nn{tagsupport/luatexko/writingmode/end}{inline}
1233 \setbox\z@\hbox\bgroup
1234 \tag_socket_use:nn{luatexko/writingmode/begin}{TbRl}
1235 \else
1236 \socket_assign_plug:nn{tagsupport/minipage/before}{luatexko/vertical}
1237 \begin{minipage}[b]{#1}
1238 \fi
1239 \typesetvertical
1240 }
1241 {
1242 \ifx\empty#1\empty
1243 \tag_socket_use:n{luatexko/writingmode/end}
1244 \egroup
1245 \else
1246 \end{minipage}
1247 \setbox\z@\lastbox
1248 \fi
1249 \tag_socket_use:n{luatexko/artifact/begin}
1250 \luatexkorotatebox\z@
1251 \tag_socket_use:n{luatexko/artifact/end}
1252 \box\z@
1253 }
1254 % horizontal environment
1255 \RenewDocumentEnvironment{horizontal}{m}
1256 {
1257 \directlua{ luatexko.gethorizboxmoveright() }
1258 \leavevmode
1259 \ifx\empty#1\empty
1260 \socket_assign_plug:nn{tagsupport/luatexko/writingmode/begin}{inline}
1261 \socket_assign_plug:nn{tagsupport/luatexko/writingmode/end}{inline}
1262 \setbox\z@\hbox\bgroup
1263 \tag_socket_use:nn{luatexko/writingmode/begin}{LrTb}
1264 \else
1265 \socket_assign_plug:nn{tagsupport/minipage/before}{luatexko/horizontal}
1266 \begin{minipage}[b]{#1}
1267 \fi
1268 \typesetmodern
1269 }
1270 {
1271 \ifx\empty#1\empty
1272 \tag_socket_use:n{luatexko/writingmode/end}
1273 \egroup
1274 \else
1275 \end{minipage}
1276 \setbox\z@\lastbox
1277 \fi
1278 \tag_socket_use:n{luatexko/artifact/begin}
1279 \luatexkounrotatebox\z@
1280 \tag_socket_use:n{luatexko/artifact/end}
1281 \raise\luatexkohorizboxmoveright
1282 \box\z@
1283 }
1284 % verticaltypesetting
1285 \AddToHook{cmd/verticaltypesetting/after}
1286 {
1287 \tag_socket_use:nn{luatexko/writingmode/begin}{TbRl}
1288 }
1289 \AddToHook{cmd/endverticaltypesetting/before}
1290 {
1291 \tag_socket_use:n{luatexko/writingmode/end}
1292 }
1293 \AddToHookNext{begindocument/end}
1294 {
1295 \cs_if_eq:NNT \verticaltypesetting \relax % whole document is vertical
1296 {
1297 \tag_struct_gput:nnn{\tag_get:n{struct_num}}{attribute}{/O~/Layout~/WritingMode~(TbRl)}
1298 }
1299 }
1300 \ExplSyntaxOff
1301 \endinput