In the post Fake small caps with XeTeX/fontspec? I have found the following definitions to fake small caps
\def\mycommand{\bgroup\obeyspaces\mycommandaux}
\def\mycommandaux#1{\mycommandauxii #1\relax\relax\egroup}
\def\mycommandauxii#1{%
\ifx\relax#1\else
\ifcat#1\@sptoken{}
\expandafter\expandafter\expandafter\mycommandauxii\else
\ifnum`#1=\uccode`#1 {\normalsize #1}\else {\footnotesize \uppercase{#1}}\fi
\expandafter\expandafter\expandafter\mycommandauxii\expandafter\fi\fi}
% ...
\mycommand{This text is set in fake small caps.}
\mycommand works properly in the main text. However, when \mycommand is used inside other commands like \title of \footnote it removes the spaces between the words.
So I wonder if there is any way to make the above command to work inside other commands or if there are other ways to achieve the same result.
In the code above \normalsize and \footnotesize can be replaced some \fontspec instructions. An advantage of the approach (or similar) is that it could work for generic fonts without small caps (I am aware of fontinst and the support for creating small caps in fontforge)

\titleor\footnote. – Alan Munn Jul 25 '12 at 04:18\obeyspacesalters the tokenization of spaces. You need to use an alternative token-by-token mapping that respects spaces. These are always a bit tricky! – Joseph Wright Jul 25 '12 at 06:13fontinst. (In fact, it will probably have significant disadvantages even over and above those which apply to that method.) Given that we have access to fonts with proper small-caps, it seems a shame to encourage the use of faked ones. (Just as faked slanted shapes are an extremely poor substitute for true italics.) – cfr Mar 10 '14 at 03:56