0

I have a custom Latex class from my employer that (besides some other stuff) loads the Fonts Charter and Frontpage (Fonts supplied with the class). It works fine with pdflatex and basically loads the fonts via renewcommand (see below). I want to use lualatex and polyglossia and found in the logfile that polyglossia actually loads fontspec. If fontspec is loaded, Charter and Frontpage get substituted by defaults. Is there a way to make this work?

(I also have ttf-Files for both fonts which I can load with fontspec but they seem not to include small caps)

Here is the example code. You will not be able to execute it if you dont have the fonts but you see how I load them.

\documentclass{article}
\usepackage{fontspec}
  \renewcommand*{\rmdefault}{5ch}
  \renewcommand*{\sfdefault}{5fp}
%The loading order of these three lines makes no difference

\begin{document}
    Charter\\
Normal\\
\textbf{textbf}\\
\textit{textit}\\
\textsc{textsc}\\
CAPSLOCK\\
\textbf{\textit{textbf textit}}

{\sffamily
    Frontpage\\
Normal\\
\textbf{textbf}\\
\textit{textit}\\
\textsc{textsc}\\
CAPSLOCK\\
\textbf{\textit{textbf textit}}
}
\end{document}

Here are the relevant parts from the logfile

LaTeX Font Info:    ... okay on input line 9. %this is \begin{document}
LaTeX Font Info:    Try loading font information for EU2+5ch on input line 9.
LaTeX Font Info:    No file EU25ch.fd. on input line 9.
LaTeX Font Warning: Font shape `EU2/5ch/m/n' undefined
(Font)              using `EU2/lmr/m/n' instead on input line 9.
%snip--------
    LaTeX Font Info:    Encoding `OT1' has changed to `EU2' for symbol font
(Font)              `operators' in the math version `normal' on input line 9.
LaTeX Font Info:    Overwriting symbol font `operators' in version `normal'
(Font)                  OT1/cmr/m/n --> EU2/5ch/m/n on input line 9.
LaTeX Font Info:    Encoding `OT1' has changed to `EU2' for symbol font
(Font)              `operators' in the math version `bold' on input line 9.
LaTeX Font Info:    Overwriting symbol font `operators' in version `bold'
(Font)                  OT1/cmr/bx/n --> EU2/5ch/m/n on input line 9.
LaTeX Font Info:    Overwriting symbol font `operators' in version `normal'
(Font)                  EU2/5ch/m/n --> EU2/5ch/m/n on input line 9.
LaTeX Font Info:    Overwriting math alphabet `\mathit' in version `normal'
(Font)                  OT1/cmr/m/it --> EU2/5ch/m/it on input line 9.
LaTeX Font Info:    Overwriting math alphabet `\mathbf' in version `normal'
(Font)                  OT1/cmr/bx/n --> EU2/5ch/bx/n on input line 9.
LaTeX Font Info:    Overwriting math alphabet `\mathsf' in version `normal'
(Font)                  OT1/cmss/m/n --> EU2/5fp/m/n on input line 9.
LaTeX Font Info:    Overwriting math alphabet `\mathtt' in version `normal'
(Font)                  OT1/cmtt/m/n --> EU2/lmtt/m/n on input line 9.
LaTeX Font Info:    Overwriting symbol font `operators' in version `bold'
(Font)                  EU2/5ch/m/n --> EU2/5ch/bx/n on input line 9.
LaTeX Font Info:    Overwriting math alphabet `\mathit' in version `bold'
(Font)                  OT1/cmr/bx/it --> EU2/5ch/bx/it on input line 9.
LaTeX Font Info:    Overwriting math alphabet `\mathsf' in version `bold'
(Font)                  OT1/cmss/bx/n --> EU2/5fp/bx/n on input line 9.
LaTeX Font Info:    Overwriting math alphabet `\mathtt' in version `bold'
(Font)                  OT1/cmtt/m/n --> EU2/lmtt/bx/n on input line 9.
LaTeX Font Warning: Font shape `EU2/5ch/bx/n' undefined
(Font)              using `EU2/5ch/m/n' instead on input line 12.
%and so on, font warning for every line
  • Did you try putting your settings after loading fontspec? – Joseph Wright May 13 '16 at 10:22
  • BTW, note that hyphenation will be wrong here for anything outside of the ASCII range – Joseph Wright May 13 '16 at 10:23
  • I just tried - Does not make a difference – JLo0815 May 13 '16 at 10:24
  • @hyphenation: I know, i cut out luainputenc for brevity – JLo0815 May 13 '16 at 10:25
  • could you please post (edit your question) that part of the log file? Often there is an hint, why the font is substituted. – aronadaal May 13 '16 at 10:31
0

While it is possible to use these fonts with lualatex (by using the correct fontencoding and not using fontspec) I wouldn't recommend it. The hyphenation will be wrong and you will get problems with non-ascii-chars like umlauts. If you want to switch to lualatex do it properly and use open type fonts.

If you want to try it out do it like this:

\documentclass{article}

%load polyglossia or fontspec here if needed

\usepackage[T1]{fontenc} %probably, or [OT1]
  \renewcommand*{\rmdefault}{5ch}
  \renewcommand*{\sfdefault}{5fp}


\begin{document}
 %test non-ascii
 äöü§ß Euro: € 

    Charter\\
Normal\\
\textbf{textbf}\\
\textit{textit}\\
\textsc{textsc}\\
CAPSLOCK\\
\textbf{\textit{textbf textit}}

{\sffamily
    Frontpage\\
Normal\\
\textbf{textbf}\\
\textit{textit}\\
\textsc{textsc}\\
CAPSLOCK\\
\textbf{\textit{textbf textit}}
}
\end{document}

The "test non-ascii" will more less look like this which shows the problems you will get:

enter image description here

  • luainputenc should fix the non-ascii problems – Robert May 13 '16 at 15:27
  • @Robert: I know but imho it is at best a work-around. – Ulrike Fischer May 13 '16 at 15:36
  • @Robert luainputenc does not fix the non-ascii problems, even if one attempts things like \usepackage{textcomp} as one would do with pdftex. – user4686 May 13 '16 at 17:54
0

Your tex file looks wired. My code for including fonts did always look different from that. Dante has a good fontspec example on their ftp. ftp://ftp.dante.de/tex-archive/macros/latex/contrib/fontspec/fontspec-example.tex

\documentclass{article}

\usepackage{fontspec}

\setmainfont{TeX Gyre Pagella}
\setsansfont{TeX Gyre Heros}[Scale=MatchLowercase]
\setmonofont{Inconsolata}[Scale=MatchLowercase]

\begin{document}
\pagestyle{empty}

\section*{The basics of the \textsf{fontspec} package}

The \textsf{fontspec} package enables automatic font selection
for \LaTeX{} documents typeset with Xe\TeX{} or Lua\TeX.
The basic command is

{\centering \verb|\fontspec{font display name}[font features]|.\par}

The default, sans serif, and typewriter fonts may be set with the
commands \verb|\setmainfont|, \verb|\setsansfont| and \verb|\setmonofont|,
respectively, as shown in the preamble. They take the
same syntax as the \verb|\fontspec| package. All expected font
shapes are available:

\begin{center}
  {\itshape Italics and \scshape small caps\dots}\\
  {\sffamily\bfseries Bold sans serif and \itshape bold italic sans serif\dots}
\end{center}



Text fonts in maths mode are also changed (e.g., notice the cosine function in
`$\cos(n\pi)=\pm 1$') but only if the roman and sans serif fonts are set in
the preamble; \verb|\setmainfont| will not affect these maths mode fonts when
called mid-document.
Maths symbols themselves are not affected.

Notice the font features used to load the default fonts in the preamble.
\verb|Ligatures=TeX| is automatically enabled for the roman and sans font,
allowing regular \TeX{} ligatures like \verb|``---''| for ``---''.
\verb|Scale=MatchLowercase| automatically scales the fonts to
the same x-height.

Please see the complete \textsf{fontspec} documentation for further
information.

\end{document}

You also should have a look at the very good documented fontspec documentation here: https://www.ctan.org/pkg/fontspec

The README already contains the necessary commands.

Bye, aronadaal

P.S: Is your font-cache up-to-date?

  • This is the way to load OpenType or TrueType fonts in fontspec. I don't want to use them because: a) The TrueType-versions I have of my fonts have limited features so its not a 1:1-replacement compared to pdflatex and b) it would require me to rewrite a whole custom class which currently loads the fonts the way I showed above. My question is rather: is there a way to make this font loading mechanism work with fontspec used or do I need avoid fontspec at all to make it work? – JLo0815 May 13 '16 at 10:57

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.