Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

There are two macros that bear the name of current font encoding. First is \cf@encoding which seems to be set by core of LaTeX 2e and NFSS and changed by the fontenc package. Second macro is \UTFencname. It is set, in particluar, by fontspec package and, perhaps, by some other packages that deal with OTF/TTF fonts and unicode. What is the relation between these two macros? I noted \cf@encoding also changes when LuaLaTeX runs.

share|improve this question
add comment

1 Answer

up vote 6 down vote accepted

\cf@encoding (current font encoding) is the core command. There is also f@encoding which is used by \fontencoding to store its argument. In general both have the same value except between the \fontencoding and the next \selectfont:

\documentclass[a4paper]{article}
\usepackage[T1]{fontenc}
\begin{document}
\makeatletter
\f@encoding, \cf@encoding; 
\fontencoding{OT1}
\f@encoding, \cf@encoding;
\selectfont 
\f@encoding, \cf@encoding;
\end{document}

\UTFencname is a command used by xunicode in its various declarations. (xunicode can setup definitions for various encoding names). fontspec sets UTFencname to the correct "unicode encoding" name before loading xunicode (EU1 for xetex, EU2 for luatex, the reason for the different names is that the two engines needs different fd-files/font declarations to load fonts as they use a different syntax).

UTFencname is normally fix in a document. It doesn't change if you switch to another font encoding:

\documentclass[a4paper]{article}
\usepackage{fontspec}
\begin{document}
\makeatletter
\f@encoding, \cf@encoding,\UTFencname;
\fontencoding{OT1}
\selectfont 
\f@encoding, \cf@encoding,\UTFencname;
\end{document}
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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