diff options
Diffstat (limited to 'language/korean/pmhanguljamo/tex/pmhanguljamo.sty')
-rw-r--r-- | language/korean/pmhanguljamo/tex/pmhanguljamo.sty | 79 |
1 files changed, 68 insertions, 11 deletions
diff --git a/language/korean/pmhanguljamo/tex/pmhanguljamo.sty b/language/korean/pmhanguljamo/tex/pmhanguljamo.sty index 89cd8f4493..59853b9dd0 100644 --- a/language/korean/pmhanguljamo/tex/pmhanguljamo.sty +++ b/language/korean/pmhanguljamo/tex/pmhanguljamo.sty @@ -2,7 +2,7 @@ %% %% Poorman's Hangul Jamo Input Method. %% -%% (C) 2020-2021 Kangsoo Kim +%% (C) 2020-2022 Kangsoo Kim %% %% This work may be distributed and/or modified under the %% conditions of the LaTeX Project Public License, either version 1.3 @@ -16,22 +16,29 @@ %% %% The Current Maintainer of this work is Kangsoo Kim %% -%% This work consists of the file pmhanguljamo.sty, pmhanguljamo-rrk.sty +%% This work consists of the style files --- pmhanguljamo.sty, pmhanguljamo-rrk.sty, %% and the documentation files pmhanguljamo-doc.tex and pmhanguljamo-doc.pdf. %% \RequirePackage{xparse} \ProvidesExplPackage {pmhanguljamo} - {2021/11/28} - {v0.4} + {2022/09/02} + {v0.5} {Poorman's Hangul Jamo Input Method} \RequirePackage{l3keys2e} +\bool_new:N \opt_usepmfont_bool +\tl_new:N \opt_pmfont_tl + \keys_define:nn { pmhanguljamo } { rrk .bool_set:N = \opt_rrkopt_bool, - RRK .bool_set:N = \opt_rrkopt_bool + RRK .bool_set:N = \opt_rrkopt_bool, + pmfont .code:n = { + \bool_gset_true:N \opt_usepmfont_bool + \tl_gset:Nn \opt_pmfont_tl { #1 } + } } \ProcessKeysOptions { pmhanguljamo } @@ -157,6 +164,26 @@ \makebox[\l_tmpa_dim][c]{ \char"318D\kern-.6em\char"318D } } +%%%% usepmfont macro + +\cs_if_exist:NTF \hangulfontspec +{ + \cs_set_eq:NN \pm_hangulfontspec \hangulfontspec +} +{ + \cs_set_eq:NN \pm_hangulfontspec \fontspec +} + +\NewDocumentCommand \usepmfont { } +{ + \bool_gset_true:N \opt_usepmfont_bool +} + +\NewDocumentCommand \setpmhangulfont { m } +{ + \tl_gset:Nn \opt_pmfont_tl { #1 } +} + %%%% if RRK is given, then input pmhanguljamo-rrk.sty %%%% and stop. @@ -179,7 +206,7 @@ \exp_args:Nno \regex_split:nnN { / } { \l_tmpa_tl } \l_tmpa_seq - \seq_indexed_map_function:NN \l_tmpa_seq \build_syl:nn + \seq_map_indexed_function:NN \l_tmpa_seq \build_syl:nn } \tl_new:N \l_cho_tl @@ -192,9 +219,9 @@ \NewDocumentEnvironment { jamotext } { +b } { \seq_set_split:Nnn \l_inputpar_seq { \par } { #1 } - \seq_indexed_map_function:NN \l_inputpar_seq \jamo_word:nn + \seq_map_indexed_function:NN \l_inputpar_seq \jamo_word:nn % \seq_set_split:Nnn \l_inputword_seq { ~ } { #1 } -% \seq_indexed_map_inline:Nn \l_inputword_seq +% \seq_map_indexed_inline:Nn \l_inputword_seq % { % \jamotextcmd { ##2 } % \int_compare:nT { ##1 < \seq_count:N \l_inputword_seq } @@ -204,7 +231,35 @@ \cs_new:Npn \jamo_word:nn #1 #2 { - \jamoword { #2 } +% \jamoword { #2 } + \seq_set_split:Nnn \l_inparpar_seq { ~ } { #2 } + + \seq_map_indexed_inline:Nn \l_inparpar_seq + { + \regex_match:nnTF { ^\!\{ } { ##2 } + { + \tl_set:Nn \l_tmpa_tl { ##2 } + \regex_match:nnTF { ^\!\{(.+?)\}$ } { ##2 } + { + \regex_replace_once:nnN { ^\!\{(.+?)\}$ } { \1 } \l_tmpa_tl + \l_tmpa_tl + } + { + \tl_set_eq:NN \l_tmpb_tl \l_tmpa_tl + \regex_replace_once:nnN { ^\!\{(.+?)\}(.*)$ } { \1 } \l_tmpa_tl + \l_tmpa_tl + \regex_replace_once:nnN { ^\!\{(.+?)\}(.*)$ } { \2 } \l_tmpb_tl + \exp_args:No \jamoword { \l_tmpb_tl } + } + } + { + \jamoword{ ##2 } + } + + \int_compare:nT { ##1 < \seq_count:N \l_inparpar_seq } + { \space } + } + \int_compare:nT { #1 < \seq_count:N \l_inputpar_seq } { \par } } @@ -212,9 +267,11 @@ \NewDocumentCommand \jamoword { m } { \seq_set_split:Nnn \l_inputword_seq { ~ } { #1 } - \seq_indexed_map_inline:Nn \l_inputword_seq + \seq_map_indexed_inline:Nn \l_inputword_seq { - \jamotextcmd { ##2 } + \bool_if:NTF \opt_usepmfont_bool + { {\pm_hangulfontspec[Script=Hangul,Renderer=OpenType]{\opt_pmfont_tl} \jamotextcmd{ ##2 } } } + { \jamotextcmd { ##2 } } \int_compare:nT { ##1 < \seq_count:N \l_inputword_seq } { \space } } |