%
% luatexja-fontspec.sty
%

\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{luatexja-fontspec}[2017/06/25 fontspec support of LuaTeX-ja]
\RequirePackage{l3keys2e,luatexja}
\ExplSyntaxOn

%%%%%%%% \g_ltj_fontspec_scale_fp
%% Default scale value for jfont.
\fp_new:N \g_ltj_fontspec_scale_fp
\group_begin:
\fontsize{16}{16}\selectfont
\fp_gset:Nn \g_ltj_fontspec_scale_fp {\zw / 16}
\group_end:

\bool_new:N \ltj_fontspec_match_bool
\keys_define:nn { luatexja-fontspec }
  {
    match .bool_set:N = \ltj_fontspec_match_bool,
    match .default:n  = true,
    pass .code:n = \PassOptionsToPackage{#1} {fontspec},
      % 互換性のために残したオプション
    scale .fp_gset:N = \g_ltj_fontspec_scale_fp,
    unknown .code:n = \PassOptionsToPackage { \l_keys_key_tl } {fontspec},
  }
\ProcessKeysOptions{ luatexja-fontspec }
\RequirePackage{fontspec}[2017/01/01]% v2.5c
\RequirePackage{luatexja-fontspec-25c}
%\@ifpackagelater{fontspec}{2017/01/01}%
%  {\RequirePackage{luatexja-fontspec-25c}}% v2.5c
%  {\RequirePackage{luatexja-fontspec-24}}% --v2.5a

\ExplSyntaxOff
%%%%%%%% Now we completely ignore kanjifont definition file.
\def\@ltj@use@fd{false}

% We must redefine \try@load@fontshape to ignore kanjifont definitions at all.
\def\try@load@fontshape{%
   \expandafter
   \ifx\csname \f@encoding+\f@family\endcsname\relax
       \directlua{luatexja.jfont.is_kenc('\luatexluaescapestring{\f@encoding}')}%
\ifin@\else % Alphabetic font
    \@font@info{Try loading font information for \f@encoding+\f@family}%
    \global\expandafter\let
       \csname\f@encoding+\f@family\endcsname\@empty
     \nfss@catcodes
     \let\nfss@catcodes\relax
     \edef\reserved@a{%
       \lowercase{%
         \noexpand\InputIfFileExists{\f@encoding\f@family.fd}}}%
     \reserved@a\relax
          {\@input@{\f@encoding\f@family.fd}}%
\fi
   \fi}

\endinput
