%
% lltjp-fontspec.sty 2020-01-13
%

\NeedsTeXFormat{LaTeX2e}

\RequirePackage{fontspec}
\ExplSyntaxOn

%%%%%%%% fontspec v2.5c overwrites \rmfamily etc. in \setmainfont
\@ifpackagelater{fontspec}{2020/01/09}{ %% 2.7e or later
  \tl_replace_all:cnn { rmfamily~ } { \fontfamily }{ \romanfamily }
  \tl_replace_all:cnn { sffamily~ } { \fontfamily }{ \romanfamily }
  \tl_replace_all:cnn { ttfamily~ } { \fontfamily }{ \romanfamily }
  \typeout{LATEX~ 2019-10-01!}
  \cs_if_exist:NF \@rmfamilyhook {
    \tl_replace_all:cnn { rmfamily~ } { \selectfont } {
      \if@ltj@match@family
        \prepare@family@series@update@kanji{mc}\mcdefault
      \fi\selectfont
    }
    \tl_replace_all:cnn { sffamily~ } { \selectfont } {
      \if@ltj@match@family
        \prepare@family@series@update@kanji{gt}\gtdefault
      \fi\selectfont
    }
    \tl_replace_all:cnn { ttfamily~ } { \selectfont } {
      \if@ltj@match@family
        \prepare@family@series@update@kanji{jtt}\jttdefault
      \fi\selectfont
    }
  }
%% end of 2.7e (or later)
}{\@ifpackagelater{fontspec}{2019/10/19}{ %% 2.7d
\cs_set:Nn \__fontspec_main_setmainfont:nn
  {
    \fontspec_set_family:Nnn \l__fontspec_rmfamily_family_tl {#1} {#2}
    \tl_set_eq:NN \rmdefault \l__fontspec_rmfamily_family_tl
    \use:x
      {
        \exp_not:n { \DeclareRobustCommand \rmfamily }
          {
            \exp_not:N \fontencoding { \g__fontspec_nfss_enc_tl }
            \exp_not:N \fontfamily { \exp_not:N \rmdefault }
    \exp_not:N\if@ltj@match@family\exp_not:N\kanjifamily\exp_not:N\mcdefault\exp_not:N\fi%%%
            \exp_not:N \selectfont
          }
      }
    \str_if_eq:eeT {\familydefault} {\rmdefault}
      { \tl_set_eq:NN \encodingdefault \g__fontspec_nfss_enc_tl }
    \__fontspec_setmainfont_hook:nn {#1} {#2}
    \normalfont
  }
\cs_set:Nn \__fontspec_main_setsansfont:nn
  {
    \fontspec_set_family:Nnn \l__fontspec_sffamily_family_tl {#1} {#2}
    \tl_set_eq:NN \sfdefault \l__fontspec_sffamily_family_tl
    \use:x
      {
        \exp_not:n { \DeclareRobustCommand \sffamily }
          {
            \exp_not:N \fontencoding { \g__fontspec_nfss_enc_tl }
            \exp_not:N \fontfamily { \exp_not:N \sfdefault  }
    \exp_not:N\if@ltj@match@family\exp_not:N\kanjifamily\exp_not:N\gtdefault\exp_not:N\fi%%%
            \exp_not:N \selectfont
          }
      }
    \str_if_eq:eeT {\familydefault} {\sfdefault}
      { \tl_set_eq:NN \encodingdefault \g__fontspec_nfss_enc_tl }
    \__fontspec_setsansfont_hook:nn {#1} {#2}
    \normalfont
  }
\cs_set:Nn \__fontspec_main_setmonofont:nn
  {
    \fontspec_set_family:Nnn \l__fontspec_ttfamily_family_tl {#1} {#2}
    \tl_set_eq:NN \ttdefault \l__fontspec_ttfamily_family_tl
    \use:x
      {
        \exp_not:n { \DeclareRobustCommand \ttfamily }
          {
            \exp_not:N \fontencoding { \g__fontspec_nfss_enc_tl }
            \exp_not:N \fontfamily {  \exp_not:N \ttdefault }
    \exp_not:N\if@ltj@match@family\exp_not:N\kanjifamily\exp_not:N\jttdefault\exp_not:N\fi%%%
            \exp_not:N \selectfont
          }
      }
    \str_if_eq:eeT {\familydefault} {\ttdefault}
      { \tl_set_eq:NN \encodingdefault \g__fontspec_nfss_enc_tl }
    \__fontspec_setmonofont_hook:nn {#1} {#2}
    \normalfont
  }
%% end of 2.7d
}{%% 2.7c
\cs_set:Nn \__fontspec_main_setmainfont:nn
  {
    \fontspec_set_family:Nnn \l__fontspec_rmfamily_family_tl {#1} {#2}
    \tl_set_eq:NN \rmdefault \l__fontspec_rmfamily_family_tl
    \use:x
      {
        \exp_not:n { \DeclareRobustCommand \rmfamily }
          {
            \exp_not:N \fontencoding { \g__fontspec_nfss_enc_tl }
            \exp_not:N \fontfamily { \l__fontspec_rmfamily_family_tl }
    \exp_not:N\if@ltj@match@family\exp_not:N\kanjifamily\exp_not:N\mcdefault\exp_not:N\fi%%%
            \exp_not:N \selectfont
          }
      }
    \str_if_eq:eeT {\familydefault} {\rmdefault}
      { \tl_set_eq:NN \encodingdefault \g__fontspec_nfss_enc_tl }
    \__fontspec_setmainfont_hook:nn {#1} {#2}
    \normalfont
  }
\cs_set:Nn \__fontspec_main_setsansfont:nn
  {
    \fontspec_set_family:Nnn \l__fontspec_sffamily_family_tl {#1} {#2}
    \tl_set_eq:NN \sfdefault \l__fontspec_sffamily_family_tl
    \use:x
      {
        \exp_not:n { \DeclareRobustCommand \sffamily }
          {
            \exp_not:N \fontencoding { \g__fontspec_nfss_enc_tl }
            \exp_not:N \fontfamily { \l__fontspec_sffamily_family_tl }
    \exp_not:N\if@ltj@match@family\exp_not:N\kanjifamily\exp_not:N\gtdefault\exp_not:N\fi%%%
            \exp_not:N \selectfont
          }
      }
    \str_if_eq:eeT {\familydefault} {\sfdefault}
      { \tl_set_eq:NN \encodingdefault \g__fontspec_nfss_enc_tl }
    \__fontspec_setsansfont_hook:nn {#1} {#2}
    \normalfont
  }
\cs_set:Nn \__fontspec_main_setmonofont:nn
  {
    \fontspec_set_family:Nnn \l__fontspec_ttfamily_family_tl {#1} {#2}
    \tl_set_eq:NN \ttdefault \l__fontspec_ttfamily_family_tl
    \use:x
      {
        \exp_not:n { \DeclareRobustCommand \ttfamily }
          {
            \exp_not:N \fontencoding { \g__fontspec_nfss_enc_tl }
            \exp_not:N \fontfamily { \l__fontspec_ttfamily_family_tl }
    \exp_not:N\if@ltj@match@family\exp_not:N\kanjifamily\exp_not:N\jttdefault\exp_not:N\fi%%%
            \exp_not:N \selectfont
          }
      }
    \str_if_eq:eeT {\familydefault} {\ttdefault}
      { \tl_set_eq:NN \encodingdefault \g__fontspec_nfss_enc_tl }
    \__fontspec_setmonofont_hook:nn {#1} {#2}
    \normalfont
  }
%% end of 2.7d
}}

\cs_set:Nn \fontspec_visible_space:
 {
 \__fontspec_primitive_font_glyph_if_exist:NnTF \font {"2423}
   { \ltjalchar"2423\scan_stop: }
   { \fontspec_visible_space_fallback: }
 }

\cs_set:Npn \emshape { \gtfamily \itshape }
\cs_set:Npn \eminnershape { \mcfamily \upshape }

\ExplSyntaxOff
\expandafter\patchcmd\csname TU\string\textasteriskcentered\endcsname{\char}{\ltjalchar}{}{}

\endinput

