From 6a1383661dd7817761345a9d4ddfd9db6ba2dd1e Mon Sep 17 00:00:00 2001
From: Norbert Preining <norbert@preining.info>
Date: Wed, 3 Mar 2021 03:01:26 +0000
Subject: CTAN sync 202103030301

---
 macros/luatex/generic/luatexko/luatexko.sty | 147 +++++++++++++---------------
 1 file changed, 68 insertions(+), 79 deletions(-)

(limited to 'macros/luatex/generic/luatexko/luatexko.sty')

diff --git a/macros/luatex/generic/luatexko/luatexko.sty b/macros/luatex/generic/luatexko/luatexko.sty
index 958407dc81..f1e0179164 100644
--- a/macros/luatex/generic/luatexko/luatexko.sty
+++ b/macros/luatex/generic/luatexko/luatexko.sty
@@ -1,6 +1,6 @@
 % luatexko.sty
 %
-% Copyright (c) 2013-2020 Dohyun Kim <nomos at ktug org>
+% Copyright (c) 2013-2021 Dohyun Kim <nomos at ktug org>
 %                         Soojin Nam <jsunam at gmail com>
 %
 % This work may be distributed and/or modified under the
@@ -13,11 +13,10 @@
 
 \ifdefined\luatexkohangulfontattr \endinput\fi
 \ifdefined\selectfont
-  \NeedsTeXFormat{LaTeX2e}[2020/02/02]
-  \ProvidesPackage{luatexko}[2020/07/27 v2.9 typesetting Korean with LuaTeX]
+  \NeedsTeXFormat{LaTeX2e}[2020/10/01]
+  \ProvidesPackage{luatexko}[2021/03/01 v3.0 typesetting Korean with LuaTeX]
   \RequirePackage{luatexbase}
   \RequirePackage{fontspec}[2020/02/03]
-  \RequirePackage{atbegshi}
 \else
   \input luatexbase.sty
   \input luaotfload.sty
@@ -360,11 +359,6 @@
   \ifcase\count@ \directlua{ luatexko.uhc2utf8.stopconvert() }%
   \else \directlua{ luatexko.uhc2utf8.startconvert() }%
   \fi}
-% actualtext not provided
-\ifdefined\actualtext\else
-  \protected\def\actualtext#1#{\luatexkoactualtext}
-  \def\luatexkoactualtext#1{#1}
-\fi
 % math hangul
 \def\setmathhangulblock#1#2{%
   \count@="#1
@@ -432,60 +426,60 @@
   \catcode`\@=\luatexkoatcatcode
 \endinput\fi
 % latex
-\RequirePackage{everysel}
-\EverySelectfont{%
-  \luatexkohangulselectfont
-  \luatexkohanjaselectfont
-  \luatexkofallbackselectfont
+\IfHookExistsTF{selectfont}{
+  \AddToHook{selectfont}{%
+    \luatexkohangulselectfont
+    \luatexkohanjaselectfont
+    \luatexkofallbackselectfont }
+}{
+  \RequirePackage{everysel}
+  \EverySelectfont{%
+    \luatexkohangulselectfont
+    \luatexkohanjaselectfont
+    \luatexkofallbackselectfont }
 }
-\edef\@rmfamilyhook{\unexpanded\expandafter{\@rmfamilyhook
+\AddToHook{rmfamily}{%
   \let\luatexkohangulfont  \luatexkomainhangulfont
   \let\luatexkohanjafont   \luatexkomainhanjafont
   \let\luatexkofallbackfont\luatexkomainfallbackfont
-}}
-\edef\@sffamilyhook{\unexpanded\expandafter{\@sffamilyhook
+}
+\AddToHook{sffamily}{%
   \let\luatexkohangulfont  \luatexkosanshangulfont
   \let\luatexkohanjafont   \luatexkosanshanjafont
   \let\luatexkofallbackfont\luatexkosansfallbackfont
-}}
-\edef\@ttfamilyhook{\unexpanded\expandafter{\@ttfamilyhook
+}
+\AddToHook{ttfamily}{%
   \let\luatexkohangulfont  \luatexkomonohangulfont
   \let\luatexkohanjafont   \luatexkomonohanjafont
   \let\luatexkofallbackfont\luatexkomonofallbackfont
-}}
-\edef\@defaultfamilyhook{\unexpanded\expandafter{\@defaultfamilyhook
+}
+\AddToHook{normalfont}{%
   \let\luatexkohangulfont  \luatexkodefaulthangulfont
   \let\luatexkohanjafont   \luatexkodefaulthanjafont
   \let\luatexkofallbackfont\luatexkodefaultfallbackfont
-}}
+}
 % fontspec-like
 \ExplSyntaxOn
-\cs_new_nopar:Npn \l_luatexko_pacify_bfseries {
+\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_set_eq:cc
-      { \g_fontspec_encoding_tl/\l_fontspec_family_tl/##1/\updefault }
+      \cs_if_exist:cT
       { \g_fontspec_encoding_tl/\l_fontspec_family_tl/##1/\shapedefault }
-    }
-  }
-  \tl_map_inline:nn { \shapedefault \updefault \itdefault \sldefault }
-  {
-    \cs_if_exist:cF
-    { \g_fontspec_encoding_tl/\l_fontspec_family_tl/bx/##1 }
-    {
-      \cs_set_eq:cc
-      { \g_fontspec_encoding_tl/\l_fontspec_family_tl/bx/##1 }
-      { \g_fontspec_encoding_tl/\l_fontspec_family_tl/\bfdefault/##1 }
+      {
+        \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_pacify_bfseries
+  \l_luatexko_silent_upshape
   \cs_set_protected_nopar:Npn \luatexkomainhangulfont
   {
     \fontencoding \g_fontspec_encoding_tl
@@ -502,7 +496,7 @@
 \DeclareDocumentCommand \setsanshangulfont { O{} m O{} }
 {
   \fontspec_set_family:Nnn \luatexkosanshangulfamily { Ligatures=TeX, #1, #3 } { #2 }
-  \l_luatexko_pacify_bfseries
+  \l_luatexko_silent_upshape
   \cs_set_protected_nopar:Npn \luatexkosanshangulfont
   {
     \fontencoding \g_fontspec_encoding_tl
@@ -519,7 +513,7 @@
 \DeclareDocumentCommand \setmonohangulfont { O{} m O{} }
 {
   \fontspec_set_family:Nnn \luatexkomonohangulfamily { #1, #3 } { #2 }
-  \l_luatexko_pacify_bfseries
+  \l_luatexko_silent_upshape
   \cs_set_protected_nopar:Npn \luatexkomonohangulfont
   {
     \fontencoding \g_fontspec_encoding_tl
@@ -536,7 +530,7 @@
 \DeclareDocumentCommand \newhangulfontfamily { m O{} m O{} }
 {
   \fontspec_set_family:cnn { luatexko_user_family_ \cs_to_str:N #1 } { #2, #4 } { #3 }
-  \l_luatexko_pacify_bfseries
+  \l_luatexko_silent_upshape
   \cs_set_protected_nopar:Npn #1
   {
     \cs_set_nopar:Npn \luatexkohangulfont
@@ -555,7 +549,7 @@
 \DeclareDocumentCommand \hangulfontspec { O{} m O{} }
 {
   \fontspec_set_family:Nnn \luatexkohangulfontfamily { #1, #3 } { #2 }
-  \l_luatexko_pacify_bfseries
+  \l_luatexko_silent_upshape
   \cs_set_nopar:Npn \luatexkohangulfont
   {
     \fontencoding \g_fontspec_encoding_tl
@@ -567,7 +561,7 @@
 \DeclareDocumentCommand \setmainhanjafont { O{} m O{} }
 {
   \fontspec_set_family:Nnn \luatexkomainhanjafamily { Ligatures=TeX, #1, #3 } { #2 }
-  \l_luatexko_pacify_bfseries
+  \l_luatexko_silent_upshape
   \cs_set_protected_nopar:Npn \luatexkomainhanjafont
   {
     \fontencoding \g_fontspec_encoding_tl
@@ -584,7 +578,7 @@
 \DeclareDocumentCommand \setsanshanjafont { O{} m O{} }
 {
   \fontspec_set_family:Nnn \luatexkosanshanjafamily { Ligatures=TeX, #1, #3 } { #2 }
-  \l_luatexko_pacify_bfseries
+  \l_luatexko_silent_upshape
   \cs_set_protected_nopar:Npn \luatexkosanshanjafont
   {
     \fontencoding \g_fontspec_encoding_tl
@@ -601,7 +595,7 @@
 \DeclareDocumentCommand \setmonohanjafont { O{} m O{} }
 {
   \fontspec_set_family:Nnn \luatexkomonohanjafamily { #1, #3 } { #2 }
-  \l_luatexko_pacify_bfseries
+  \l_luatexko_silent_upshape
   \cs_set_protected_nopar:Npn \luatexkomonohanjafont
   {
     \fontencoding \g_fontspec_encoding_tl
@@ -618,7 +612,7 @@
 \DeclareDocumentCommand \newhanjafontfamily { m O{} m O{} }
 {
   \fontspec_set_family:cnn { luatexko_user_family_ \cs_to_str:N #1 } { #2, #4 } { #3 }
-  \l_luatexko_pacify_bfseries
+  \l_luatexko_silent_upshape
   \cs_set_protected_nopar:Npn #1
   {
     \cs_set_nopar:Npn \luatexkohanjafont
@@ -637,7 +631,7 @@
 \DeclareDocumentCommand \hanjafontspec { O{} m O{} }
 {
   \fontspec_set_family:Nnn \luatexkohanjafontfamily { #1, #3 } { #2 }
-  \l_luatexko_pacify_bfseries
+  \l_luatexko_silent_upshape
   \cs_set_nopar:Npn \luatexkohanjafont
   {
     \fontencoding \g_fontspec_encoding_tl
@@ -650,7 +644,7 @@
 \DeclareDocumentCommand \setmainfallbackfont { O{} m O{} }
 {
   \fontspec_set_family:Nnn \luatexkomainfallbackfamily { Ligatures=TeX, #1, #3 } { #2 }
-  \l_luatexko_pacify_bfseries
+  \l_luatexko_silent_upshape
   \cs_set_protected_nopar:Npn \luatexkomainfallbackfont
   {
     \fontencoding \g_fontspec_encoding_tl
@@ -667,7 +661,7 @@
 \DeclareDocumentCommand \setsansfallbackfont { O{} m O{} }
 {
   \fontspec_set_family:Nnn \luatexkosansfallbackfamily { Ligatures=TeX, #1, #3 } { #2 }
-  \l_luatexko_pacify_bfseries
+  \l_luatexko_silent_upshape
   \cs_set_protected_nopar:Npn \luatexkosansfallbackfont
   {
     \fontencoding \g_fontspec_encoding_tl
@@ -684,7 +678,7 @@
 \DeclareDocumentCommand \setmonofallbackfont { O{} m O{} }
 {
   \fontspec_set_family:Nnn \luatexkomonofallbackfamily { #1, #3 } { #2 }
-  \l_luatexko_pacify_bfseries
+  \l_luatexko_silent_upshape
   \cs_set_protected_nopar:Npn \luatexkomonofallbackfont
   {
     \fontencoding \g_fontspec_encoding_tl
@@ -701,7 +695,7 @@
 \DeclareDocumentCommand \newfallbackfontfamily { m O{} m O{} }
 {
   \fontspec_set_family:cnn { luatexko_user_family_ \cs_to_str:N #1 } { #2, #4 } { #3 }
-  \l_luatexko_pacify_bfseries
+  \l_luatexko_silent_upshape
   \cs_set_protected_nopar:Npn #1
   {
     \cs_set_nopar:Npn \luatexkofallbackfont
@@ -720,7 +714,7 @@
 \DeclareDocumentCommand \fallbackfontspec { O{} m O{} }
 {
   \fontspec_set_family:Nnn \luatexkofallbackfontfamily { #1, #3 } { #2 }
-  \l_luatexko_pacify_bfseries
+  \l_luatexko_silent_upshape
   \cs_set_nopar:Npn \luatexkofallbackfont
   {
     \fontencoding \g_fontspec_encoding_tl
@@ -732,7 +726,7 @@
 \DeclareDocumentCommand \setmathhangulfont { O{} m O{} }
 {
   \fontspec_set_family:Nnn \luatexkomathhangulfamily { #1, #3 } { #2 }
-  \l_luatexko_pacify_bfseries
+  \l_luatexko_silent_upshape
   \DeclareSymbolFont { mathhangul }
     \g_fontspec_encoding_tl \luatexkomathhangulfamily \mddefault \updefault
   \int_compare:nNnF { \Umathcharfam"AC00 } = { \symmathhangul }
@@ -746,20 +740,14 @@
 \let\adhochanjafont\hanjafontspec
 \let\adhocfallbackfont\fallbackfontspec
 % interhangul, interlatincjk, charraise
-\def\luatexkopacifybfseries{%
+\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
-  }%
-  \@tfor \@tempa := \shapedefault \updefault \itdefault \sldefault \do {%
-    \ifcsname \f@encoding/\f@family/bx/\@tempa\endcsname \else
-      \global \expandafter\let
-        \csname \f@encoding/\f@family/bx/\@tempa \expandafter\endcsname
-        \csname \f@encoding/\f@family/\bfdefault/\@tempa\endcsname
-    \fi
+    \fi\fi
   }%
 }
 \protected\def\addhangulfontfeature#1{%
@@ -767,7 +755,7 @@
   \ifdefined\luatexkohangulfont
     \fontseries\mddefault\fontshape\shapedefault \luatexkohangulfont \fi
   \addfontfeature{#1}%
-  \luatexkopacifybfseries
+  \luatexkosilentupshape
   \edef\x{\endgroup
     \def\noexpand\luatexkohangulfont{%
       \noexpand\fontencoding{\UTFencname}%
@@ -780,7 +768,7 @@
   \ifdefined\luatexkohanjafont
     \fontseries\mddefault\fontshape\shapedefault \luatexkohanjafont \fi
   \addfontfeature{#1}%
-  \luatexkopacifybfseries
+  \luatexkosilentupshape
   \edef\x{\endgroup
     \def\noexpand\luatexkohanjafont{%
       \noexpand\fontencoding{\UTFencname}%
@@ -793,7 +781,7 @@
   \ifdefined\luatexkofallbackfont
     \fontseries\mddefault\fontshape\shapedefault \luatexkofallbackfont \fi
   \addfontfeature{#1}%
-  \luatexkopacifybfseries
+  \luatexkosilentupshape
   \edef\x{\endgroup
     \def\noexpand\luatexkofallbackfont{%
       \noexpand\fontencoding{\UTFencname}%
@@ -806,21 +794,7 @@
 \newfontfeature{CharRaise}{charraise=#1}
 \newfontfeature{RemoveClassicSpaces}{+removeclassicspaces}
 \newfontfeature{CompressPunctuations}{+compresspunctuations}
-% luaotfload expansion feature, committed at 2020.06.08
-\count@=\z@
-\directlua{ if luatexko.plug_expansion_loaded then tex.setcount(255,1) end }
-\ifnum\count@=\z@
-  \newfontfeature{Expansion}{expansion=\ifx\empty#1\empty default\else #1\fi }
-\else
-  \newfontfeature{Expansion}{expansion=\directlua{
-      if "#1" == "" or "#1" == "default" then
-        tex.sprint "20 20 5"
-      else
-        tex.sprint "#1"
-      end
-    }%
-  }
-\fi
+\newfontfeature{Expansion}{expansion=\ifx\empty#1\empty default\else #1\fi }
 \newfontfeature{Protrusion}{protrusion=\ifx\empty#1\empty default\else #1\fi }
 \newfontfeature{InterCharacter}{intercharacter=#1}
 \newfontfeature{InterCharStretch}{intercharstretch=#1}
@@ -854,7 +828,22 @@
     \begingroup\ttfamily
     \directlua{ luatexko.currenthashangulchars(255) }\expandafter\endgroup
     \ifnum\count@=\z@
-      \let\luatexkomonohangulfont\luatexkosanshangulfont
+      \def\@tempa{lmtt}\def\@tempb{LatinModernMono(0)}
+      \ifnum 0\ifx\ttdefault\@tempa 1\else\ifx\ttdefault\@tempb 1\fi\fi >\z@
+        \IfFontExistsTF{UnDotum.ttf}
+          {\setmonohangulfont{UnDotum}[
+            UprightFeatures={SizeFeatures={
+              {Size={-8.5},   FakeStretch=1.062},
+              {Size={8.5-11}, FakeStretch=1.05 },
+              {Size={11-},    FakeStretch=1.03 }}},
+            BoldFeatures={SizeFeatures={
+              {Size={-},      FakeStretch=1.05}}},
+            WordSpace={1.66667,0,0}]
+          }
+          {\let\luatexkomonohangulfont\luatexkosanshangulfont }
+      \else
+        \let\luatexkomonohangulfont\luatexkosanshangulfont
+      \fi
     \fi
   \fi
   % just in case, reset luatexkodefault...font
-- 
cgit v1.2.3

