For quite intricate reasons, the math fonts are still loaded (and at fixed sizes); the warnings are actually completely innocuous, but annoying. You can get rid of them by loading
\usepackage{fix-cm}
Note
I don't understand the line
\fontspec[Scale=0.83]{Junicode}\fontsize{21}{27.3}\selectfont
Wouldn't
\fontsize{17.5}{27.3}\selectfont
do just the same? In any case, \fontspec
is a heavy macro to use and it's best to use \newfontfamily
in the preamble; but, in this case, \addfontfeatures{Scale=0.83}
would do the same.
With columns=fixed
and columns=flexible
, the listing is built inserting each character in a box 0.6em wide for fixed
and 0.45em for flexible
(the default value can be changed via basewidth
).
Using these two types is meaningless when the font has fixed width glyphs, like Courier or Computer Modern Typewriter, because for these fonts the interword space is the same as the width of every character, so the columns will line up automatically.
In those cases, columns=fullflexible
is the best: characters are not inserted in a box and the alignment is automatic.
How to set the basewidth
to a sensible value for fixed
? You can exploit the fact that when basewidth
is computed, the basic font has already been selected, so
basewidth=\fontcharwd\font`W,
will set this width to the one of the (usually) widest character.
Example:
\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage{listings}
\usepackage{xcolor} % \pagecolor
\pagecolor{yellow!15}
\setlength{\fboxsep}{0pt}
\begin{document}
Here entering a sample paragraph with \texttt{some} words entered in
\texttt{typewriter font}, which should also be \texttt{monospaced} - or rather,
\texttt{fixed width}. It can be quite useful for showing \texttt{variables}.
\noindent\begin{minipage}[t]{.4\textwidth}
\begin{lstlisting}[basicstyle=\scriptsize\ttfamily,
caption={[short] Some instructions here; the font here is \texttt{\ttdefault}.},
escapechar=!,
showlines=true,
label=lst:ex2a,
columns=fixed,
basewidth=\fontcharwd\font`M,
frame=tlrb]
080484c4 <list>:
!\fbox{\hspace{-\fboxrule}\texttt{80484c4:\_cmd one}\linebreak}!
80484c7: cmd two
80484ca: cmd three, four
80484cf: cmd five
80484d6: cmd six, seven
80484dd: cmd more than enough
80484e0: cmd not_even_joking
\end{lstlisting}
\end{minipage}
\hspace{1cm}
\noindent\begin{minipage}[t]{.4\textwidth}
\begin{lstlisting}[basicstyle=\scriptsize\ttfamily,
caption={[short] Some instructions here; the font here is \texttt{\ttdefault}.},
escapechar=!,
showlines=true,
label=lst:ex2b,
columns=fullflexible,
keepspaces,
frame=tlrb]
080484c4 <list>:
!\fbox{\hspace{-\fboxrule}\texttt{80484c4:\_cmd one}}!
80484c7: cmd two
80484ca: cmd three, four
80484cf: cmd five
80484d6: cmd six, seven
80484dd: cmd more than enough
80484e0: cmd not_even_joking
\end{lstlisting}
\end{minipage}
\end{document}
How to determine if a font is fixed width?
\ifdim\fontcharwd\font`i=\fontcharwd\font`W
<code for fixed width font>
\else
<code for proportional font>
\fi
Of course \font
refers to the current font.
Best Answer
You may be even more shocked to learn that LaTeX knows very little about the fonts it uses for typesetting documents.
In order to typeset a document, TeX only needs to have information about the characters' bounding boxes, ligatures, italic corrections, font spacing and little else. The characters' shapes (glyphs) aren't something TeX worries about.
This was clearer before the advent of PDF. Classic TeX used to (and still can) store the typesetting information in a DVI file (the name stands for “device independent”). This file could be used for viewing or printing, maybe after transformation into a device dependent format.
In olden times, for each printing device connected to the computer, a suitable driver written for that particular device had to be used. You can still find in TeX Live programs such as
dvihp
anddvilj
: Hewlett-Packard developed a page description language called PCL and these programs transform the DVI file into something that can be sent to a printer (HP or LJ, respectively) using that language.However, when PostScript was released by Adobe, things started to change. More and more producers of printing devices began to use the PostScript language and the TeX world was already at ease with it because Tom Rokicki wrote
dvips
.How fonts are treated by the device driver is of no concern to TeX. But, of course, TeX has needed fonts since the beginning: no font, no printing. And, indeed, Donald Knuth also wrote a sister program to TeX, namely METAFONT, aimed at producing fonts.
At the time TeX and METAFONT were being developed, the late 70s of the 20th century, bitmaps were the only technology available for storing fonts. This is the only output format for METAFONT (besides the font information needed by TeX). And, in Knuth's vision, you needed a parameter file for each printer model in order to adjust the bitmap fonts to it.
PostScript, however, has a different view on fonts: it thinks of the characters by their outlines: curves (usually splines) that delimit the region of the plane to be filled with ink; but it also allowed for different formats and one of Rokicki's jobs was to provide a transparent conversion from bitmap METAFONT's PK files to PostScript Type3 fonts.
So, typically, if one had a 300dpi laser printer able to understand PostScript, the
dvips
driver would have produced, if necessary, the missing bitmap fonts with thecx
modeAs you see, there was actually a single supplier of laser engines, so the modes for these printers could be shared.
But PostScript prefers outline fonts to bitmaps and it has its own font format, called Type1, which is device independent and, in particular, resolution independent. This format was kept secret, so that Adobe could sell their high quality fonts. But at some point, the Type1 format was reverse-engineered, Adobe lost the lawsuit against the “perpetrators” and was in some sense forced to open the format.
Shortly thereafter, Blue Sky Research produced the first transformation of the Computer Modern fonts into Type1 format. It was needed in order to provide Textures (the TeX engine for the Macintosh they produced) with a way to use Adobe Type Manager (only able to cope with Type1 fonts) and display font outlines on the screen or print them with as little pixelation as possible.
Rokicki also provided a small utility for transforming the Adobe font metrics into TeX font metrics, so as to be able to directly use PostScript fonts in TeX.
The vast majority of the METAFONT defined fonts have since been digitized and transformed into the outlines required by Type1. This was a necessary step for the later developments.
Enter PDF.
The PDF format was derived from PostScript to allow for device independent viewing or printing. A version of TeX shipping out PDF files was developed by Hàn Thê Thành as part of his PhD thesis.
This requires font files to be (partially) embedded in the PDF file, but this does not invalidate the claim at the top of the document. We can approximately think of PDF files produced by TeX/LaTeX as a combined job of TeX and
dvips
. The TeX part of this production still relies on knowing nothing about the glyphs, but just about their bounding boxes and related things (italic corrections, ligatures, font spacing parameters).When a page is shipped out to the PDF file, information is recorded about the fonts needed and at the end of the job, the needed ones are embedded in the PDF file.
No pixelation still requires Type1 fonts or its descendant OpenType format. Also TrueType fonts are allowed, though. This format was developed as a combined project by Apple and Microsoft, in an attempt to become less dependent on Adobe. Apple provided its experimental GX font technology, on which the first version of XeTeX was based. But the original model is still valid for XeTeX and also for LuaTeX. When typesetting, the engine need to know nothing about the glyphs; only PDF production eventually needs them.