# \setmainfont{Linux Libertine O} uses pfb files instead of otf

(This is sort of a follow-up to libertineotf and xelatex - bold smallcaps broken?, based on a problem that I had noticed earlier, but hadn't put my finger on.)

\documentclass{article}
\usepackage{fontspec}
\setmainfont{Linux Libertine O}% 1
%   \setmainfont{LinLibertine_R_0.otf}% 2
%   \usepackage{libertineotf}% 3
\begin{document}
Foo bar. \textsc{Foo bar \textbf{baz!}}
\end{document}


Unexpectedly, this file doesn't use the otf Linux Libertine O files in C:\Windows\Fonts\, but the pfb files in my texmf tree (cf. log snippets below). I presume this is why the small caps don't work as described in Herbert's answer here, and also why doing any OpenType magic à la \addfontfeauture doesn't work either.

I'm not quite sure where the problem is coming from. Variant 2, which calls the otf font directly, runs, but doesn't use small caps; I assume that's because this font file is too specific for fontspec to automatically find the small caps font, so that I'd have to specify the file with the SmallCapsFont option manually. Variant 3 works pretty well, but as outlined in the question linked above, the calling of small caps is buggy there (and I want to solve the problem, not circumvent it).

As for background, I'm using MiKTeX 2.9, all up-to-date; and I have version 5.3 of the Linux Libertine fonts installed in C:\Windows\Fonts\ (independently from LaTeX, these are the ones I would've expected fontspec to use).

Some seemingly relevant bits from the log file (of variant 1):

Requested font "Linux Libertine O" at 10.0pt
-> C:/Program Files (x86)/MiKTeX 2.9/fonts/type1/public/libertine/LinLibertine
O.pfb
Requested font "Linux Libertine O/ICU" at 10.0pt
-> C:/Program Files (x86)/MiKTeX 2.9/fonts/type1/public/libertine/LinLibertine
O.pfb


[and a number of similar lines, but then:]

Requested font "Linux Libertine O/BI/ICU" at 10.0pt
-> C:/Windows/Fonts/LinLibertine_RB.otf
Requested font "Linux Libertine O/BI/BI/ICU" at 10.0pt
-> C:/Windows/Fonts/LinLibertine_RB.otf


I don't really have a specific question, other than: What's going on here, and how can I fix it?

-

For some reason XeTeX is finding the Type1 fonts first1, you can tell FontConfig not to use Type1 fonts by blacklistling them by putting something like this in your local FontConfig configuration file (see How to make XeLaTeX recognize linked fonts with Windows? for more details).

<?xml version="1.0"?>
<!DOCTYPE fontconfig SYSTEM "fonts.dtd">
<fontconfig>
<selectfont>
<rejectfont>
<glob>C:/Program Files (x86)/MiKTeX 2.9/fonts/type1/public/libertine/*</glob>
</rejectfont>
</selectfont>
</fontconfig>


You can even blacklist all Type1 fonts in TEXMF tree by using C:/Program Files (x86)/MiKTeX 2.9/fonts/type1/* instead.

1 But not essentially using them for typesetting, fontspec loads the font first to collect some info about it, before loading it for “real”. To see the actual fonts that went into the PDF, try running xelatex with the option --output-driver="xdvipdfmx -v" to get some verbose output.

Update: This is more or less fixed now in XeTeX; TrueType/OpenType are given high priority over Type1, so it should be fixed in TeX Live 2013 (and the equivalent MiKTeX update).

-
Thanks! Several things: In the place Leo described, I only found fonts.config.in (note the .in), no localfonts.config. Creating a localfonts.config with or without .in, with the content you proposed, followed by updating the FNDB, refreshing the formats, deleting the auxiliary files, and recompiling didn't change anything. Also, running xelatex with the option you described (copy-pasted) returns xelatex: Invalid command-line option \\ xelatex: Data: unknown option. –  doncherry Nov 26 '12 at 0:36
@doncherry: sorry, I don’t use MiKTeX (nor Windows), and don’t know much about its specifics, for FontConfig you would want to run the equivalent of fc-cache command line tool. No idea why XeTeX option is not recognized, probably options are handled differently than TeX Live implementation. –  Khaled Hosny Nov 26 '12 at 2:08
The xelatex works with " instead of '. I'm now playing around with fc-cache, which is new to me. –  doncherry Nov 26 '12 at 2:39
I created the localfonts.config, ran fc-cache -r -v, but the output included the line C:/Program Files (x86)/MiKTeX 2.9/fonts/type1/public/libertine: caching, new cache contents: 10 fonts, 0 dirs. No progress in the output. While I don't think the log of the compilation will be particularly enlightening, here it is: pastebin.com/n5cW11Dh –  doncherry Nov 26 '12 at 3:22
@doncherry: Try using .conf instead of .config, I don’t think FontConfig recognizes the later. –  Khaled Hosny Nov 26 '12 at 3:42