[Tex/LaTex] Debugging ‘Font shape undefined’ and ‘Corrupted NFSS tables’ (T5, concretevn and sig-alternate)

acmfontspdftex

I was told to take a look for an unspecified problem with the fonts in one of my PDFs generated by pdflatex.. I couldn't find anything obvious, except for the innocuous:

LaTeX Font Warning: Font shape `T1/lmr/bx/sc' undefined
(Font)              using `T1/lmr/bx/n' instead on input line 103.

Well, what I wanted to have is basically portions of text written in small caps, and I liked concretevn; however, what I was not aware of, is that this is a Vietnamese font, and it follows T5 encoding! That I realised only after finding and looking at concretevn-test.tex.

So I thought I try to look at this on an minimal example, and I think there are some problems when using this font and Alternate ACM LaTeX2e Style File V2.4 (APRIL 2009 CLS) (from ACM SIG Proceedings Templates — Association for Computing Machinery).

First, there are seemingly no problems at all when using the default article document class (calling the file fonttest.tex):

\documentclass{article}

\usepackage[T5]{fontenc}    % must have for new font selection style (11533 bytes PDF size)
                            % , else on \fontencoding{T5} line:
                            %% ! LaTeX Error: Encoding scheme `T5' unknown.
                            % ... not needed for old (?) font selection style;
                            % but if used, 11534 bytes - if not used, 17846 bytes of PDF size


%%%%% old (?) font selection style
% \newfont{\myscfont}{vncccsc10 scaled 900}

\begin{document}

This is a test of normal text... This is a test of normal text... This is a test of normal text... This is a test of normal text...

{
%%%%% old (?) font selection style
% \myscfont

%%%%% new font selection style
\fontencoding{T5}
\fontfamily{ccr}
\fontseries{m}
\fontshape{sc}
\fontsize{10}{12}
\selectfont
  Trying Small Caps Out...
}

This is a test of normal text... This is a test of normal text... This is a test of normal text... This is a test of normal text...

\end{document}

Both old (?) and new font selection system (NFSS) work fine (the above file demonstrating the NFSS method); pdflatex doesn't give any warnings or errors; evince opens PDF file OK; pdffonts reports:

$ pdffonts fonttest.pdf
name                                 type              emb sub uni object ID
------------------------------------ ----------------- --- --- --- ---------
TVOLGQ+VNR10                         Type 1            yes yes no       4  0
VNWFOD+Vncccsc10                     Type 1            yes yes no       5  0

 

The problem starts if I replace the article document class with \documentclass{sig-alternate}:

...
No file fonttest.aux.
! Corrupted NFSS tables.
wrong@fontshape ...message {Corrupted NFSS tables}
                                                  error@fontshape else let f...
l.14 \begin{document}
...

If I press ENTER here, the pdf actually does get generated:

LaTeX Font Warning: Some font shapes were not available, defaults substituted.
...
Output written on fonttest.pdf (1 page, 17702 bytes).

$ pdffonts fonttest.pdf
name                                 type              emb sub uni object ID
------------------------------------ ----------------- --- --- --- ---------
NJOBBG+CMR10                         Type 1            yes yes no       4  0
VNWFOD+Vncccsc10                     Type 1            yes yes no       5  0

… and strangely, the font does seem to be embedded fine ?! In any case, evince opens it fine, shows the right fonts…

Now, where I get surprised, is if I look at the .log file:

...
LaTeX Font Info:    Redeclaring font encoding T1 on input line 43.
)
LaTeX Font Info:    Try loading font information for T1+aer on input line 100.

(/path/to/texlive/texmf-dist/tex/latex/ae/t1aer.fd
File: t1aer.fd 1997/11/16 Font definitions for T1/aer.
)))
(/path/to/texlive/texmf-dist/tex/latex/base/fontenc.sty
Package: fontenc 2005/09/27 v1.99g Standard LaTeX package

(/path/to/texlive/texmf-dist/tex/latex/vntex/t5enc.def
File: t5enc.def 2006/11/21 v1.4 Vietnamese T5 encoding
)
LaTeX Font Info:    Try loading font information for T5+aer on input line 100.
LaTeX Font Info:    No file T5aer.fd. on input line 100.

LaTeX Font Warning: Font shape `T5/aer/m/n' undefined
(Font)              using `T5/cmr/m/n' instead on input line 100.

LaTeX Font Info:    Try loading font information for T5+cmr on input line 100.
(/path/to/texlive/texmf-dist/tex/latex/vntex/t5cmr.fd
File: t5cmr.fd 1999/05/25 v2.5h Standard LaTeX font definitions
))
....
LaTeX Font Info:    Checking defaults for U/cmr/m/n on input line 14.
LaTeX Font Info:    ... okay on input line 14.
LaTeX Font Info:    Checking defaults for T5/cmr/m/n on input line 14.
LaTeX Font Info:    ... okay on input line 14.
! Corrupted NFSS tables.
wrong@fontshape ...message {Corrupted NFSS tables}
                                                  error@fontshape else let f...
l.14 \begin{document}

?

LaTeX Font Warning: Font shape `T5/aer/m/n' undefined
(Font)              using `OT1/cmr/m/n' instead on input line 14.
...
LaTeX Font Info:    Try loading font information for T5+ccr on input line 28.

(/path/to/texlive/texmf-dist/tex/latex/vntex/t5ccr.fd
File: t5ccr.fd 2006/08/02 Fontinst v1.927 font definitions for T5/ccr.
) [1

{/path/to/texlive/texmf-var/fonts/map/pdftex/updmap/pdftex.map}

] (./fonttest.aux)

LaTeX Font Warning: Some font shapes were not available, defaults substituted.
....

Note that the same behavour (Corrupted NFSS tables with sig-alternate) happens if I use the old (?) font selection style, too – but only if the line "\usepackage[T5]{fontenc}" is used! If this line is commented, then pdflatex reports no warnings, and evince renders the PDF fine.

Now, if I'm reading the .log correctly, "Font shape 'T5/aer/m/n' undefined" basically means something requested the aer font in T5 encoding; but I don't understand what?! The sig-alternate class indeed uses this aer font:

$ grep -n --context=1 aer sig-alternate.cls
1458-\ProcessOptions
1459:\fontfamily{aer}
1460-\RequirePackage[T1]{fontenc}
--
1466-    \renewcommand{\sfdefault}{aess}
1467:    \renewcommand{\rmdefault}{aer}
1468-    \renewcommand{\ttdefault}{aett}

… but the way I see it – shouldn't all this (related to aer font) have been set up when the "\documentclass{...}" command executes; and then when the .tex file comes to the "\fontencoding{T5}" part, shouldn't it refer only to the "\fontfamily{ccr}" font ?!

That is what I'd like to understand better – because in my original problem (where I use the old style font selection) pdflatex seemingly looks for the small caps font in T1 encoding (and looks for the wrong font, lmr, at that), which I cannot reproduce in the minimal example above; I could maybe try to include a "\usepackage[T5]{fontenc}" to deal with that – but the minimal example tells me trouble awaits there? So how would I proceed with debugging that?

Thanks in advance for any comments,
Cheers!

Best Answer

You don't want to use T5 encoding as the default encoding. So don't load it as the only (and the last encoding). Load both encodings and set T1 as default by loading it last:

\documentclass{article}
\usepackage[T5,T1]{fontenc}    
\begin{document}
abc 

{\fontencoding{T5}
\fontfamily{ccr}
\fontseries{m}
\fontshape{sc}
\fontsize{10}{12}
\selectfont
  Trying Small Caps Out...
}
\end{document}

This will work with your class too.

Your class is using the ae-fonts as default. Something which nobody today would do. Also for some reason is sets the font family in the preamble to aer, that confuses latex in combination with the T5 encoding and leds to your corrupted NFSS table message.

I would suggest to undo the aer setting e.g. with

\fontfamily{cmr} %only needed it T5 is default encoding
\renewcommand{\sfdefault}{cmss}
\renewcommand{\rmdefault}{cmr}
\renewcommand{\ttdefault}{cmtt}

or

\fontfamily{lmr} %only needed it T5 is default encoding
\usepackage{lmodern}