# Selecting optical sizes for all fonts in a family

XeTeX and LuaTeX are able to assign optical sizes to fonts when they are provided. In those situations where XeTeX or LuaTex are unable to correctly assign optical sizes I am able to specify them but only for the regular font, not for italics, bold, or bold italics. I'm looking for a way to assign all of them.

The specific example I'm using is for Minion Pro and I know a package exists for it but I'm looking for a general solution I can apply as a regular user whenever something like this comes up again.

Here's the MWE:

\documentclass[openleft,12pt]{memoir}
\usepackage{fontspec}
\setmainfont[ItalicFont={MinionPro-It},BoldFont={MinionPro-Bold},BoldItalicFont={MinionPro-BoldIt}]{Minion Pro}

\begin{document}
Regular\\
\textit{Italic}\\
\textbf{Bold}\\
\textit{\textbf{Bold Italic}}\
{\tiny tiny}\\
{\normalsize normal}\\
{\Large Large}\\
{\LARGE LARGE}\\
{\HUGE HUGE}\\

{\tiny{
\textit{tiny italic} \textbf{tiny bold} \textbf{\textit{tiny bold italic}}}}\\
{\Large{
\textit{Large italic} \textbf{Large bold} \textbf{\textit{Large bold italic}}}}\\
{\HUGE{
\textit{HUGE italic} \textbf{HUGE bold} \textbf{\textit{HUGE bold italic}}}}

\end{document}


Both XeLaTeX and LuaLaTeX need the italic, bold, and bold italic fonts declared. After that XeLaTeX uses all the correct optical sizes for this example. LuaLaTeX does not use any of them (except as before for the regular font).

If you change the \setmainfont section to look like this:

\setmainfont[ItalicFont={MinionPro-It},BoldFont={MinionPro-Bold},BoldItalicFont={MinionPro-BoldIt},
SizeFeatures={
{Size={-8.4},OpticalSize=8},
{Size={8.4-13},OpticalSize=11},
{Size={13-19.9},OpticalSize=19},
{Size={19.9-},OpticalSize=72}}
]
{Minion Pro}


Then everything still works for XeLaTeX and now the optical sizes (Caption, Regular, SubHeader, Display) work with LuaLaTeX for the regular fonts but not for italics, bold, and bold italics.

I had thought that maybe something like:

\setmainfont[ItalicFont={MinionPro-It},BoldFont={MinionPro-Bold},BoldItalicFont={MinionPro-BoldIt},
SizeFeatures={
{Size={-8.4},OpticalSize=8,ItalicFont={MinionPro-ItCapt},
{Size={8.4-13},OpticalSize=11},
{Size={13-19.9},OpticalSize=19,ItalicFont={MinionPro-ItSubH},
{Size={19.9-},OpticalSize=72,ItalicFont={MinionPro-Disp}}}
]
{Minion Pro}


Would work (obviously filling in the bold and bold italic fonts and the other sizes) but that results in an error. I've tried several variations on that idea and nothing works. I keep reading over the fontspec and luaotfload manuals but can find nothing on how to do this thing specifically (I did find a reference to a "goodies" file for ConTeXt but was unable to figure out how to load it into a LuaLaTeX document).

Update Some more experimentation with Adobe fonts. I just did the same experiment with Garamond Premier Pro (also has optical sizes). And the results are similar. LuaLaTeX will just not load the Caption/Subheading/Display versions of Italic/Bold/Bold Italic though it handles the Regular font without even having to specify the optical sizes (thanks to a fix supplied when I asked a similar question before about Garamond specifically). XeLaTeX will but uses the SemiBoldItalic versions for the different optical sizes instead of just BoldItalic.

• I don’t have Minion’s opticals but do have opticals for 3 other Adobe fonts by Robert Slimbach, and none requires specifying the italic, etc. I’d be surprised if a general solution exists: when a font has optical sizes but xe/luatex acts as if it didn’t, you’ve encountered a bug, and if the bug is in the font, well, each buggy font is buggy in its own way. So you’d need to inspect the font and find a work-around (perhaps a feature file) for its peculiarities. Jul 31, 2013 at 2:41
• There are a couple of Adobe fonts w/ incorrect optical size information --- details should be on the XeTeX mailing list. Jul 31, 2013 at 2:54
• I see you've tried nesting the italic fonts inside the size specification; have you tried nesting the size specification inside the ItalicFeatures option? Jul 31, 2013 at 2:57
• Indeed, I fail to see how feature files can be of any help here. That is clearly a luaotfload bug and you should report it before looking for workarounds. But then I don’t understand why you have to select all font styles manually, something is deeply broken on your side. Jul 31, 2013 at 16:03
• You can use the issue tracker. Jul 31, 2013 at 19:31

You have to specify the font for each feature. See section 5.1.2. of the fontspec manual.

A XeTeX MWE:

\documentclass[12pt]{memoir}
\usepackage{fontspec}
\setmainfont[%
UprightFeatures={
SizeFeatures={
{Size={-8.4},Font=MinionPro-Capt},
{Size={8.4-13},Font=MinionPro-Regular},
{Size={13-19.9},Font=MinionPro-Subh},
{Size={19.9-},Font=MinionPro-Disp}
},
},
BoldFeatures={
SizeFeatures={
{Size={-8.4},Font=MinionPro-BoldCapt},
{Size={8.4-13},Font=MinionPro-Bold},
{Size={13-19.9},Font=MinionPro-BoldSubh},
{Size={19.9-},Font=MinionPro-BoldDisp}
},
},
ItalicFeatures={
SizeFeatures={
{Size={-8.4},Font=MinionPro-ItCapt},
{Size={8.4-13},Font=MinionPro-It},
{Size={13-19.9},Font=MinionPro-ItSubh},
{Size={19.9-},Font=MinionPro-ItDisp}
},
},
BoldItalicFeatures={
SizeFeatures={
{Size={-8.4},Font=MinionPro-BoldItCapt},
{Size={8.4-13},Font=MinionPro-BoldIt},
{Size={13-19.9},Font=MinionPro-BoldItSubh},
{Size={19.9-},Font=MinionPro-BoldItDisp}
},
},
]
{Minion Pro}

\begin{document}
\noindent
Regular\\
\textit{Italic}\\
\textbf{Bold}\\
\textit{\textbf{Bold Italic}}\\

\noindent
{\tiny tiny}\\
{\normalsize normal, not \textbf{\textit{HUGE bold italic}}}\\
{\Large Large}\\
{\LARGE LARGE}\\
{\HUGE HUGE}\\

\noindent
{\tiny{
\textit{tiny italic} \textbf{tiny bold} \textbf{\textit{tiny bold italic}}}}\\
{\Large{
\textit{Large italic} \textbf{Large bold} \textbf{\textit{Large bold italic}}}}\\
{\HUGE{
\noindent
HUGE\\
\textit{HUGE italic}\\
\textbf{HUGE bold}\\
\textbf{\textit{HUGE bold italic}}}}

\end{document}

• +1! "... specify the font for each feature ..." came as such an unpleasant surprise that I actually checked it out (with XeLaTeX), and can confirm that the results are different. Surprising, too is that all the fonts are embedded in the pdf, even though some of them are not used (in the single-sizefeatures case). Hmm. Jan 18, 2015 at 8:51
• @Ludenticus, thanks for this. I could not for the life of me figure out the proper syntax for this. The manual doesn't make this very clear either. Regardless, this is huge for me. Jan 18, 2015 at 16:09
• I need to revise my earlier comment. I had checked SemiBold against Bold, and of course they were different! With XeTeX using the default choices for bold and italic, you don't need to specify the sizes for each feature -- a single set of size specifications works. (Though I use font names, rather than font filenames). With LuaTeX, the results from the two idioms differ, and both differ from XeTeX. As I'm a XeTeX user, I don't plan to investigate the LuaTeX side further. (This year, anyway) Jan 19, 2015 at 18:19

With XeTeX you do not need multiple size declarations, and I believe you should not with LuaTeX. In what follows, I'll refer to @Ludenticus' solution as (1), and mine, which follows, as (2):

\documentclass[12pt,a5paper]{memoir}
\setlrmarginsandblock{1cm}{*}{1}
\usepackage{fontspec}
\setmainfont{Minion Pro}[%
SizeFeatures={%
{Size={-8.4},Font=* Caption},
{Size={8.4-13},Font=*},
{Size={19.9-},Font=* Display}
},
BoldFont={* Bold},
BoldItalicFont={* Bold Italic},
]
\setlength{\parindent}{0pt}
\nonzeroparskip
\begin{document}
\noindent
Regular
\textit{Italic}
\textbf{Bold}
\textit{\textbf{Bold Italic}}\par

\noindent
{\tiny tiny}\par
{\normalsize normal, not \textbf{\textit{HUGE bold italic}}}\par
{\Large Large}\par
{\LARGE LARGE}\par
{\HUGE HUGE}\par

\noindent
{\tiny{
\textit{tiny italic} \textbf{tiny bold} \textbf{\textit{tiny bold italic}}}}\par
{\Large{
\textit{Large italic} \textbf{Large bold} \textbf{\textit{Large bold italic}}}}\par
{\HUGE{
\noindent
HUGE\par
\textit{HUGE italic}\par
\textbf{HUGE bold}\par
\textbf{\textit{HUGE bold italic}}}}

\end{document}


(1) and (2) processed with XeLaTeX produce visually identical PDFs (compared with diffpdf, option 'appearance'.

(1) and (2) processed with LuaLaTeX are different. The PDF from (1) has a full complement of embedded fonts (16), while (2) only has 10, the extra optical sizes being missing.

Notes:

• The default Bold association for Minion Pro is not 'bold', but 'semibold'. I assume this was what made you search for the parameters to change the two bold series.
• If you're happy with semibold, you can just omit the two Bold... lines altogether.
• I much prefer to use font names rather than font filenames -- it seems a lot less brittle (once you discover the right names!).
• This appears to work for me in LuaTex. Thanks! Oct 4, 2015 at 2:07