I'm trying to change \textsc to produce small caps from a different font. The font pajp is used for the main text, but it doesn't have small caps. The font paj contains small caps, but I don't want to use anything else from that font.
The current and edited MWE:
\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage{pdftexcmds}
\renewcommand{\sfdefault}{paj}
\makeatletter
\let\scshape\relax % to avoid a warning
\DeclareRobustCommand\scshape{%
\not@math@alphabet\scshape\relax
\ifnum\pdf@strcmp{\f@family}{\familydefault}=\z@
\fontfamily{paj}%
\fi
\fontshape\scdefault\selectfont}
\makeatother
\begin{document}
% This font contains small caps that I want to use
% Shows T1/paj/m/sc is defined
\usefont{T1}{paj}{m}{sc}
\fontsize{14pt}{1em}\selectfont
Lorem ipsum dolor (small caps)
% This font is used for everything else and doesn't contain small caps
% Shows T1/pajp/m/n is defined
% When using this \scshape and \textsc don't work
\usefont{T1}{pajp}{m}{n}
\fontsize{14pt}{1em}\selectfont
Lorem ipsum dolor (regular)\\
% Set the default family
\renewcommand{\familydefault}{pjap}
\fontfamily{\familydefault}\selectfont
% This doesn't work
%\fontfamily{pajp}\selectfont
%This is the standard small caps font:
%{\fontshape\scdefault\selectfont Small Caps}
This is the new one: {\scshape Small Caps}
This is the new one: \textsc{Small Caps}
\sffamily
Let's try \textsc{Small Caps}
\end{document}
The first image is from the MWE as above. It works. The second image is produced if I use commented out \usefont{T1}{pajp}{m}{n} or \fontfamily{pajp}\selectfont to select the regular font. It doesn't have the correct font as the small caps one.

In the latter case the error messages are:
LaTeX Font Warning: Font shape `T1/pajp/m/sc' undefined
(Font) using `T1/pajp/m/n' instead on input line 41.
LaTeX Font Warning: Font shape `T1/pajp/m/sc' undefined
(Font) using `T1/pajp/m/n' instead on input line 43.

\familydefaulttopajpand in the redefinition of\scshapeusepajwhere I usedqbk. – egreg Jul 26 '14 at 21:42\DeclareRobustCommand{\scshape}{...}in\AtBeginDocument{...}– egreg Aug 16 '21 at 14:53