diff options
author | Karl Berry <karl@freefriends.org> | 2014-05-13 22:10:13 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2014-05-13 22:10:13 +0000 |
commit | 965a87a0387a9b227aca0cf47913062116a7d735 (patch) | |
tree | c6397cb81089a980f530226d090b049ffa660173 /Master/texmf-dist/tex/xetex/xetexko/xetexko-font.sty | |
parent | 96ae66c3ffba17421aa8dafe928f185b0b23e372 (diff) |
xetexko (13may14)
git-svn-id: svn://tug.org/texlive/trunk@34013 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/xetex/xetexko/xetexko-font.sty')
-rw-r--r-- | Master/texmf-dist/tex/xetex/xetexko/xetexko-font.sty | 559 |
1 files changed, 304 insertions, 255 deletions
diff --git a/Master/texmf-dist/tex/xetex/xetexko/xetexko-font.sty b/Master/texmf-dist/tex/xetex/xetexko/xetexko-font.sty index e61331944e8..a959de576e4 100644 --- a/Master/texmf-dist/tex/xetex/xetexko/xetexko-font.sty +++ b/Master/texmf-dist/tex/xetex/xetexko/xetexko-font.sty @@ -10,264 +10,309 @@ % and version 1.3c or later is part of all distributions of LaTeX % version 2006/05/20 or later. -\ProvidesPackage{xetexko-font}[2014/03/28 v2.5 Font commands for XeTeX-ko] +\ProvidesPackage{xetexko-font}[2014/05/11 v2.6 Font commands for XeTeX-ko] \let\xetexko@f@size\f@size \RequirePackage{fontspec} \let\f@size\xetexko@f@size -\RequirePackage{xkeyval} %%%%%%%%%%%%%%%%%%%%%%%%%%%% %%% for old hangul rendering -\ExplSyntaxOn -\fontspec_define_font_feature:n {YetHangul} -\keys_define:nn {fontspec} - { - YetHangul .default:n = {On} , - YetHangul / On .code:n = { - \fontspec_update_fontid:n {yethangul:on} - \fontspec_update_featstr:n {script=hang} - } , - YetHangul / Off .code:n = { - \fontspec_update_fontid:n {yethangul:off} - \fontspec_update_featstr:n {-ljmo;-vjmo;-tjmo} - } - } -\ExplSyntaxOff +\newfontfeature{YetHangul}{script=hang} +\ExplSyntaxOn %%%%%%%%%%%%%%%%%%%%% % hangul font options -\newtoks\XK@font@options\XK@font@options{} -\define@key[xtxko]{font}{hu}{\addto@hook\XK@font@options{\def\xetexkohu{#1}}} -\define@key[xtxko]{font}{interhchar}{\addto@hook\XK@font@options{\def\xetexkointerhchar{#1}}} -\define@key[xtxko]{font}{lowerexclamation}{\addto@hook\XK@font@options{\def\xetexkolowerexclamation{#1}}} -\define@key[xtxko]{font}{lowerperiod}{\addto@hook\XK@font@options{\def\xetexkolowerperiod{#1}}} -\define@key[xtxko]{font}{lowerquestion}{\addto@hook\XK@font@options{\def\xetexkolowerquestion{#1}}} -\define@key[xtxko]{font}{lowercomma}{\addto@hook\XK@font@options{\def\xetexkolowercomma{#1}}} -\define@key[xtxko]{font}{postexclamationkern}{\addto@hook\XK@font@options{\def\xetexkopostexclamationkern{#1}}} -\define@key[xtxko]{font}{postmathskip}{\addto@hook\XK@font@options{\def\xetexkopostmathskip{#1}}} -\define@key[xtxko]{font}{postperiodkern}{\addto@hook\XK@font@options{\def\xetexkopostperiodkern{#1}}} -\define@key[xtxko]{font}{postquestionkern}{\addto@hook\XK@font@options{\def\xetexkopostquestionkern{#1}}} -\define@key[xtxko]{font}{postcommakern}{\addto@hook\XK@font@options{\def\xetexkopostcommakern{#1}}} -\define@key[xtxko]{font}{preexclamationkern}{\addto@hook\XK@font@options{\def\xetexkopreexclamationkern{#1}}} -\define@key[xtxko]{font}{preperiodkern}{\addto@hook\XK@font@options{\def\xetexkopreperiodkern{#1}}} -\define@key[xtxko]{font}{prequestionkern}{\addto@hook\XK@font@options{\def\xetexkoprequestionkern{#1}}} -\define@key[xtxko]{font}{precommakern}{\addto@hook\XK@font@options{\def\xetexkoprecommakern{#1}}} -\define@key[xtxko]{font}{quoteraise}{\addto@hook\XK@font@options{\def\xetexkoquoteraise{#1}}} -\define@key[xtxko]{font}{quotewidth}{\addto@hook\XK@font@options{\def\xetexkoquotewidth{#1}}} -\define@key[xtxko]{font}{charraise}{\addto@hook\XK@font@options{\def\xetexkocharraise{#1}}} - -\presetkeys[xtxko]{font}{ - hu=0.06em, - interhchar={}, - lowerexclamation={}, - lowerperiod={}, - lowercomma={}, - lowerquestion={}, - postexclamationkern={}, - postmathskip=\dimexpr\xetexkohu*\tw@\relax, - postperiodkern={}, - postcommakern={}, - postquestionkern={}, - preexclamationkern={}, - preperiodkern={}, - precommakern={}, - prequestionkern={}, - quoteraise={}, - quotewidth={}, - charraise={} -}{} - +\tl_new:N \l_xtxko_font_opts_tl +\tl_new:N \l_xtxko_font_opts_init_tl +\tl_set:Nn \l_xtxko_font_opts_init_tl + { + \tl_clear:N \xetexkointerhchar + \tl_clear:N \xetexkointerhchar + \tl_clear:N \xetexkolowerexclamation + \tl_clear:N \xetexkolowerperiod + \tl_clear:N \xetexkolowercomma + \tl_clear:N \xetexkolowerquestion + \tl_clear:N \xetexkopostexclamationkern + \tl_clear:N \xetexkopostperiodkern + \tl_clear:N \xetexkopostcommakern + \tl_clear:N \xetexkopostquestionkern + \tl_clear:N \xetexkopreexclamationkern + \tl_clear:N \xetexkopreperiodkern + \tl_clear:N \xetexkoprecommakern + \tl_clear:N \xetexkoprequestionkern + \tl_clear:N \xetexkoquoteraise + \tl_clear:N \xetexkoquotewidth + \tl_clear:N \xetexkocharraise + \tl_set:Nn \xetexkohu {0.06em} + \tl_set:Nn \xetexkopostmathskip {\dim_eval:n {\xetexkohu*2}} + } +\cs_new:Nn \__xtxko_add_font_opt:Nn + { + \tl_put_right:Nn \l_xtxko_font_opts_tl { \tl_set:Nn #1 {#2} } + } +\keys_define:nn { xtxko-font } + { + hu .code:n = + { \__xtxko_add_font_opt:Nn \xetexkohu {#1} } , + interhchar .code:n = + { \__xtxko_add_font_opt:Nn \xetexkointerhchar {#1} } , + lowerexclamation .code:n = + { \__xtxko_add_font_opt:Nn \xetexkolowerexclamation {#1} } , + lowerperiod .code:n = + { \__xtxko_add_font_opt:Nn \xetexkolowerperiod {#1} } , + lowercomma .code:n = + { \__xtxko_add_font_opt:Nn \xetexkolowercomma {#1} } , + lowerquestion .code:n = + { \__xtxko_add_font_opt:Nn \xetexkolowerquestion {#1} } , + postexclamationkern .code:n = + { \__xtxko_add_font_opt:Nn \xetexkopostexclamationkern {#1} } , + postmathskip .code:n = + { \__xtxko_add_font_opt:Nn \xetexkopostmathskip {#1} } , + postperiodkern .code:n = + { \__xtxko_add_font_opt:Nn \xetexkopostperiodkern {#1} } , + postcommakern .code:n = + { \__xtxko_add_font_opt:Nn \xetexkopostcommakern {#1} } , + postquestionkern .code:n = + { \__xtxko_add_font_opt:Nn \xetexkopostquestionkern {#1} } , + preexclamationkern .code:n = + { \__xtxko_add_font_opt:Nn \xetexkopreexclamationkern {#1} } , + preperiodkern .code:n = + { \__xtxko_add_font_opt:Nn \xetexkopreperiodkern {#1} } , + precommakern .code:n = + { \__xtxko_add_font_opt:Nn \xetexkoprecommakern {#1} } , + prequestionkern .code:n = + { \__xtxko_add_font_opt:Nn \xetexkoprequestionkern {#1} } , + quoteraise .code:n = + { \__xtxko_add_font_opt:Nn \xetexkoquoteraise {#1} } , + quotewidth .code:n = + { \__xtxko_add_font_opt:Nn \xetexkoquotewidth {#1} } , + charraise .code:n = + { \__xtxko_add_font_opt:Nn \xetexkocharraise {#1} } , + InterLatinCJK .code:n = + { \keys_set:nn { xtxko-font } { hu = {#1} } } , + InterHangul .code:n = + { \keys_set:nn { xtxko-font } { interhchar = {#1} } } , + PunctRaise .code:n = + { \keys_set:nn { xtxko-font } { lowerperiod = { \dim_eval:n {-#1} } } } , + CharRaise .code:n = + { \keys_set:nn { xtxko-font } { charraise = {#1} } } , + } +\tl_new:N \l_xtxko_rem_tl +\cs_new:Nn \__xtxko_assign_font_opts:Nn + { + \tl_set_eq:NN \l_xtxko_font_opts_tl \l_xtxko_font_opts_init_tl + \keys_set_known:nxN { xtxko-font } {#2} \l_xtxko_rem_tl + \tl_set_eq:NN #1 \l_xtxko_font_opts_tl + } +\cs_generate_variant:Nn \__xtxko_assign_font_opts:Nn { c } %%%%%%%%%%%%%%%%%%%% % user font commands -\protected\def\setmainhangulfont - {\@ifnextchar[\@setmainhangulfont{\@setmainhangulfont[]}} -\def\@setmainhangulfont[#1]{% - \def\kormainfont{\XK@main@hangul@font\XK@main@hangul@options}% - \XK@font@options{}% - \setkeys*[xtxko]{font}{#1}% - \edef\XK@main@hangul@options{\the\XK@font@options}% - \expandafter\newfontfamily\expandafter\XK@main@hangul@font\expandafter[\XKV@rm]} - -\protected\def\setsanshangulfont - {\@ifnextchar[\@setsanshangulfont{\@setsanshangulfont[]}} -\def\@setsanshangulfont[#1]{% - \def\korsansfont{\XK@sans@hangul@font\XK@sans@hangul@options}% - \XK@font@options{}% - \setkeys*[xtxko]{font}{#1}% - \edef\XK@sans@hangul@options{\the\XK@font@options}% - \expandafter\newfontfamily\expandafter\XK@sans@hangul@font\expandafter[\XKV@rm]} - -\protected\def\setmonohangulfont{\newfontfamily\kormonofont} - -\protected\def\setmainhanjafont - {\@ifnextchar[\@setmainhanjafont{\@setmainhanjafont[]}} -\def\@setmainhanjafont[#1]{% - \def\hnjmainfont{\XK@main@hanja@font\XK@main@hanja@options}% - \XK@font@options{}% - \setkeys*[xtxko]{font}{#1}% - \edef\XK@main@hanja@options{\the\XK@font@options}% - \expandafter\newfontfamily\expandafter\XK@main@hanja@font\expandafter[\XKV@rm]} - -\protected\def\setsanshanjafont - {\@ifnextchar[\@setsanshanjafont{\@setsanshanjafont[]}} -\def\@setsanshanjafont[#1]{% - \def\hnjsansfont{\XK@sans@hanja@font\XK@sans@hanja@options}% - \XK@font@options{}% - \setkeys*[xtxko]{font}{#1}% - \edef\XK@sans@hanja@options{\the\XK@font@options}% - \expandafter\newfontfamily\expandafter\XK@sans@hanja@font\expandafter[\XKV@rm]} - -\protected\def\setmonohanjafont {\newfontfamily\hnjmonofont} - -% adhochangulfont/adhochanjafont, hangulfontspec/hanjafontspec -\protected\def\adhochangulfont{\@ifnextchar[\@adhochangulfont{\@adhochangulfont[]}} -\def\@adhochangulfont[#1]{% - \def\XKhangulfont{% - \XK@storeltnfont\chardef\XKcurrentfont\@ne - \XK@adhoc@hangul@font\XK@adhoc@hangul@options - \XK@storecjkfont - }% - \XK@font@options{}% - \setkeys*[xtxko]{font}{#1}% - \edef\XK@adhoc@hangul@options{\the\XK@font@options}% - \expandafter\newfontfamily\expandafter\XK@adhoc@hangul@font\expandafter[\XKV@rm]} -\let\hangulfontspec\adhochangulfont - -\protected\def\adhochanjafont{\@ifnextchar[\@adhochanjafont{\@adhochanjafont[]}} -\def\@adhochanjafont[#1]{% - \def\XKhanjafont{% - \XK@storeltnfont\chardef\XKcurrentfont\tw@ - \XK@adhoc@hanja@font\XK@adhoc@hanja@options - \XK@storecjkfont - }% - \XK@font@options{}% - \setkeys*[xtxko]{font}{#1}% - \edef\XK@adhoc@hanja@options{\the\XK@font@options}% - \expandafter\newfontfamily\expandafter\XK@adhoc@hanja@font\expandafter[\XKV@rm]} -\let\hanjafontspec\adhochanjafont - -% newhangulfontfamily/newhanjafontfamily -\def\XK@newfont@family{XK@newfont@family} -\def\XK@newfont@options{XK@newfont@options} - -\protected\def\newhangulfontfamily#1{% - \@ifnextchar[{\@newhangulfontfamily#1}{\@newhangulfontfamily#1[]}} -\def\@newhangulfontfamily#1[#2]{% - \protected\def#1{\def\XKhangulfont{% - \XK@storeltnfont\chardef\XKcurrentfont\@ne - \csname\XK@newfont@family \string#1\endcsname - \csname\XK@newfont@options\string#1\endcsname - \XK@storecjkfont - }}% - \XK@font@options{}% - \setkeys*[xtxko]{font}{#2}% - \expandafter\edef\csname\XK@newfont@options\string#1\endcsname - {\the\XK@font@options}% - \expandafter\expandafter\expandafter\newfontfamily\expandafter - \csname\expandafter\XK@newfont@family\expandafter - \string\expandafter#1\expandafter\endcsname\expandafter[\XKV@rm]} - -\protected\def\newhanjafontfamily#1{% - \@ifnextchar[{\@newhanjafontfamily#1}{\@newhanjafontfamily#1[]}} -\def\@newhanjafontfamily#1[#2]{% - \protected\def#1{\def\XKhanjafont{% - \XK@storeltnfont\chardef\XKcurrentfont\tw@ - \csname\XK@newfont@family\string#1\endcsname - \csname\XK@newfont@options\string#1\endcsname - \XK@storecjkfont - }}% - \XK@font@options{}% - \setkeys*[xtxko]{font}{#2}% - \expandafter\edef\csname\XK@newfont@options\string#1\endcsname - {\the\XK@font@options}% - \expandafter\expandafter\expandafter\newfontfamily\expandafter - \csname\expandafter\XK@newfont@family\expandafter - \string\expandafter#1\expandafter\endcsname\expandafter[\XKV@rm]} - -% newhangulfontface/newhanjafontface -\protected\def\newhangulfontface#1{% - \@ifnextchar[{\@newhangulfontface#1}{\@newhangulfontface#1[]}} -\def\@newhangulfontface#1[#2]{% - \protected\def#1{\def\XKhangulfont{% - \XK@storeltnfont\chardef\XKcurrentfont\@ne - \csname\XK@newfont@family\string#1\endcsname - \csname\XK@newfont@options\string#1\endcsname - \XK@storecjkfont - }}% - \XK@font@options{}% - \setkeys*[xtxko]{font}{#2}% - \expandafter\edef\csname\XK@newfont@options\string#1\endcsname - {\the\XK@font@options}% - \expandafter\expandafter\expandafter\newfontface\expandafter - \csname\expandafter\XK@newfont@family\expandafter - \string\expandafter#1\expandafter\endcsname\expandafter[\XKV@rm]} - -\protected\def\newhanjafontface#1{% - \@ifnextchar[{\@newhanjafontface#1}{\@newhanjafontface#1[]}} -\def\@newhanjafontface#1[#2]{% - \protected\def#1{\def\XKhanjafont{% - \XK@storeltnfont - \chardef\XKcurrentfont\tw@ - \csname\XK@newfont@family\string#1\endcsname - \csname\XK@newfont@options\string#1\endcsname - \XK@storecjkfont - }}% - \XK@font@options{}% - \setkeys*[xtxko]{font}{#2}% - \expandafter\edef\csname\XK@newfont@options\string#1\endcsname - {\the\XK@font@options}% - \expandafter\expandafter\expandafter\newfontface\expandafter - \csname\expandafter\XK@newfont@family\expandafter - \string\expandafter#1\expandafter\endcsname\expandafter[\XKV@rm]} - -% addhangulfontfeature/addhanjafontfeature -\protected\def\addhangulfontfeature#1{% - \begingroup - \XKhangulfont - \unpresetkeys[xtxko]{font}% - \XK@font@options{}% - \setkeys*[xtxko]{font}{#1}% - \global\toks@\expandafter{\the\XK@font@options}% - \addfontfeature{\XKV@rm}% - \global\let\XK@curr@family\f@family - \endgroup - \edef\XKhangulfont{\unexpanded\expandafter{\XKhangulfont\fontfamily}{\XK@curr@family}% - \noexpand\selectfont\the\toks@}% -} -\let\addhangulfontfeatures\addhangulfontfeature - -\protected\def\addhanjafontfeature#1{% - \begingroup - \XKhanjafont - \unpresetkeys[xtxko]{font}% - \XK@font@options{}% - \setkeys*[xtxko]{font}{#1}% - \global\toks@\expandafter{\the\XK@font@options}% - \addfontfeature{\XKV@rm}% - \global\let\XK@curr@family\f@family - \endgroup - \edef\XKhanjafont{\unexpanded\expandafter{\XKhanjafont\fontfamily}{\XK@curr@family}% - \noexpand\selectfont\the\toks@}% -} -\let\addhanjafontfeatures\addhanjafontfeature - +\DeclareDocumentCommand \setmainhangulfont { O{} m } + { + \__xtxko_assign_font_opts:Nn \XK@main@hangul@options {#1} + \newfontfamily \XK@main@hangul@font [\l_xtxko_rem_tl] {#2} + \tl_set:Nn \kormainfont {\XK@main@hangul@font \XK@main@hangul@options} + \ignorespaces + } +\DeclareDocumentCommand \setsanshangulfont { O{} m } + { + \__xtxko_assign_font_opts:Nn \XK@sans@hangul@options {#1} + \newfontfamily \XK@sans@hangul@font [\l_xtxko_rem_tl] {#2} + \tl_set:Nn \korsansfont {\XK@sans@hangul@font \XK@sans@hangul@options} + \ignorespaces + } +\DeclareDocumentCommand \setmonohangulfont { O{} m } + { + \newfontfamily \kormonofont [#1] {#2} + \ignorespaces + } +\DeclareDocumentCommand \setmainhanjafont { O{} m } + { + \__xtxko_assign_font_opts:Nn \XK@main@hanja@options {#1} + \newfontfamily \XK@main@hanja@font [\l_xtxko_rem_tl] {#2} + \tl_set:Nn \hnjmainfont {\XK@main@hanja@font \XK@main@hanja@options} + \ignorespaces + } +\DeclareDocumentCommand \setsanshanjafont { O{} m } + { + \__xtxko_assign_font_opts:Nn \XK@sans@hanja@options {#1} + \newfontfamily \XK@sans@hanja@font [\l_xtxko_rem_tl] {#2} + \tl_set:Nn \hnjsansfont {\XK@sans@hanja@font \XK@sans@hanja@options} + \ignorespaces + } +\DeclareDocumentCommand \setmonohanjafont { O{} m } + { + \newfontfamily \hnjmonofont [#1] {#2} + \ignorespaces + } +%% {hangul,hanja}fontspec = adhoc{hangul,hanja}font +\DeclareDocumentCommand \adhochangulfont { O{} m } + { + \__xtxko_assign_font_opts:Nn \XK@adhoc@hangul@options {#1} + \newfontfamily \XK@adhoc@hangul@font [\l_xtxko_rem_tl] {#2} + \tl_set:Nn \XKhangulfont + { + \XK@storeltnfont + \tl_set_eq:NN \XKcurrentfont \c_one + \XK@adhoc@hangul@font \XK@adhoc@hangul@options + \XK@storecjkfont + } + \ignorespaces + } +\cs_set_eq:NN \hangulfontspec \adhochangulfont +\DeclareDocumentCommand \adhochanjafont { O{} m } + { + \__xtxko_assign_font_opts:Nn \XK@adhoc@hanja@options {#1} + \newfontfamily \XK@adhoc@hanja@font [\l_xtxko_rem_tl] {#2} + \tl_set:Nn \XKhanjafont + { + \XK@storeltnfont + \tl_set_eq:NN \XKcurrentfont \c_two + \XK@adhoc@hanja@font \XK@adhoc@hanja@options + \XK@storecjkfont + } + \ignorespaces + } +\cs_set_eq:NN \hanjafontspec \adhochanjafont +%% new{hangul,hanja}font{family,face} +\DeclareDocumentCommand \newhangulfontfamily { m O{} m } + { + \__xtxko_assign_font_opts:cn { XK@newfont@options \token_to_str:N #1 } {#2} + \exp_after:wN \newfontfamily + \cs:w XK@newfont@family \token_to_str:N #1 \cs_end: [\l_xtxko_rem_tl] {#3} + \DeclareRobustCommand #1 + { + \tl_set:Nn \XKhangulfont + { + \XK@storeltnfont + \tl_set_eq:NN \XKcurrentfont \c_one + \use:c { XK@newfont@family \token_to_str:N #1 } + \use:c { XK@newfont@options \token_to_str:N #1 } + \XK@storecjkfont + } + } + } +\DeclareDocumentCommand \newhanjafontfamily { m O{} m } + { + \__xtxko_assign_font_opts:cn { XK@newfont@options \token_to_str:N #1 } {#2} + \exp_after:wN \newfontfamily + \cs:w XK@newfont@family \token_to_str:N #1 \cs_end: [\l_xtxko_rem_tl] {#3} + \DeclareRobustCommand #1 + { + \tl_set:Nn \XKhanjafont + { + \XK@storeltnfont + \tl_set_eq:NN \XKcurrentfont \c_two + \use:c { XK@newfont@family \token_to_str:N #1 } + \use:c { XK@newfont@options \token_to_str:N #1 } + \XK@storecjkfont + } + } + } +\DeclareDocumentCommand \newhangulfontface { m O{} m } + { + \__xtxko_assign_font_opts:cn { XK@newfont@options \token_to_str:N #1 } {#2} + \exp_after:wN \newfontface + \cs:w XK@newfont@family \token_to_str:N #1 \cs_end: [\l_xtxko_rem_tl] {#3} + \DeclareRobustCommand #1 + { + \tl_set:Nn \XKhangulfont + { + \XK@storeltnfont + \tl_set_eq:NN \XKcurrentfont \c_one + \use:c { XK@newfont@family \token_to_str:N #1 } + \use:c { XK@newfont@options \token_to_str:N #1 } + \XK@storecjkfont + } + } + } +\DeclareDocumentCommand \newhanjafontface { m O{} m } + { + \__xtxko_assign_font_opts:cn { XK@newfont@options \token_to_str:N #1 } {#2} + \exp_after:wN \newfontface + \cs:w XK@newfont@family \token_to_str:N #1 \cs_end: [\l_xtxko_rem_tl] {#3} + \DeclareRobustCommand #1 + { + \tl_set:Nn \XKhanjafont + { + \XK@storeltnfont + \tl_set_eq:NN \XKcurrentfont \c_two + \use:c { XK@newfont@family \token_to_str:N #1 } + \use:c { XK@newfont@options \token_to_str:N #1 } + \XK@storecjkfont + } + } + } +%% add{hangul,hanja}fontfeature[s] +\DeclareDocumentCommand \addhangulfontfeature { m } + { + \group_begin: + \XKhangulfont + \tl_clear:N \l_xtxko_font_opts_tl + \keys_set_known:nxN { xtxko-font } {#1} \l_xtxko_rem_tl + \addfontfeature {\l_xtxko_rem_tl} + \use:x + { + \group_end: + \exp_not:N \tl_set:Nn \exp_not:N \XKhangulfont + { + \exp_not:N \XK@storeltnfont + \exp_not:N \tl_set_eq:NN \exp_not:N \XKcurrentfont \exp_not:N \c_one + \exp_not:N \fontfamily { \f@family } \exp_not:N \selectfont + \exp_not:V \l_xtxko_font_opts_tl + \exp_not:N \XK@storecjkfont + } + } + \ignorespaces + } +\cs_set_eq:NN \addhangulfontfeatures \addhangulfontfeature +\DeclareDocumentCommand \addhanjafontfeature { m } + { + \group_begin: + \XKhanjafont + \tl_clear:N \l_xtxko_font_opts_tl + \keys_set_known:nxN { xtxko-font } {#1} \l_xtxko_rem_tl + \addfontfeature {\l_xtxko_rem_tl} + \use:x + { + \group_end: + \exp_not:N \tl_set:Nn \exp_not:N \XKhanjafont + { + \exp_not:N \XK@storeltnfont + \exp_not:N \tl_set_eq:NN \exp_not:N \XKcurrentfont \exp_not:N \c_two + \exp_not:N \fontfamily { \f@family } \exp_not:N \selectfont + \exp_not:V \l_xtxko_font_opts_tl + \exp_not:N \XK@storecjkfont + } + } + \ignorespaces + } +\cs_set_eq:NN \addhanjafontfeatures \addhanjafontfeature +%% math hangul font +\DeclareDocumentCommand \setmathhangulfont { O{} m } + { + \fontspec_set_family:Nnn \xetexko@math@hangul@family {#1} {#2} + } %%%%%%%%%%%%%%%%%%%% %% xetexkofontregime -\define@key[xtxko]{char}{alphs}{\csname #1alphs\endcsname} -\define@key[xtxko]{char}{nums}{\csname #1nums\endcsname} -\define@key[xtxko]{char}{parens}{\csname #1parens\endcsname} -\define@key[xtxko]{char}{quotes}{\csname #1quotes\endcsname} -\define@key[xtxko]{char}{puncts}{\csname #1puncts\endcsname} -\define@key[xtxko]{char}{colons}{\csname #1colons\endcsname} -\define@key[xtxko]{char}{hyphens}{\csname #1hyphens\endcsname} -\define@key[xtxko]{char}{cjksymbols}{\csname #1cjksymbols\endcsname} - -\protected\def\xetexkofontregime{% - \@ifnextchar[\@xetexkofontregime{\@xetexkofontregime[]}} -\def\@xetexkofontregime[#1]#2{% - \csname #2marks\endcsname - \setkeys*[xtxko]{char}{#1}} +\keys_define:nn { xtxko-char } + { + alphs .code:n = \use:c { #1alphs } , + nums .code:n = \use:c { #1nums } , + parens .code:n = \use:c { #1parens } , + quotes .code:n = \use:c { #1quotes } , + puncts .code:n = \use:c { #1puncts } , + colons .code:n = \use:c { #1colons } , + hyphens .code:n = \use:c { #1hyphens } , + cjksymbols .code:n = \use:c { #1cjksymbols } , + } +\DeclareDocumentCommand \xetexkofontregime { O{} m } + { + \use:c { #2marks } + \keys_set:nn { xtxko-char } { #1 } + } +\ExplSyntaxOff %%%%%%%%%%%%%%%%%%%%%%%%%% % set unfonts if [unfonts] @@ -319,8 +364,12 @@ %%%%%%%%%%%%%%%%%%%%%%%%%% % font switching for latex -\def\XKstoreprevfont{\ifx\f@family\XKcjkprevfont\let\f@family\XKltnprevfont\fi} -\def\XK@storeltnfont{\ifx\f@family\XKcjkprevfont\else\let\XKltnprevfont\f@family\fi} +\def\XKstoreprevfont{% + \ifx\f@family\XKcjkprevfont\let\f@family\XKltnprevfont\fi +} +\def\XK@storeltnfont{% + \ifx\f@family\XKcjkprevfont\else\let\XKltnprevfont\f@family\fi +} \def\XK@storecjkfont{% \let\XKcjkprevfont\f@family \edef\XKplaincjkprevfont{\the\font}% @@ -372,7 +421,9 @@ \edef\rmfamily{\unexpanded\expandafter{\rmfamily\XK@rm@korean@font}} \edef\sffamily{\unexpanded\expandafter{\sffamily\XK@sf@korean@font}} -\edef\ttfamily{\unexpanded\expandafter{\ttfamily\XK@tt@korean@font\disablehangulspacing}} +\edef\ttfamily{\unexpanded\expandafter{\ttfamily + \XK@tt@korean@font\disablehangulspacing +}} \edef\verbatim@font{\unexpanded\expandafter{\verbatim@font \disablehangulspacingandlinebreak \let\XKstoreprevfont\XKlatinfont @@ -380,23 +431,21 @@ \expandafter\ifx\familydefault\rmdefault \XK@rm@korean@font - \protected\edef\normalfont{\unexpanded\expandafter{\normalfont\XK@rm@korean@font}} + \protected\edef\normalfont{\unexpanded\expandafter{\normalfont + \XK@rm@korean@font}} \else \expandafter\ifx\familydefault\sfdefault \XK@sf@korean@font - \protected\edef\normalfont{\unexpanded\expandafter{\normalfont\XK@sf@korean@font}} + \protected\edef\normalfont{\unexpanded\expandafter{\normalfont + \XK@sf@korean@font}} \else \XK@tt@korean@font - \protected\edef\normalfont{\unexpanded\expandafter{\normalfont\XK@tt@korean@font}} + \protected\edef\normalfont{\unexpanded\expandafter{\normalfont + \XK@tt@korean@font}} \fi\fi \let\reset@font\normalfont %%%%%%%%%%%%%%%%%%%%% % hangul in math mode -\def\setmathhangulfont{% - \@ifnextchar[{\setmathhangulfont@}{\setmathhangulfont@[]}} -\def\setmathhangulfont@[#1]#2{% - \zf@fontspec{#1}{#2}% - \xdef\xetexko@math@hangul@family{\zf@family}} \AtBeginDocument{% \begingroup \ifx\xetexko@math@hangul@family\undefined |