# How to change font, size, and shape in Xelatex

Having established a document platform as:

\documentclass[10pt,b5paper,twoside]{report}
%--------------------------
%--- Packages required
%--------------------------
\usepackage{microtype}
\usepackage{lettrine}
\usepackage{fontspec}
\usepackage{fourier-orns, multido}
\usepackage{graphicx}
\usepackage{tabularx, booktabs}
\usepackage{enumitem}
\usepackage{titleps}
\usepackage[textwidth=110mm, textheight=180mm, marginratio={4:6,5:7},nofoot, nomarginpar]{geometry}
\usepackage{polyglossia}
\usepackage{setspace}

%--------------------------
%--- Set commands
%--------------------------
\defaultfontfeatures{Numbers = {OldStyle,Proportional},Ligatures = Rare, Style = Historic,
StylisticSet={1,5},WordSpace = 1.2}%

\renewpagestyle{plain} {%
}%

\pagestyle{plain}

\setmainlanguage{english}

%---------------------------------------------------------
%--- Fonts used: IM FELL DW Pica Font Family
%--- http://www.1001fonts.com/im-fell-dw-pica-font.html
%---------------------------------------------------------
\setmainfont{IMFePisc29P.ttf}

%------------------------------
%--- Beginning of the document
%------------------------------
\begin{document}

\newgeometry{textwidth=89mm, textheight =158mm, marginratio={4:6,5:7},nofoot}
\noindent\renewcommand\arraystretch{2}
\hskip-0.2em\multido{\n=1+1}{14}{\decoone\decosix}\decoone

\arraybackslash}X@{}}
\textsc{r e s u l t} \\
\textsc{\normalsize of the} \\
\itshape CONVENTION, \&c. \\
\bottomrule
\end{tabularx}
\vskip4ex

%---------------------------------------------
%--- Needs to be italicized and set to 12pt
%---------------------------------------------
\setlength\leftskip{1em}{\itshape\hskip-2.3em
In Convention of Delegates from the several towns of Lynn, Salem, Danvers, Wenham,
Manchester, Glou\-cester, Ipswich, Newbury-Port, Salisbury, Methuen, Boxford \& Topsfield,
holden by adjourment at Ipswich, on the twenty-ninth day of April, one thousand seven
hundred \& seventy eight.}

%---------------------------------------------
%--- Needs to be bold, set to 12pt, left justified
%---------------------------------------------
\large Peter Coffin Esq ; in the Chair.

%------------------------------------------------------
%--- Needs to be set to 10pt after large first letter
%------------------------------------------------------
\setlength\leftskip{2mm}

\lettrine[lines=4,slope=0.6em,findent=0.6em,nindent=0em]{T}{HE} Constitution and form of Government framed
by the Convention of this State, was read paragraph by paragraph, and after debate, the following

\end{document}


How can the following be accomplished:

1. Use the listed font, of italic form, to italicize the paragraph indicated and have the font size set for that paragraph
2. left justify in a set a line (Peter Coffin Esq line)
3. "randomly" change fonts, sizes, shapes locally (in general for any part of a document) ?

• (1) If you specify the font using a file name, I think you have to tell it explicitly what to use for other shapes etc. If the fonts are installed for your system, you can possibly avoid this. Don't know which paragraph but \textit{} should then work. And {\small ...} or {\large ...} or whatever for the size. (2) Please clarify. (3) Please clarify. – cfr Jul 14 '15 at 20:40
• See answer below for (1). For (2), it doesn't really matter which line you want to apply this to. What I'm not clear about is what you mean by left justify in a set a line. left justify is a bit odd to begin with. Usually text is justified, flush left or flush right. in a set I cannot guess right now. For (3), again, it doesn't really matter which part you mean. What do you mean by 'randomly'? You just change sizes, shapes etc. locally the way you always do e.g. \textit{}, \small etc. If you want commands to switch to a special font, you can load or create them. The usual. – cfr Jul 14 '15 at 21:15

Page 6 of fontspec's manual says this:

Fonts selected by filename must include bold and italic variants explicitly.

\setmainfont{texgyrepagella-regular.otf}[
BoldFont  = texgyrepagella-bold.otf ,
ItalicFont  = texgyrepagella-italic.otf ,
BoldItalicFont = texgyrepagella-bolditalic.otf ]


In this case, for example:

\documentclass[a4paper]{article}
\usepackage{fontspec,kantlipsum}
% font features set according to the copies of the fonts I have
\setmainfont{IMFePIrm29P.ttf}[% fontspec complains about the features not being available for sc and trying to deactivate them makes it complain again about a lack of the deactivated-feature - pah! this thing is noisy!
ItalicFont = IMFePIit29P.ttf,
SmallCapsFont = IMFePIsc29P.ttf,
StylisticSet=1,
WordSpace = 1.2,
Ligatures = Rare,
Style = Historic,
]
\begin{document}

This is 10pt upright.

\textit{This is 10pt italics.}

\textsc{This is 10pt small-caps.}

{\itshape\large This is 12pt italics.

\scshape This is 12pt small-caps.

\upshape This is 12pt upright.
}

This is 10pt upright.

\kant[1]

{\itshape \kant[2]}

{\small\itshape \kant[3]}

{\large \kant[4]}

\end{document}


produces

You can use \newfontfamily\commandname{...} to define a font which you want to use for a special effect, for example. This can be defined as you would the main document fonts for text. Or it could be an ornamental or specialist font.

For example:

\newfontfamily\imflowers{IMFeFlow1.ttf}


Allows me to say

  {\imflowers ABCDEFGHIJKLMNOPQRSTUVWXYZ abc}


if I want to illustrate the text with some printers' ornaments:

[All this would be easier if the fonts were installed for the system and did not need to be called by filename. As it is, I still find this easier in pdfLaTeX! At least there, I really do have complete control if I care to use it.]

# Changing font or font characteristics 'on a whim'

To change font shape for an arbitrary part of the document, you can use

• \itshape All text, until further notice will be italicised.
• \scshape All text, until further notice will be in small-caps.
• \normalfont Back to default font shape (and weight).

For example:

\documentclass[a4paper]{article}
\usepackage{fontspec,kantlipsum}
% font features set according to the copies of the fonts I have
\setmainfont{IMFePIrm29P.ttf}[% fontspec complains about the features not being available for sc and trying to deactivate them makes it complain again about a lack of the deactivated-feature - pah! this thing is noisy!
ItalicFont = IMFePIit29P.ttf,
SmallCapsFont = IMFePIsc29P.ttf,
StylisticSet=1,
WordSpace = 1.2,
Ligatures = Rare,
Style = Historic,
]
\begin{document}

\itshape \kant[1]

\scshape \kant[2]

\normalfont \kant[3]

\end{document}


You can also limit the scope of a shape command by using curly brackets as shown in the earlier example above.

Regular shape.

{\itshape Italics here.

More italics.

Yet more italics.}

Regular shape again.


Similarly, the standard sizing commands work in the same way and may also be limited by grouping using curly brackets or similar methods.

\documentclass[a4paper]{article}
\usepackage{fontspec,kantlipsum}
% font features set according to the copies of the fonts I have
\setmainfont{IMFePIrm29P.ttf}[% fontspec complains about the features not being available for sc and trying to deactivate them makes it complain again about a lack of the deactivated-feature - pah! this thing is noisy!
ItalicFont = IMFePIit29P.ttf,
SmallCapsFont = IMFePIsc29P.ttf,
StylisticSet=1,
WordSpace = 1.2,
Ligatures = Rare,
Style = Historic,
]
\begin{document}

\tiny As is own in the writings of Aristotle, the things in themselves (and it remains a mystery why this is the case) are a representation of time.

\scriptsize As is own in the writings of Aristotle, the things in themselves (and it remains a mystery why this is the case) are a representation of time.

\footnotesize As is own in the writings of Aristotle, the things in themselves (and it remains a mystery why this is the case) are a representation of time.

\small As is own in the writings of Aristotle, the things in themselves (and it remains a mystery why this is the case) are a representation of time.

\normalsize As is own in the writings of Aristotle, the things in themselves (and it remains a mystery why this is the case) are a representation of time.

\large As is own in the writings of Aristotle, the things in themselves (and it remains a mystery why this is the case) are a representation of time.

\Large As is own in the writings of Aristotle, the things in themselves (and it remains a mystery why this is the case) are a representation of time.

\LARGE As is own in the writings of Aristotle, the things in themselves (and it remains a mystery why this is the case) are a representation of time.

\Huge As is own in the writings of Aristotle, the things in themselves (and it remains a mystery why this is the case) are a representation of time.

\end{document}


You can also, of course, use further fontspec commands to adjust the features enabled for the font e.g. to turn the Rare ligatures off. However, you probably don't want this since it would make the typography inconsistent. (Unless you are writing about such typographic features, of course, which would be a different story where such illustrations might well be useful.)