4

My TeX system is MikTeX 2.9 Portable on Windows 10, but I believe this question has general applicability to any TeX installation.

Consider this generic document:

\documentclass[12pt]{article}
\begin{document}
Yada yada yada.
\end{document}

I did not specify a font. My TeX system chooses Computer Modern font family by default. I believe that under other circumstances (a more complicated document without font specification) it would choose Latin Modern font family.

Now, I know how to specify the default font(s) within a document. But I wonder, where in TeX does it choose CM (or LM) as the default font family, when I provide no font choice at all?

Here is why I ask: I do not work with math, and so do not need characters beyond the ones generally available in opentype fonts nowadays. I wish to ensure that any font appearing in a document is either one of the licensed commercial fonts I have, or an SIL-licensed font. So, I wish to point the default font families away from CM or LM to something such as the (Adobe/Google) Source fonts, which I have installed.

Again, this is when the document does not specify any font. I do not wish to add a font specification to the document, I wish to change the TeX system default. I've already searched quite a bit, but have only discovered how to specify fonts within a document.

I realize that the GUST and Latex Project licenses are very nice, but I want to restrict font embedding to the commercial or SIL licensed fonts.

  • 1
    If you don't want the system to load a given font family by default, you've got to tell it what else it should load. (Not loading any font at all is not an option, right?) Incidentally, what's wrong with specifying the desired font in the preamble of a LaTeX document? – Mico Apr 26 '16 at 21:21
  • 1
    you say you are using opentype fonts but that implies using luatex or xelatex (and fontspec) which is a rather different question than the one you ask about the default fonts (for a latex/pdflatex document) – David Carlisle Apr 26 '16 at 21:31
  • Latin Modern is never the default unless you load a package which changes to LM. Perhaps you are thinking of cases where you load fontspec or polyglossia. In that case, LM is loaded. You cannot change the TeX default from CM, I don't think. I believe it is hard-coded. – cfr Apr 26 '16 at 21:32
  • I can understand not liking the fonts themselves - it's partly a matter of preference, after all - but it seems weird to reject them on the basis of their licence, given the licences involved. – cfr Apr 26 '16 at 21:35
  • 1
    You can make a copy of fonttext.cfg in your local texmf and add changes there (you need to recreate the format then). But I wouldn't recommend it. It is difficult to get support for such configurations -- nobody expect that a minimal document doesn't use cm. – Ulrike Fischer Apr 26 '16 at 21:41
3

As you seem to be using fontspec, the solution is much simpler.

Create the appropriate structure in

/usr/local/texlive/texmf-local/tex/latex/fontspec

and copy there the following modification of the distributed fontspec.cfg file:

%%% FONTSPEC.CFG %%%
%
% This configuration file sets up TeX Ligatures by default for all fonts loaded
% with `\setmainfont` and `\setsansfont`.
%
% In addition, `\setmonofont` has default features to enforce "monospace"
% settings with regard to space stretchability and shrinkability.
%
% Make a copy of this file in your own home TEXMF directory to set up your own
% defaults.


\defaultfontfeatures
 [\rmfamily,\sffamily]
 {Ligatures=TeX}

\defaultfontfeatures
 [\ttfamily]
 {WordSpace={1,0,0},
  PunctuationSpace=WordSpace}

%%% Modifications start here

\AtBeginDocument{
  \setmainfont{SourceSerifPro}[
    Extension=.otf,
    UprightFont=*-Regular,
    ItalicFont=*-Regular, % no italic
    BoldFont=*-Bold,
    BoldItalicFont=*-Bold, % no bold italic
  ]
  \setsansfont{SourceSansPro}[
    Extension=.otf,
    UprightFont=*-Regular,
    ItalicFont=*-RegularIt,
    BoldFont=*-Bold,
    BoldItalicFont=*-BoldIt,
  ]
  \setmonofont{SourceCodePro}[
    Extension=.otf,
    UprightFont=*-Regular,
    ItalicFont=*-RegularIt,
    BoldFont=*-Bold,
    BoldItalicFont=*-BoldIt,
  ]
}

Run mktexlsr; now the modified fontspec.cfg file will have priority over the distributed one. Try the following test file:

\documentclass{article}
\usepackage{fontspec}

\begin{document}
Main:
Normal \textit{Italic} \textbf{Bold \textit{BoldItalic}}

{\sffamily Sans:
Normal \textit{Italic} \textbf{Bold \textit{BoldItalic}}
}

{\ttfamily Mono:
Normal \textit{Italic} \textbf{Bold \textit{BoldItalic}}
}
\end{document}

The output will be

enter image description here

Here's the output of pdffonts test.pdf just to confirm.

name                                 type              encoding         emb sub uni object ID
------------------------------------ ----------------- ---------------- --- --- --- ---------
CUDPZP+SourceSerifPro-Regular-Identity-H CID Type 0C       Identity-H       yes yes yes      5  0
YCFVOZ+SourceSerifPro-Bold-Identity-H CID Type 0C       Identity-H       yes yes yes      7  0
OKVEPQ+SourceSansPro-Regular-Identity-H CID Type 0C       Identity-H       yes yes yes      9  0
OLDNKC+SourceSansPro-It-Identity-H   CID Type 0C       Identity-H       yes yes yes     11  0
KKFWEH+SourceSansPro-Bold-Identity-H CID Type 0C       Identity-H       yes yes yes     13  0
VXEFYK+SourceSansPro-BoldIt-Identity-H CID Type 0C       Identity-H       yes yes yes     15  0
IVVCWG+SourceCodePro-Regular-Identity-H CID Type 0C       Identity-H       yes yes yes     17  0
OSDIQN+SourceCodePro-It-Identity-H   CID Type 0C       Identity-H       yes yes yes     19  0
NTAJGT+SourceCodePro-Bold-Identity-H CID Type 0C       Identity-H       yes yes yes     21  0
LSJKOA+SourceCodePro-BoldIt-Identity-H CID Type 0C       Identity-H       yes yes yes     23  0
  • That works, too. Since it is of more general applicability than my own font-file substitute name hack, I will consider it to be the best solution. Thanks. – user103221 Apr 27 '16 at 23:35
  • I should have mentioned: In MikTeX Portable, it seems that the local tree cannot be given priority over the main tree (if you have several local trees, they can be prioritized relative to each other). Don't know why. But the solution can be implemented by putting the code into (for example) a custom class in the local tree, then requiring that class. – user103221 Apr 28 '16 at 14:26
0

It turns out that (specific to my situation) there is an absurdly simple work-around:

I can use the Source (Serif, Sans, Mono) Pro fonts, because they have the correct license. So I install them. I get both OpenType and Type1 fonts, but since I work exclusively with LuaLaTeX (and so must the others), only the OpenType fonts are of interest.

I copy these fonts into fonts/opentype/public/lm which is where the lm fonts reside. Then, I remove the lm font files, and copy the nearest Source font with the file name changed. So, I replace the real lmroman5-regular.otf, lmroman6-regular-.otf (etc.) with SourceSerifPro.otf, except I change the file names to lmroman5-regular.otf, lmroman6-regular.otf (etc.).

Now, when fontspec looks for an lm opentype font, it sees the correct file names in the correct folder, and uses the fonts. It does not know that it is actually using the Source fonts. It is the Source font (by its own name) that appear in the PDF.

I couldn't make this work in my local (custom) directory. I had to do it in the main tree. That could be a problem if the lm font package is ever updated. So, I made a zip copy of the hacked font files, and keep it elsewhere for future use.

This would be more effort for those not using LuaLaTeX/fontspec with OpenType fonts.

Note that I am not changing the internal name of any fonts. Only the file name. That's OK.

Others who acually use the lm fonts should NOT do this.

All that nonsense, because my commercial print service was unhappy with the lack of an SIL license within the actual font file.

  • 1
    A bit of an odd choice, to my mind, since Source Serif Pro has not italics (see @egreg's output elsewhere on this page!). Have you considered using Charis SIL (based on Bitstream Charter)? It has a strong family resemblance to Source Serif, since these both draw on Pierre Simon Fournier's 18th C characters,. – Dɑvïd Apr 27 '16 at 22:35
  • You are correct. Charis is a much better choice, and it carries the SIL license, which is important. Now that I know the hack works, I'll put in Charis instead, when I get the time. Only used Source because I had it in front of me. – user103221 Apr 27 '16 at 23:34
  • Best to grab it from SIL directly, then -- the FontSquirrel version is an older one, I believe. (But it's easier to get a feel for the font at FontSquirrel than at SIL's site!) – Dɑvïd Apr 28 '16 at 8:58
  • Got it from SIL. Grabbed others as well. I thought that the SIL fonts were an installable MikTeX package, but I was wrong. But you are correct in that FontSquirrel is very well organized and easy to use, in general. – user103221 Apr 28 '16 at 14:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy