Assume I would like to change the font for a section of text, e.g. use Bookman for both headings and paragraphs (similarly to the explanations in this community wiki guide).
If I change the \familydefault, as in section (1), only headings are affected. If on the other hand I select Bookman as the \fontfamily, it affects only paragraph text but not headings (2). Combining both commands gives the desired result (3), as does adding a \normalfont command to \familydefault* (4).
What causes this behaviour? Does \fontfamily set some "currentfont" variable which is not accessed when headings are formatted? And why does changing \familydefault immediately affect headings, but not text?
*This was pointed out in a comment by @mpg.

\documentclass{article}
\usepackage[T1]{fontenc}
%print a _short section of lipsum text
\newcommand{\shlipsum}{%
\section{A quick brown fox}
Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Ut purus elit, vestibulum ut, placerat ac, adipiscing vitae, felis. Curabitur dictum gravida mauris. Nam arcu libero, nonummy eget, consectetuer id, vulputate a, magna.\\%
}
%reset font to typewriter CM
\newcommand{\resetfont}{\renewcommand{\familydefault}{cmtt}\normalfont}
\begin{document}
\resetfont
\renewcommand{\familydefault}{pbk} %sets heading only
\shlipsum
\resetfont
\fontfamily{pbk}\selectfont %sets paragraph text only
\shlipsum
\resetfont
\renewcommand{\familydefault}{pbk}
\fontfamily{pbk}\selectfont
\shlipsum
\resetfont
\renewcommand{\familydefault}{pbk}
\normalfont
\shlipsum
\end{document}
\fontfamily, i.e. what is its identifier? – dgs Jun 08 '12 at 15:44\DeclareRobustCommand\fontfamily[1]{\edef\f@family{#1}}so\f@familybut you wouldn't normally need to look at that directly – David Carlisle Jun 08 '12 at 16:13\fontfamily{pbk}\selectfontworks fine with pdfLaTeX engine but does not with XeLaTeX. – Say OL Apr 13 '18 at 02:02\fontencoding{T1}but this is not solve the problem since I am planing to use it with complex-script language, Khmer, which requiresTUfont encoding. So in order to usepbkand others, do we require to defineTUfor those fonts? – Say OL Apr 13 '18 at 09:33pbkare so things work on an IBM PC using 8 letter filenames in 1990. using xetex this century you have no need for it at all. You can refer to your fonts by their natural names. using the fontspec package, you should almost never need to be setting low level macros like\fontfamilyor\fontencodingby hand. – David Carlisle Apr 13 '18 at 10:08