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.
Best Answer
With
utf8
the Unicode character€
is mapped to\texteuro
, which requirestextcomp
. The definition of\texteuro
isIf 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:This will issue
and no glyph will be printed. You could define it to use a glyph from another font instead, say
Note that a test based on
\iffontchar\font191
will not succeed, because usually fonts built withfontinst
have a black square for inexistent characters. Thereforetextcomp
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.