Command \texteuro unavailable in encoding T1

I want to know how does LaTeX figures out if the Eurosymbol (€) is a glyph of a given T1 font. I tried \iffontchar but it seems the value is not unique. AFAIK it's not a standard symbol of the 256 characters, so I'm interested in the algorithm.

Please note: I'm not interested in using the € symbol if my font doesn't has the glyph. I just want to catch the error and make it relax or redefine if glyph not in font. I'm also not interested in using opentype font.

Also the answer should work for PDFLaTeX, LuaLaTeX and XeLaTeX.

Here is what I wrote so far when I came across this:

\documentclass[11pt,a4paper]{article}
\usepackage{iftex}
\ifPDFTeX
\input glyphtounicode
\pdfgentounicode=1
\usepackage[utf8]{inputenc}
\else
\ifLuaTeX
\input glyphtounicode
\pdfgentounicode=1
\usepackage[utf8]{luainputenc}
\else
\ifXeTeX %XeTeX T1 german special char fix
\usepackage{newunicodechar}
\newunicodechar{ß}{\ss}
\newunicodechar{ä}{\"{a}}
\newunicodechar{ü}{\"{u}}
\newunicodechar{ö}{\"{o}}
\newunicodechar{Ä}{\"{A}}
\newunicodechar{Ü}{\"{U}}
\newunicodechar{Ö}{\"{O}}
\newunicodechar{§}{\textsection}% I think it's okay because standard character... but
%\newunicodechar{€}{here it should check if eurosymbol in t1 font and if not let him relax (print nothing)}
\renewcommand{\SS}{\iffontchar\font"1E9E \symbol{"1E9E}\else SS\fi}
\fi
\fi
\fi
\usepackage[ngerman]{babel}
\usepackage[left=3.5cm,right=3cm,bottom=3.5cm]{geometry}
\usepackage[default,t1,osf,semibold]{raleway}
\usepackage{microtype}
\begin{document}
Office 0123456789 äüöÄÜÖß \texteuro € \textmu
\end{document}


Update Using textcomp package works and gets an unfaked glyph from the font. So this is solved. But I'm still interested in how I should define the %\newunicodechar{€}{} for fonts which don't have the special letters.

• I am not a XeLaTeX expert, but do you not need one of the packages textcomp, fourier, marvosym, for example for \texteuro? – user31729 Jul 16 '14 at 21:06
• No, the textcomp package fakes the glyph if it's not available. I don't want this and because of this I made the topic! – Tim Jul 16 '14 at 21:07
• If you're "not interested" in OpenType fonts, why do you care that the solution work under LuaLaTeX and XeLaTeX (in addition to, of course, pdfLaTeX)? One big reason for using LuaLaTeX and XeLaTeX is their ability to access OpenType fonts... – Mico Jul 16 '14 at 21:09
• There are a number of reasons to use Lua(La)TeX besides just OpenType fonts: luamplib, lua scripting, etc. – acarlow Jul 16 '14 at 22:10
• textcomp takes the glyph from a different (TS1 encoded) font not the T1 encoded font (these may be the same underlying type 1 font encoded two different ways but TeX does not "know" that.) – David Carlisle Jul 16 '14 at 22:25

With utf8 the Unicode character € is mapped to \texteuro, which requires textcomp. The definition of \texteuro is

\DeclareTextCommandDefault{\texteuro}
{\CheckEncodingSubset\UseTextSymbol{TS1}\tc@fake@euro5\texteuro}


If the TS1 font for the current family is known not to have the Euro symbol (that is, it belongs to class 5), the glyph is faked by means of \tc@fake@euro. If you want instead to raise an error, just change the definition of this macro:

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{textcomp}

\makeatletter
\def\tc@fake@euro#1{%
\@latex@error{No \noexpand#1in family \f@family}{}%
}
\makeatother

\begin{document}
X€X

\fontfamily{put}\selectfont % put belongs to class 5
X€X
\end{document}


This will issue

! LaTeX Error: No \texteuro in family put.


and no glyph will be printed. You could define it to use a glyph from another font instead, say

\def\tc@fake@euro#1{{%
\fontencoding{TS1}\fontfamily{lmr}\selectfont\symbol{191}%
}}


Note that a test based on \iffontchar\font191 will not succeed, because usually fonts built with fontinst have a black square for inexistent characters. Therefore textcomp bases its decision to fake or not a glyph on an internal database.

By the way, \iffontchar\font"1E9E will return false if eight bit TeX fonts are used, so it's a pretty useless test.

• Helped me with \textquotesingle as well – silvado Dec 5 '16 at 17:00

LaTeX does not need to check anything, the T1 encoding doesn't include euro by definition. It is in the TS1 encoding (as used by textcomp) and of course in the EU1 and EU2 encodings used by lua and xe latex.

if everything else fails, you can try to fake the euro sign. this solution may not look as good, but it works anytime:

\newcommand{\euro}{{\mathrm{C}\!\!\!\!\!\!=}}