A bug of luatexja-fontspec
After Running the following example, you will see that the font of test is not changed to \ttfamily.
\documentclass{article} \usepackage{luatexja-fontspec} \begin{document} \ttfamily test \end{document}
It seems that this bug is caused by the redefinition of \fontfamily:
%%%%%%%% Now we completely ignore kanjifont definition file. \DeclareRobustCommand\fontfamily[1]{% \@notkfamfalse\@notffamfalse \edef\tmp@item{'\luatexluaescapestring{#1}'}% \edef\tmp@enc{'\luatexluaescapestring{\f@encoding}'}% \ifcsname \k@encoding+#1\endcsname % if \k@encoding+#1 is already defined \edef\k@family{#1}% \else\@notkfamtrue\fi \ifcsname \f@encoding+#1\endcsname \edef\f@family{#1}% \else % search font definition file... \directlua{luatexja.jfont.is_ffam(\tmp@enc, \tmp@item)}% \ifin@\edef\k@family{#1}\else% \directlua{luatexja.jfont.is_Nffam(\tmp@enc, \tmp@item)}% \ifin@\@notffamtrue\else% \def\@temp##1+{\lowercase{\def\@@temp{##1#1.fd}}}\expandafter\@temp\f@encoding+% \message{(I search kanjifont definition file: \@@temp)}% \IfFileExists{\@@temp#1.fd}{\@tempswztrue}{\@tempswzfalse}% \if@tempswz \directlua{luatexja.jfont.add_ffam_list(\tmp@enc, \tmp@item)}% \edef\f@family{#1}% \else \directlua{luatexja.jfont.add_Nffam_list(\tmp@enc, \tmp@item)}% \@notffamtrue% \fi \fi \fi \fi \if@notkfam\if@notffam {\ifcsname D@\k@encoding\endcsname\@nameuse{D@\k@encoding}\fi \xdef\@@temp{\default@family}}\edef\k@family{\@@temp}% {\ifcsname D@\f@encoding\endcsname\@nameuse{D@\f@encoding}\fi \xdef\@@temp{\default@family}}\edef\f@family{\@@temp}% \fi\fi }
In line 19, {\@@temp#1.fd} should be \@@temp. I want to provide a little better patch which is fully consistent with the test in \try@load@fontshape.
\DeclareRobustCommand\fontfamily[1]{% \@notkfamfalse\@notffamfalse \edef\tmp@item{'\luatexluaescapestring{#1}'}% \edef\tmp@enc{'\luatexluaescapestring{\f@encoding}'}% \ifcsname \k@encoding+#1\endcsname % if \k@encoding+#1 is already defined \edef\k@family{#1}% \else\@notkfamtrue\fi \ifcsname \f@encoding+#1\endcsname \edef\f@family{#1}% \else % search font definition file... \directlua{luatexja.jfont.is_ffam(\tmp@enc, \tmp@item)}% \ifin@\edef\k@family{#1}\else% \directlua{luatexja.jfont.is_Nffam(\tmp@enc, \tmp@item)}% \ifin@\@notffamtrue\else% \edef\@temp{\lowercase{\noexpand\IfFileExists{\f@encoding#1.fd}}}% \@temp{\@tempswztrue}% {\IfFileExists{\f@encoding#1.fd}{\@tempswztrue}{\@tempswzfalse}}% \if@tempswz \directlua{luatexja.jfont.add_ffam_list(\tmp@enc, \tmp@item)}% \edef\f@family{#1}% \else \directlua{luatexja.jfont.add_Nffam_list(\tmp@enc, \tmp@item)}% \@notffamtrue% \fi \fi \fi \fi \if@notkfam\if@notffam {\ifcsname D@\k@encoding\endcsname\@nameuse{D@\k@encoding}\fi \xdef\@@temp{\default@family}}\edef\k@family{\@@temp}% {\ifcsname D@\f@encoding\endcsname\@nameuse{D@\f@encoding}\fi \xdef\@@temp{\default@family}}\edef\f@family{\@@temp}% \fi\fi }
In line 19, {\@@temp#1.fd} should be \@@temp.
This is already fixed in the git repository (6025952 and 124db59), but we forgot to release the bugfix. Thanks.
After Running the following example, you will see that the font of test is not changed to \ttfamily.
It seems that this bug is caused by the redefinition of \fontfamily:
In line 19, {\@@temp#1.fd} should be \@@temp. I want to provide a little better patch which is fully consistent with the test in \try@load@fontshape.
\DeclareRobustCommand\fontfamily[1]{% \@notkfamfalse\@notffamfalse \edef\tmp@item{'\luatexluaescapestring{#1}'}% \edef\tmp@enc{'\luatexluaescapestring{\f@encoding}'}% \ifcsname \k@encoding+#1\endcsname % if \k@encoding+#1 is already defined \edef\k@family{#1}% \else\@notkfamtrue\fi \ifcsname \f@encoding+#1\endcsname \edef\f@family{#1}% \else % search font definition file... \directlua{luatexja.jfont.is_ffam(\tmp@enc, \tmp@item)}% \ifin@\edef\k@family{#1}\else% \directlua{luatexja.jfont.is_Nffam(\tmp@enc, \tmp@item)}% \ifin@\@notffamtrue\else% \edef\@temp{\lowercase{\noexpand\IfFileExists{\f@encoding#1.fd}}}% \@temp{\@tempswztrue}% {\IfFileExists{\f@encoding#1.fd}{\@tempswztrue}{\@tempswzfalse}}% \if@tempswz \directlua{luatexja.jfont.add_ffam_list(\tmp@enc, \tmp@item)}% \edef\f@family{#1}% \else \directlua{luatexja.jfont.add_Nffam_list(\tmp@enc, \tmp@item)}% \@notffamtrue% \fi \fi \fi \fi \if@notkfam\if@notffam {\ifcsname D@\k@encoding\endcsname\@nameuse{D@\k@encoding}\fi \xdef\@@temp{\default@family}}\edef\k@family{\@@temp}% {\ifcsname D@\f@encoding\endcsname\@nameuse{D@\f@encoding}\fi \xdef\@@temp{\default@family}}\edef\f@family{\@@temp}% \fi\fi }