% luatexko.sty % % Copyright (c) 2013-2019 Dohyun Kim % Soojin Nam % % This work may be distributed and/or modified under the % conditions of the LaTeX Project Public License, either version 1.3c % of this license or (at your option) any later version. % The latest version of this license is in % http://www.latex-project.org/lppl.txt % and version 1.3c or later is part of all distributions of LaTeX % version 2006/05/20 or later. \ifx\luatexkocatcodeofatchar\undefined\else\endinput\fi % no multiple loading \begingroup\expandafter\expandafter\expandafter\endgroup \expandafter\ifx\csname selectfont\endcsname\relax % plain tex \edef\luatexkocatcodeofatchar{\catcode`@=\the\catcode`@} \input luatexko-core.sty %\hangulfont{name:NanumGothic:interlatincjk=0.125em} at 10pt %\setmathhangulfont{NanumGothic} \luatexkocatcodeofatchar \expandafter\endinput \fi \ProvidesPackage{luatexko}[2019/04/06 v1.24 Typesetting Korean with LuaLaTeX] \ifdefined\adjustspacing\else % luatex < 0.87 \let\adjustspacing\pdfadjustspacing \let\protrudechars\pdfprotrudechars \fi %% package options \newif\if@hangul \newif\if@hanja \newif\if@luatexko@loadfontspec\@luatexko@loadfontspectrue \DeclareOption{hangul}{\@hangultrue} \DeclareOption{hanja}{\@hangultrue\@hanjatrue} \DeclareOption{unfonts}{} \DeclareOption{nofontspec}{\@luatexko@loadfontspecfalse} \ProcessOptions\relax \if@luatexko@loadfontspec \RequirePackage{fontspec}[2018/07/30] \fi \RequirePackage{luatexko-core} \if@luatexko@loadfontspec %% fontspec Korean options \newfontfeature{YetHangul}{script=hang} \newfontfeature{InterHangul}{interhangul=#1} \newfontfeature{InterLatinCJK}{interlatincjk=#1} \newfontfeature{PunctRaise}{punctraise=#1} \newfontfeature{CharRaise}{charraise=#1} \newfontfeature{NoEmbed}{embedding=no} \aliasfontfeature{NoEmbed}{NoEmbedding} \newfontfeature{protrusion}{protrusion=#1} \newfontfeature{expansion}{expansion=#1} \ExplSyntaxOn \DeclareDocumentCommand \newhangulfontfeature {mmmm} { \keys_define:nn { fontspec } { #1 .code:n = { \keys_set:nn { fontspec } { #2 = {##1} } #4 }, #1 .default:n = {#3} } } \newhangulfontfeature{Protrusion}{protrusion}{default} {\aftergroup\protrudechars\aftergroup\tw@} \newhangulfontfeature{Expansion}{expansion}{default} {\aftergroup\adjustspacing\aftergroup\tw@} %% default font features \cs_set_eq:NN \defaulthangulfontfeatures \defaultfontfeatures \cs_set_eq:NN \defaulthanjafontfeatures \defaultfontfeatures \cs_set_eq:NN \defaultfallbackfontfeatures \defaultfontfeatures \defaultfontfeatures [ \serifhangul@font, \serifhanja@font, \seriffallback@font, \sanshangul@font, \sanshanja@font, \sansfallback@font, ] {Ligatures=TeX} %% macros for Korean fonts \DeclareDocumentCommand \setmainhangulfont { O{} m O{} } { \setfontfamily \serifhangul@font [#1,#3] {#2} \str_if_eq_x:nnT \familydefault \rmdefault { \cs_set_eq:NN \hangul@font \serifhangul@font \luatexko@hangul@selectfont } \ignorespaces } \DeclareDocumentCommand \setmainhanjafont { O{} m O{} } { \setfontfamily \serifhanja@font [#1,#3] {#2} \str_if_eq_x:nnT \familydefault \rmdefault { \cs_set_eq:NN \hanja@font \serifhanja@font \luatexko@hanja@selectfont } \ignorespaces } \DeclareDocumentCommand \setmainfallbackfont { O{} m O{} } { \setfontfamily \seriffallback@font [#1,#3] {#2} \str_if_eq_x:nnT \familydefault \rmdefault { \cs_set_eq:NN \fallback@font \seriffallback@font \luatexko@fallback@selectfont } \ignorespaces } \DeclareDocumentCommand \setsanshangulfont { O{} m O{} } { \setfontfamily \sanshangul@font [#1,#3] {#2} \str_if_eq_x:nnT \familydefault \sfdefault { \cs_set_eq:NN \hangul@font \sanshangul@font \luatexko@hangul@selectfont } \ignorespaces } \DeclareDocumentCommand \setsanshanjafont { O{} m O{} } { \setfontfamily \sanshanja@font [#1,#3] {#2} \str_if_eq_x:nnT \familydefault \sfdefault { \cs_set_eq:NN \hanja@font \sanshanja@font \luatexko@hanja@selectfont } \ignorespaces } \DeclareDocumentCommand \setsansfallbackfont { O{} m O{} } { \setfontfamily \sansfallback@font [#1,#3] {#2} \str_if_eq_x:nnT \familydefault \sfdefault { \cs_set_eq:NN \fallback@font \sansfallback@font \luatexko@fallback@selectfont } \ignorespaces } \DeclareDocumentCommand \setmonohangulfont { O{} m O{} } { \setfontfamily \monohangul@font [#1,#3] {#2} \str_if_eq_x:nnT \familydefault \ttdefault { \cs_set_eq:NN \hangul@font \monohangul@font \luatexko@hangul@selectfont } \ignorespaces } \DeclareDocumentCommand \setmonohanjafont { O{} m O{} } { \setfontfamily \monohanja@font [#1,#3] {#2} \str_if_eq_x:nnT \familydefault \ttdefault { \cs_set_eq:NN \hanja@font \monohanja@font \luatexko@hanja@selectfont } \ignorespaces } \DeclareDocumentCommand \setmonofallbackfont { O{} m O{} } { \setfontfamily \monofallback@font [#1,#3] {#2} \str_if_eq_x:nnT \familydefault \ttdefault { \cs_set_eq:NN \fallback@font \monofallback@font \luatexko@fallback@selectfont } \ignorespaces } \DeclareDocumentCommand \newhangulfontfamily { m O{} m O{} } { \exp_args:Nc \setfontfamily { luatexkofont@ \token_to_str:N #1 } [#2,#4] {#3} \DeclareRobustCommand #1 { \cs_set_eq:Nc \hangul@font { luatexkofont@ \token_to_str:N #1 } \luatexko@hangul@selectfont } } \DeclareDocumentCommand \newhanjafontfamily { m O{} m O{} } { \exp_args:Nc \setfontfamily { luatexkofont@ \token_to_str:N #1 } [#2,#4] {#3} \DeclareRobustCommand #1 { \cs_set_eq:Nc \hanja@font { luatexkofont@ \token_to_str:N #1 } \luatexko@hanja@selectfont } } \DeclareDocumentCommand \newfallbackfontfamily { m O{} m O{} } { \exp_args:Nc \setfontfamily { luatexkofont@ \token_to_str:N #1 } [#2,#4] {#3} \DeclareRobustCommand #1 { \cs_set_eq:Nc \fallback@font { luatexkofont@ \token_to_str:N #1 } \luatexko@fallback@selectfont } } \DeclareDocumentCommand \newhangulfontface { m O{} m O{} } { \exp_args:Nc \newfontface { luatexkofont@ \token_to_str:N #1 } [#2,#4] {#3} \DeclareRobustCommand #1 { \cs_set_eq:Nc \hangul@font { luatexkofont@ \token_to_str:N #1 } \luatexko@hangul@selectfont } } \DeclareDocumentCommand \newhanjafontface { m O{} m O{} } { \exp_args:Nc \newfontface { luatexkofont@ \token_to_str:N #1 } [#2,#4] {#3} \DeclareRobustCommand #1 { \cs_set_eq:Nc \hanja@font { luatexkofont@ \token_to_str:N #1 } \luatexko@hanja@selectfont } } \DeclareDocumentCommand \newfallbackfontface { m O{} m O{} } { \exp_args:Nc \newfontface { luatexkofont@ \token_to_str:N #1 } [#2,#4] {#3} \DeclareRobustCommand #1 { \cs_set_eq:Nc \fallback@font { luatexkofont@ \token_to_str:N #1 } \luatexko@fallback@selectfont } } \DeclareDocumentCommand \hangulfontspec { O{} m O{} } { \setfontfamily \hangul@font [#1,#3] {#2} \luatexko@hangul@selectfont \ignorespaces } \cs_set_eq:NN \adhochangulfont \hangulfontspec \DeclareDocumentCommand \hanjafontspec { O{} m O{} } { \setfontfamily \hanja@font [#1,#3] {#2} \luatexko@hanja@selectfont \ignorespaces } \cs_set_eq:NN \adhochanjafont \hanjafontspec \DeclareDocumentCommand \fallbackfontspec { O{} m O{} } { \setfontfamily \fallback@font [#1,#3] {#2} \luatexko@fallback@selectfont \ignorespaces } \cs_set_eq:NN \adhocfallbackfont \fallbackfontspec \DeclareDocumentCommand \addhangulfontfeature { m } { \group_begin: \cs_if_exist:NT \hangul@font { \hangul@font } \addfontfeature {#1} \use:x { \group_end: \exp_not:N \tl_set:Nn \exp_not:N \hangul@font { \exp_not:N \fontfamily { \f@family } \exp_not:N \selectfont } } \luatexko@hangul@selectfont \ignorespaces } \cs_set_eq:NN \addhangulfontfeatures \addhangulfontfeature \DeclareDocumentCommand \addhanjafontfeature { m } { \group_begin: \cs_if_exist:NT \hanja@font { \hanja@font } \addfontfeature {#1} \use:x { \group_end: \exp_not:N \tl_set:Nn \exp_not:N \hanja@font { \exp_not:N \fontfamily { \f@family } \exp_not:N \selectfont } } \luatexko@hanja@selectfont \ignorespaces } \cs_set_eq:NN \addhanjafontfeatures \addhanjafontfeature \DeclareDocumentCommand \addfallbackfontfeature { m } { \group_begin: \cs_if_exist:NT \fallback@font { \fallback@font } \addfontfeature {#1} \use:x { \group_end: \exp_not:N \tl_set:Nn \exp_not:N \fallback@font { \exp_not:N \fontfamily { \f@family } \exp_not:N \selectfont } } \luatexko@fallback@selectfont \ignorespaces } \cs_set_eq:NN \addfallbackfontfeatures \addfallbackfontfeature % hangul math font command \DeclareDocumentCommand \setmathhangulfont { O{} m O{} } { \fontspec_set_family:Nnn \luatexko@math@hangul@family {#1,#3} {#2} } %% fontspec 2018 \RenewDocumentCommand \setmainfont { O{} m O{} } { \__fontspec_main_setmainfont:nn {#1,#3} {#2} \protected\edef\rmfamily{ \unexpanded{\luatexko@serif@fonts} \unexpanded\expandafter{\rmfamily} } \ignorespaces } \RenewDocumentCommand \setsansfont { O{} m O{} } { \__fontspec_main_setsansfont:nn {#1,#3} {#2} \protected\edef\sffamily{ \unexpanded{\luatexko@sans@fonts} \unexpanded\expandafter{\sffamily} } \ignorespaces } \RenewDocumentCommand \setmonofont { O{} m O{} } { \__fontspec_main_setmonofont:nn {#1,#3} {#2} \protected\edef\ttfamily{ \unexpanded{\luatexko@mono@fonts} \unexpanded\expandafter{\ttfamily} } \ignorespaces } \cs_set_eq:NN \setromanfont \setmainfont \ExplSyntaxOff \fi \RequirePackage{everysel} \EverySelectfont{% \luatexko@hangul@selectfont \luatexko@hanja@selectfont \luatexko@fallback@selectfont } % serif : finemathattr = 2 % sans : finemathattr = 1 % tt : finemathattr = 0 % verbatim : finemathattr = nil \def\luatexko@serif@fonts{% \let\hangul@font\serifhangul@font \let\hanja@font\serifhanja@font \let\fallback@font\seriffallback@font \finemathattr\tw@ } \def\luatexko@sans@fonts{% \let\hangul@font\sanshangul@font \let\hanja@font\sanshanja@font \let\fallback@font\sansfallback@font \finemathattr\@ne } \def\luatexko@mono@fonts{% \let\hangul@font\monohangul@font \let\hanja@font\monohanja@font \let\fallback@font\monofallback@font \finemathattr\z@ } \protected\edef\rmfamily{% \unexpanded{\luatexko@serif@fonts}\unexpanded\expandafter{\rmfamily}} \protected\edef\sffamily{% \unexpanded{\luatexko@sans@fonts}\unexpanded\expandafter{\sffamily}} \protected\edef\ttfamily{% \unexpanded{\luatexko@mono@fonts}\unexpanded\expandafter{\ttfamily}} \edef\verbatim@font{\unexpanded\expandafter{\verbatim@font \unsetattribute\finemathattr}} \AtBeginDocument{ \unless\ifdefined\serifhangul@font\let\serifhangul@font\sanshangul@font\fi \unless\ifdefined\sanshangul@font \let\sanshangul@font\serifhangul@font\fi \unless\ifdefined\monohangul@font \let\monohangul@font\sanshangul@font \fi \unless\ifdefined\serifhangul@font\unless\ifdefined\sanshangul@font \hangulpunctuations=0 % nanumtype1 \fi\fi % don't forget to redefine \normalfont \expandafter\ifx\familydefault\rmdefault \protected\edef\normalfont{% \unexpanded{\luatexko@serif@fonts}\unexpanded\expandafter{\normalfont}} % and current hangul font \luatexko@serif@fonts \else\expandafter\ifx\familydefault\sfdefault \protected\edef\normalfont{% \unexpanded{\luatexko@sans@fonts}\unexpanded\expandafter{\normalfont}} \luatexko@sans@fonts \else \protected\edef\normalfont{% \unexpanded{\luatexko@mono@fonts}\unexpanded\expandafter{\normalfont}} \luatexko@mono@fonts \fi\fi \let\reset@font\normalfont % reset hangul font \selectfont % for hyperref \@ifpackageloaded{hyperref}{\pdfstringdefDisableCommands{% \let\dotemph\@firstofone \let\ruby\@firstoftwo \let\uline\@firstofone \let\sout\@firstofone \let\uuline\@firstofone \let\xout\@firstofone \let\uwave\@firstofone \let\dashuline\@firstofone \let\dotuline\@firstofone \let\actualtext\@firstofone \let\inhibitglue\empty \def\는{는}% \def\은{은}% \def\을{을}% \def\를{를}% \def\와{와}% \def\과{과}% \def\가{가}% \def\이{이}% \def\라{라}% \def\으{으}% \def\로{로}% }}{} } \if@luatexko@loadfontspec %% hangul in math --- latex \AtBeginDocument{ \begingroup \unless\ifdefined\luatexko@math@hangul@family \ifdefined\hangul@font \hangul@font \fi \xdef\luatexko@math@hangul@family{\f@family}% \fi \endgroup \DeclareSymbolFont{mathhangul}% \f@encoding\luatexko@math@hangul@family\mddefault\updefault \ifcsname\f@encoding/\luatexko@math@hangul@family/\bfdefault/\updefault\endcsname \SetSymbolFont{mathhangul}{bold}% \f@encoding\luatexko@math@hangul@family\bfdefault\updefault \fi \setmathhangulblock{AC00}{D7A3} } \fi \RequirePackage{kolabels-utf} \if@hangul \AtBeginDocument{\RequirePackage{konames-utf}} \linespread{1.3888} \footnotesep=1.3888\footnotesep \skip\footins=\glueexpr\skip\footins/72*100\relax \hangulpunctuations=1 \frenchspacing \fi \endinput