summaryrefslogtreecommitdiff
path: root/macros/luatex/generic/luatexko/luatexko.sty
diff options
context:
space:
mode:
Diffstat (limited to 'macros/luatex/generic/luatexko/luatexko.sty')
-rw-r--r--macros/luatex/generic/luatexko/luatexko.sty344
1 files changed, 184 insertions, 160 deletions
diff --git a/macros/luatex/generic/luatexko/luatexko.sty b/macros/luatex/generic/luatexko/luatexko.sty
index c44ccedcbe..b3f78f4ba4 100644
--- a/macros/luatex/generic/luatexko/luatexko.sty
+++ b/macros/luatex/generic/luatexko/luatexko.sty
@@ -12,9 +12,9 @@
% version 2006/05/20 or later.
\ifdefined\luatexkohangulfontattr \endinput\fi
-\ifdefined\selectfont
- \NeedsTeXFormat{LaTeX2e}[2020/10/01]
- \ProvidesPackage{luatexko}[2021/04/20 v3.1 typesetting Korean with LuaTeX]
+\ifdefined\ProvidesPackage
+ \NeedsTeXFormat{LaTeX2e}[2021/06/01]
+ \ProvidesPackage{luatexko}[2021/06/10 v3.2 typesetting Korean with LuaTeX]
\RequirePackage{luatexbase}
\RequirePackage{fontspec}[2020/02/03]
\else
@@ -25,52 +25,43 @@
\catcode`\@=11
\fi
\newlanguage\koreanlanguage
-\protected\def\pdfliteral{\pdfextension literal}
\newattribute\luatexkohangulfontattr
\newattribute\luatexkohanjafontattr
\newattribute\luatexkofallbackfontattr
\newattribute\luatexkoautojosaattr
\newattribute\luatexkoclassicattr
\newattribute\luatexkodotemphattr
-\newattribute\luatexkoulineattr
\newattribute\luatexkorubyattr \chardef\luatexkorubyalloc\allocationnumber
\newattribute\luatexkohangulbyhangulattr
\newattribute\luatexkohanjabyhanjaattr
\directlua{ require"luatexko" }
-\ifdefined\AtBegShi@Hook
- \edef\AtBegShi@Hook{% occupy the first position
- \unexpanded{%
- \AtBegShi@Item{%
- \directlua{%
- luatexko.process_atbegshi(tex.getbox(\the\AtBeginShipoutBox))
- }%
- }%
- }%
- \unexpanded\expandafter{\AtBegShi@Hook}%
- }
-\else
- \AddToHook{shipout/before}{%
- \directlua{ luatexko.process_atbegshi(tex.getbox(\the\ShipoutBox)) }%
- }
- \DeclareHookRule{shipout/before}{.}{before}{luacolor}
-\fi
-% classic
-\protected\def\typesetclassic{% 0
+% classics
+% 0: horizontal KO, JP
+% 1: vertical KO, SC
+% 2: horizontal SC
+% 3: horizontal TC
+% 4: vertical TC
+% 5: vertical JP
+\chardef\luatexkolangCJK=\z@ % 0:KO, 1:JP, 2:SC, 3:TC
+\protected\def\typesetclassic{%
\ifnum\luatexkoclassicattr<\z@
\luatexkoclassicattr\z@
\parindent1em
\fi
}
-\protected\def\typesetvertical{% 1
- \ifcase\luatexkoclassicattr
+\protected\def\typesetvertical{% 1, 4, 5
+ \ifcase\luatexkolangCJK
\luatexkoclassicattr\@ne
\parindent1em
\or
+ \luatexkoclassicattr=5\relax
+ \parindent1em
\or
\luatexkoclassicattr\@ne
+ \parindent2em
\or
\luatexkoclassicattr=4\relax
- \or
+ \parindent2em
\else
\luatexkoclassicattr\@ne
\parindent1em
@@ -78,7 +69,25 @@
}
\protected\def\typesetmodern{\unsetattribute\luatexkoclassicattr}
\protected\def\inhibitglue{\hskip\z@skip}
+\protected\def\japanese{% 0, 5
+ \chardef\luatexkolangCJK=\@ne
+ \ifcase\luatexkoclassicattr
+ \or
+ \luatexkoclassicattr=5\relax
+ \or
+ \luatexkoclassicattr\z@
+ \or
+ \luatexkoclassicattr\z@
+ \or
+ \luatexkoclassicattr=5\relax
+ \or
+ \else
+ \luatexkoclassicattr\z@
+ \fi
+ \parindent1em
+ }
\protected\def\Schinese{% 2, 1
+ \chardef\luatexkolangCJK=\tw@
\ifcase\luatexkoclassicattr
\luatexkoclassicattr\tw@
\or
@@ -87,12 +96,15 @@
\luatexkoclassicattr\tw@
\or
\luatexkoclassicattr\@ne
+ \or
+ \luatexkoclassicattr\@ne
\else
\luatexkoclassicattr\tw@
\fi
\parindent2em
}
\protected\def\Tchinese{% 3, 4
+ \chardef\luatexkolangCJK=\thr@@
\ifcase\luatexkoclassicattr
\luatexkoclassicattr\thr@@
\or
@@ -101,12 +113,14 @@
\luatexkoclassicattr\thr@@
\or
\or
+ \or
+ \luatexkoclassicattr=4\relax
\else
\luatexkoclassicattr\thr@@
\fi
\parindent2em
}
-\let\korean\typesetmodern \let\japanese\typesetclassic \let\chinese\Schinese
+\let\korean\typesetmodern \let\chinese\Schinese
% josa
\count@"AC00
\loop
@@ -189,19 +203,16 @@
% dotemph
\newcount\luatexkodotemphcount
\def\dotemphraise{1ex }
-\unless\ifdefined\bfseries\let\bfseries\bf\fi
-\def\dotemphchar{\bfseries\char"02D9 }
+\edef\dotemphchar{\expandafter\noexpand\ifdefined\bfseries\bfseries\else\bf\fi ^^^^02d9}
\protected\def\dotemph#1{%
\global\advance\luatexkodotemphcount\@ne
+ \ifnum\luatexkodotemphcount=\@ne \directlua{ luatexko.activate"dotemph" }\fi
\begingroup
+ \count@=\luatexkodotemphcount
\setbox\z@\hbox{\raise\dotemphraise\hbox{\dotemphchar}}%
- \directlua{
- if \the\luatexkodotemphcount == 1 then luatexko.activate("dotemph") end
- luatexko.dotemphbox[\the\luatexkodotemphcount] = node.copy(tex.box[0])
- }\luatexkodotemphattr\luatexkodotemphcount #1%
- \directlua{
- luatexko.dotemphboundary(\the\luatexkodotemphattr)
- }%
+ \directlua{ luatexko.dotemphbox[\number\count@] = node.copy(tex.box[0]) }%
+ \luatexkodotemphattr\count@ #1\relax
+ \directlua{ luatexko.dotemphboundary(\number\count@) }%
\endgroup }
% uline
\newcount\luatexkoulinecount
@@ -215,19 +226,15 @@
\luatexkomarkoverwith }
\def\luatexkomarkoverwith#1#2{%
\global\advance\luatexkoulinecount\@ne
+ \ifnum\luatexkoulinecount=\@ne \directlua{ luatexko.activate"uline" }\fi
\begingroup
+ \count@=\luatexkoulinecount
\leavevmode
\setbox\z@\hbox{#1}%
- \directlua{
- if \the\luatexkoulinecount == 1 then luatexko.activate("uline") end
- luatexko.ulboundary(\the\luatexkoulinecount,
- tex.box[0].list,
- \luatexkoleaderstype)
- }%
- \luatexkoulineattr\luatexkoulinecount #2\relax
- \directlua{
- luatexko.ulboundary(\the\luatexkoulineattr)
- }\endgroup }
+ \directlua{ luatexko.ulboundary(\number\count@, tex.box[0].list, \luatexkoleaderstype) }%
+ #2\relax
+ \directlua{ luatexko.ulboundary(\number\count@) }%
+ \endgroup }
\protected\def\uline{\markoverwith{%
\vrule width\z@ height-\ulinedown depth\dimexpr\ulinedown+\ulinewidth\relax }}
\protected\def\dashuline{\markoverwith*{%
@@ -271,15 +278,16 @@
\let\rubynooverlap\ruby@overlapfalse
\rubyoverlap % ruby may hangover neighboring chars
\newcount\luatexkorubycount
-\def\luatexkorubybasehbox{\hbox attr\luatexkorubyalloc=\luatexkorubycount}
\protected\def\ruby#1#2{%
\global\advance\luatexkorubycount\@ne
+ \ifnum\luatexkorubycount=\@ne \directlua{ luatexko.activate"ruby" }\fi
\begingroup
+ \count@=\luatexkorubycount
\leavevmode
- \setbox\z@\luatexkorubybasehbox{#1}% base
+ \setbox\z@\hbox attr\luatexkorubyalloc=\count@{#1}% base
\setbox\tw@\hbox{% ruby
\ifdefined\rubyfont \rubyfont \fi
- \ifdefined\selectfont % <- latex
+ \ifcsname ver@luatexko.sty\endcsname % <- latex
\dimen@\dimexpr\rubysize em\relax
\fontsize\dimen@\dimen@\selectfont
\fi
@@ -291,13 +299,13 @@
\ifruby@overlap
\dimen@\dimexpr\wd\tw@-\wd\z@-\dimen@ii\relax % overhang .5 rubysize
\ifdim\dimen@ > \z@
- \setbox\z@\luatexkorubybasehbox spread\dimen@{%
+ \setbox\z@\hbox attr\luatexkorubyalloc=\count@ spread\dimen@{%
\hskip\z@ plus \luatexkostretchfactor em\relax
\unhbox\z@
\hskip\z@ plus \luatexkostretchfactor em\relax }%
\fi
\else
- \setbox\z@\luatexkorubybasehbox to\wd\tw@{%
+ \setbox\z@\hbox attr\luatexkorubyalloc=\count@ to\wd\tw@{%
\hskip\z@ plus \luatexkostretchfactor em\relax
\unhbox\z@
\hskip\z@ plus \luatexkostretchfactor em\relax }%
@@ -316,8 +324,7 @@
\fi
\fi
\directlua{
- if \the\luatexkorubycount == 1 then luatexko.activate("ruby") end
- luatexko.rubybox[\the\luatexkorubycount] = {
+ luatexko.rubybox[\number\count@] = {
node.copy(tex.box[2]),
\number\numexpr\dimexpr\rubysep\relax\relax,
\ifruby@overlap true\else false\fi, }}%
@@ -337,56 +344,62 @@
% vertical writing
\protected\def\vertical#1{%
\leavevmode
- \setbox\z@\vbox\bgroup
- \hsize#1\relax
- \typesetvertical }
+ \ifx\empty#1\empty
+ \setbox\z@\hbox\bgroup
+ \else
+ \setbox\z@\vbox\bgroup \hsize#1\relax
+ \fi
+ \typesetvertical }
\protected\def\endvertical{%
\egroup
\luatexkorotatebox\z@
\box\z@ }
\protected\def\luatexkorotatebox#1{%
- \setbox#1\hbox to\dimexpr\ht#1+\dp#1{%
+ \dimen@\dimexpr\ht#1+\dp#1\relax
+ \setbox#1\hbox to\dimen@\bgroup
\hfil
- \vbox to\wd#1{%
- \wd#1\z@ \ht#1\z@ \dp#1\z@
- \pdfliteral{q 0 -1 1 0 0 0 cm}\box#1\pdfliteral{Q}%
- \vfil }}}
+ \vbox to\wd#1\bgroup
+ \wd#1\z@
+ \pdfextension save\relax
+ \pdfextension setmatrix{0 -1 1 0}\relax
+ \box#1\relax
+ \kern-\dimen@
+ \pdfextension restore\relax
+ \vfil
+ \egroup
+ \egroup
+}
% horizontal box inside vertical writing
\def\luatexkohorizboxmoveright{0.5ex}
\protected\def\horizontal#1{%
\directlua{ luatexko.gethorizboxmoveright() }%
\leavevmode
- \setbox\z@\vbox\bgroup
- \hsize#1\relax
- \typesetmodern }
+ \ifx\empty#1\empty
+ \setbox\z@\hbox\bgroup
+ \else
+ \setbox\z@\vbox\bgroup \hsize#1\relax
+ \fi
+ \typesetmodern }
\protected\def\endhorizontal{%
\egroup
- \dimen@=\dimexpr.5\wd\z@-\luatexkohorizboxmoveright\relax
\luatexkounrotatebox\z@
- \lower\dimen@\box\z@ }
+ \raise\luatexkohorizboxmoveright
+ \box\z@ }
\protected\def\luatexkounrotatebox#1{%
- \setbox#1\hbox to\dimexpr\ht#1+\dp#1{%
- \vbox to\wd#1{%
+ \dimen@\dimexpr\ht#1+\dp#1\relax
+ \setbox#1\hbox to\dimen@\bgroup
+ \lower.5\wd#1\vbox to\wd#1\bgroup
\vfil
- \wd#1\z@ \ht#1\z@ \dp#1\z@
- \pdfliteral{q 0 1 -1 0 0 0 cm}\box#1\pdfliteral{Q}}%
- \hfil }}
-% do not veticalize headline/footline
-\ifdefined\selectfont
- \def\verticaltypesetting{%
- \maxdepth\z@ \typesetvertical
- \dimen@\textwidth \textwidth\textheight \textheight\dimen@
- \edef\@outputpage{\unexpanded{\luatexkorotatebox\@outputbox
- \textwidth\textheight}\unexpanded\expandafter{\@outputpage}}}
-\else
- \def\verticaltypesetting{%
- \dimen@\hsize \hsize\vsize \vsize\dimen@
- \edef\plainoutput{\unexpanded{\dimen@\hsize \hsize\vsize \vsize\dimen@}%
- \unexpanded\expandafter{\plainoutput}}%
- \def\pagebody{\setbox\z@\vbox to\hsize{\boxmaxdepth=\maxdepth
- \pagecontents}\luatexkorotatebox\z@\box\z@}%
- \maxdepth\z@ \typesetvertical }
-\fi
+ \wd#1\z@
+ \pdfextension save\relax
+ \pdfextension setmatrix{0 1 -1 0}\relax
+ \box#1\relax
+ \kern-\dimen@
+ \pdfextension restore\relax
+ \egroup
+ \hfil
+ \egroup
+}
% hangul normalize
\def\luatexhangulnormalize{%
\directlua{require"luatexko-normalize"}%
@@ -443,16 +456,51 @@
\fi
\fi }
% plain
-\ifdefined\selectfont\else
+\ifcsname ver@luatexko.sty\endcsname\else
+ % do not verticalize headline/footline.
+ \def\verticaltypesetting{%
+ \dimen@\hsize \hsize\vsize \vsize\dimen@
+ \edef\plainoutput{\dimen@\hsize \hsize\vsize \vsize\dimen@
+ \unexpanded\expandafter{\plainoutput}}%
+ \def\pagebody{\setbox\z@\vbox to\hsize{\boxmaxdepth=\maxdepth \pagecontents}%
+ \luatexkorotatebox\z@\box\z@}%
+ \maxdepth\z@ \typesetvertical
+ \let\verticaltypesetting\relax % prevent multiple running
+ }
+ \def\beginverticaltypesetting{\vfill\supereject \begingroup \verticaltypesetting}
+ \def\endverticaltypesetting{\vfill\supereject \endgroup}
+ % hangul fonts
\protected\def\hangulfont{%
\afterassignment\luatexkohangulselectfont\font\luatexkohangulfont}
\protected\def\hanjafont{%
\afterassignment\luatexkohanjaselectfont\font\luatexkohanjafont}
\protected\def\fallbackfont{%
\afterassignment\luatexkofallbackselectfont\font\luatexkofallbackfont}
- \newfam\symmathhangul
+ \def\sethangulfont#1{%
+ \def\@tempa{#1}\edef\@tempb{\csstring#1}%
+ \expandafter\afterassignment\expandafter\luatexko@sethangulfont
+ \expandafter\font\csname luatexko.hangulfont.\@tempb\endcsname }
+ \def\luatexko@sethangulfont{%
+ \expandafter\protected\expandafter\edef\@tempa{%
+ \luatexkohangulfontattr\fontid\csname luatexko.hangulfont.\@tempb\endcsname\relax }}
+ \def\sethanjafont#1{%
+ \def\@tempa{#1}\edef\@tempb{\csstring#1}%
+ \expandafter\afterassignment\expandafter\luatexko@sethanjafont
+ \expandafter\font\csname luatexko.hanjafont.\@tempb\endcsname }
+ \def\luatexko@sethanjafont{%
+ \expandafter\protected\expandafter\edef\@tempa{%
+ \luatexkohanjafontattr\fontid\csname luatexko.hanjafont.\@tempb\endcsname\relax }}
+ \def\setfallbackfont#1{%
+ \def\@tempa{#1}\edef\@tempb{\csstring#1}%
+ \expandafter\afterassignment\expandafter\luatexko@setfallbackfont
+ \expandafter\font\csname luatexko.fallbackfont.\@tempb\endcsname }
+ \def\luatexko@setfallbackfont{%
+ \expandafter\protected\expandafter\edef\@tempa{%
+ \luatexkofallbackfontattr\fontid\csname luatexko.fallbackfont.\@tempb\endcsname\relax }}
+ \hangulfont={UnBatang:mode=node;script=hang;+tlig} at 10pt % default: unbatang
\protected\def\setmathhangulfonts#1#2#3{% font identifiers
- \ifnum\Umathcharfam"AC00=\symmathhangul\else
+ \ifnum\Umathcodenum"AC00="AC00\relax
+ \csname newfam\endcsname\symmathhangul
\setmathhangulblock{AC00}{D7A3}%
\fi
\textfont\symmathhangul=#1\relax
@@ -471,17 +519,41 @@
\catcode`\@=\luatexkoatcatcode
\endinput\fi
% latex
-\IfHookExistsTF{selectfont}{
- \AddToHook{selectfont}{%
- \luatexkohangulselectfont
- \luatexkohanjaselectfont
- \luatexkofallbackselectfont }
-}{
- \RequirePackage{everysel}
- \EverySelectfont{%
- \luatexkohangulselectfont
- \luatexkohanjaselectfont
- \luatexkofallbackselectfont }
+% do not verticalize headline/footline
+\def\verticaltypesetting{%
+ \ifx\@nodocument\relax % not in the preamble
+ \clearpage
+ \begingroup
+ \fi
+ \hsize\textheight \vsize\textwidth
+ \textwidth\hsize \textheight\vsize
+ \@colroom\vsize \@colht\vsize
+ \if@twocolumn
+ \columnwidth=.5\dimexpr\textwidth-\columnsep\relax
+ \linewidth\columnwidth \hsize\columnwidth
+ \else
+ \linewidth\hsize \columnwidth\hsize
+ \fi
+ \expandafter\def\expandafter\@outputpage\expandafter{%
+ \expandafter\luatexkorotatebox\expandafter\@outputbox
+ \expandafter\textwidth\expandafter\textheight
+ \@outputpage
+ }%
+ \maxdepth\z@ \typesetvertical
+ \let\verticaltypesetting\relax % prevent multiple running
+}
+\def\endverticaltypesetting{%
+ \clearpage
+ \endgroup
+ \global\@colroom\textheight
+ \global\@colht\textheight
+ \global\vsize\textheight
+}
+% hangul fonts
+\AddToHook{selectfont}{%
+ \luatexkohangulselectfont
+ \luatexkohanjaselectfont
+ \luatexkofallbackselectfont
}
\AddToHook{rmfamily}{%
\let\luatexkohangulfont \luatexkomainhangulfont
@@ -505,26 +577,9 @@
}
% fontspec-like
\ExplSyntaxOn
-\cs_new_nopar:Npn \l_luatexko_silent_upshape {
- \tl_map_inline:nn { \mddefault \bfdefault }
- {
- \cs_if_exist:cF
- { \g_fontspec_encoding_tl/\l_fontspec_family_tl/##1/\updefault }
- {
- \cs_if_exist:cT
- { \g_fontspec_encoding_tl/\l_fontspec_family_tl/##1/\shapedefault }
- {
- \cs_set_eq:cc
- { \g_fontspec_encoding_tl/\l_fontspec_family_tl/##1/\updefault }
- { \g_fontspec_encoding_tl/\l_fontspec_family_tl/##1/\shapedefault }
- }
- }
- }
-}
\DeclareDocumentCommand \setmainhangulfont { O{} m O{} }
{
\fontspec_set_family:Nnn \luatexkomainhangulfamily { Ligatures=TeX, #1, #3 } { #2 }
- \l_luatexko_silent_upshape
\cs_set_protected_nopar:Npn \luatexkomainhangulfont
{
\fontencoding \g_fontspec_encoding_tl
@@ -541,7 +596,6 @@
\DeclareDocumentCommand \setsanshangulfont { O{} m O{} }
{
\fontspec_set_family:Nnn \luatexkosanshangulfamily { Ligatures=TeX, #1, #3 } { #2 }
- \l_luatexko_silent_upshape
\cs_set_protected_nopar:Npn \luatexkosanshangulfont
{
\fontencoding \g_fontspec_encoding_tl
@@ -558,7 +612,6 @@
\DeclareDocumentCommand \setmonohangulfont { O{} m O{} }
{
\fontspec_set_family:Nnn \luatexkomonohangulfamily { #1, #3 } { #2 }
- \l_luatexko_silent_upshape
\cs_set_protected_nopar:Npn \luatexkomonohangulfont
{
\fontencoding \g_fontspec_encoding_tl
@@ -575,7 +628,6 @@
\DeclareDocumentCommand \newhangulfontfamily { m O{} m O{} }
{
\fontspec_set_family:cnn { luatexko_user_family_ \cs_to_str:N #1 } { #2, #4 } { #3 }
- \l_luatexko_silent_upshape
\cs_set_protected_nopar:Npn #1
{
\cs_set_nopar:Npn \luatexkohangulfont
@@ -594,7 +646,6 @@
\DeclareDocumentCommand \hangulfontspec { O{} m O{} }
{
\fontspec_set_family:Nnn \luatexkohangulfontfamily { #1, #3 } { #2 }
- \l_luatexko_silent_upshape
\cs_set_nopar:Npn \luatexkohangulfont
{
\fontencoding \g_fontspec_encoding_tl
@@ -606,7 +657,6 @@
\DeclareDocumentCommand \setmainhanjafont { O{} m O{} }
{
\fontspec_set_family:Nnn \luatexkomainhanjafamily { Ligatures=TeX, #1, #3 } { #2 }
- \l_luatexko_silent_upshape
\cs_set_protected_nopar:Npn \luatexkomainhanjafont
{
\fontencoding \g_fontspec_encoding_tl
@@ -623,7 +673,6 @@
\DeclareDocumentCommand \setsanshanjafont { O{} m O{} }
{
\fontspec_set_family:Nnn \luatexkosanshanjafamily { Ligatures=TeX, #1, #3 } { #2 }
- \l_luatexko_silent_upshape
\cs_set_protected_nopar:Npn \luatexkosanshanjafont
{
\fontencoding \g_fontspec_encoding_tl
@@ -640,7 +689,6 @@
\DeclareDocumentCommand \setmonohanjafont { O{} m O{} }
{
\fontspec_set_family:Nnn \luatexkomonohanjafamily { #1, #3 } { #2 }
- \l_luatexko_silent_upshape
\cs_set_protected_nopar:Npn \luatexkomonohanjafont
{
\fontencoding \g_fontspec_encoding_tl
@@ -657,7 +705,6 @@
\DeclareDocumentCommand \newhanjafontfamily { m O{} m O{} }
{
\fontspec_set_family:cnn { luatexko_user_family_ \cs_to_str:N #1 } { #2, #4 } { #3 }
- \l_luatexko_silent_upshape
\cs_set_protected_nopar:Npn #1
{
\cs_set_nopar:Npn \luatexkohanjafont
@@ -676,7 +723,6 @@
\DeclareDocumentCommand \hanjafontspec { O{} m O{} }
{
\fontspec_set_family:Nnn \luatexkohanjafontfamily { #1, #3 } { #2 }
- \l_luatexko_silent_upshape
\cs_set_nopar:Npn \luatexkohanjafont
{
\fontencoding \g_fontspec_encoding_tl
@@ -689,7 +735,6 @@
\DeclareDocumentCommand \setmainfallbackfont { O{} m O{} }
{
\fontspec_set_family:Nnn \luatexkomainfallbackfamily { Ligatures=TeX, #1, #3 } { #2 }
- \l_luatexko_silent_upshape
\cs_set_protected_nopar:Npn \luatexkomainfallbackfont
{
\fontencoding \g_fontspec_encoding_tl
@@ -706,7 +751,6 @@
\DeclareDocumentCommand \setsansfallbackfont { O{} m O{} }
{
\fontspec_set_family:Nnn \luatexkosansfallbackfamily { Ligatures=TeX, #1, #3 } { #2 }
- \l_luatexko_silent_upshape
\cs_set_protected_nopar:Npn \luatexkosansfallbackfont
{
\fontencoding \g_fontspec_encoding_tl
@@ -723,7 +767,6 @@
\DeclareDocumentCommand \setmonofallbackfont { O{} m O{} }
{
\fontspec_set_family:Nnn \luatexkomonofallbackfamily { #1, #3 } { #2 }
- \l_luatexko_silent_upshape
\cs_set_protected_nopar:Npn \luatexkomonofallbackfont
{
\fontencoding \g_fontspec_encoding_tl
@@ -740,7 +783,6 @@
\DeclareDocumentCommand \newfallbackfontfamily { m O{} m O{} }
{
\fontspec_set_family:cnn { luatexko_user_family_ \cs_to_str:N #1 } { #2, #4 } { #3 }
- \l_luatexko_silent_upshape
\cs_set_protected_nopar:Npn #1
{
\cs_set_nopar:Npn \luatexkofallbackfont
@@ -759,7 +801,6 @@
\DeclareDocumentCommand \fallbackfontspec { O{} m O{} }
{
\fontspec_set_family:Nnn \luatexkofallbackfontfamily { #1, #3 } { #2 }
- \l_luatexko_silent_upshape
\cs_set_nopar:Npn \luatexkofallbackfont
{
\fontencoding \g_fontspec_encoding_tl
@@ -771,9 +812,8 @@
\DeclareDocumentCommand \setmathhangulfont { O{} m O{} }
{
\fontspec_set_family:Nnn \luatexkomathhangulfamily { #1, #3 } { #2 }
- \l_luatexko_silent_upshape
\DeclareSymbolFont { mathhangul }
- \g_fontspec_encoding_tl \luatexkomathhangulfamily \mddefault \updefault
+ \g_fontspec_encoding_tl \luatexkomathhangulfamily \seriesdefault \shapedefault
\int_compare:nNnF { \Umathcharfam"AC00 } = { \symmathhangul }
{
\setmathhangulblock{AC00}{D7A3}
@@ -785,22 +825,11 @@
\let\adhochanjafont\hanjafontspec
\let\adhocfallbackfont\fallbackfontspec
% interhangul, interlatincjk, charraise
-\def\luatexkosilentupshape{%
- \@tfor \@tempa := \mddefault \bfdefault \do {%
- \ifcsname \f@encoding/\f@family/\@tempa/\updefault\endcsname \else
- \ifcsname \f@encoding/\f@family/\@tempa/\shapedefault\endcsname
- \global \expandafter\let
- \csname \f@encoding/\f@family/\@tempa/\updefault \expandafter\endcsname
- \csname \f@encoding/\f@family/\@tempa/\shapedefault\endcsname
- \fi\fi
- }%
-}
\protected\def\addhangulfontfeature#1{%
\begingroup
\ifdefined\luatexkohangulfont
- \fontseries\mddefault\fontshape\shapedefault \luatexkohangulfont \fi
+ \fontseries\seriesdefault\fontshape\shapedefault \luatexkohangulfont \fi
\addfontfeature{#1}%
- \luatexkosilentupshape
\edef\x{\endgroup
\def\noexpand\luatexkohangulfont{%
\noexpand\fontencoding{\UTFencname}%
@@ -811,9 +840,8 @@
\protected\def\addhanjafontfeature#1{%
\begingroup
\ifdefined\luatexkohanjafont
- \fontseries\mddefault\fontshape\shapedefault \luatexkohanjafont \fi
+ \fontseries\seriesdefault\fontshape\shapedefault \luatexkohanjafont \fi
\addfontfeature{#1}%
- \luatexkosilentupshape
\edef\x{\endgroup
\def\noexpand\luatexkohanjafont{%
\noexpand\fontencoding{\UTFencname}%
@@ -824,9 +852,8 @@
\protected\def\addfallbackfontfeature#1{%
\begingroup
\ifdefined\luatexkofallbackfont
- \fontseries\mddefault\fontshape\shapedefault \luatexkofallbackfont \fi
+ \fontseries\seriesdefault\fontshape\shapedefault \luatexkofallbackfont \fi
\addfontfeature{#1}%
- \luatexkosilentupshape
\edef\x{\endgroup
\def\noexpand\luatexkofallbackfont{%
\noexpand\fontencoding{\UTFencname}%
@@ -854,25 +881,22 @@
\AtBeginDocument{
% default hangul fonts
\ifdefined\luatexkomainhangulfont\else
- \begingroup\rmfamily
- \directlua{ luatexko.currenthashangulchars(255) }\expandafter\endgroup
- \ifnum\count@=\z@
+ \begingroup\rmfamily\expandafter\endgroup
+ \iffontchar\font"AC00 \else
\IfFontExistsTF{UnBatang.ttf}
{\setmainhangulfont{UnBatang}[Script=Hangul,Language=Korean]}
{}
\fi
\fi
\ifdefined\luatexkosanshangulfont\else
- \begingroup\sffamily
- \directlua{ luatexko.currenthashangulchars(255) }\expandafter\endgroup
- \ifnum\count@=\z@
+ \begingroup\sffamily\expandafter\endgroup
+ \iffontchar\font"AC00 \else
\IfFontExistsTF{UnDotum.ttf}{\setsanshangulfont{UnDotum}}{}
\fi
\fi
\ifdefined\luatexkomonohangulfont\else
- \begingroup\ttfamily
- \directlua{ luatexko.currenthashangulchars(255) }\expandafter\endgroup
- \ifnum\count@=\z@
+ \begingroup\ttfamily\expandafter\endgroup
+ \iffontchar\font"AC00 \else
\def\@tempa{lmtt}\def\@tempb{LatinModernMono(0)}
\ifnum 0\ifx\ttdefault\@tempa 1\else\ifx\ttdefault\@tempb 1\fi\fi >\z@
\IfFontExistsTF{UnDotum.ttf}