\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{tudafonts}
 [\filedate\space\fileversion\space
   font loading for TUDa-CI, TU Darmstadt's Corporate Design]

\expandafter\newif\csname if@TUDa@T1\endcsname

\DeclareOption{T1}{\csname @TUDa@T1true\endcsname}
\ProcessOptions\relax

\RequirePackage{iftex}
\RequirePackage{anyfontsize}

\ifPDFTeX
    \csname @TUDa@T1true\endcsname
    %Fallback for older versions
    \expandafter\ifx\csname DeclareUnicodeCharacter\endcsname\relax
    \RequirePackage[utf8]{inputenc}
    \fi
    \expandafter\ifx\csname texteuro\endcsname\relax
       \RequirePackage{textcomp}
    \fi
    \DeclareUnicodeCharacter{20AC}{\texteuro}
\fi

\csname if@TUDa@T1\endcsname
    \RequirePackage{XCharter}%activates T1
    \PassOptionsToPackage{type1}{roboto}
    \PassOptionsToPackage{type1}{roboto-mono}
\else
    \RequirePackage{fontspec}
    \setmainfont{XCharter}
\fi

\RequirePackage{roboto}
\IfFileExists{roboto-mono.sty}{
	\RequirePackage{roboto-mono}
}{
	\PackageWarningNoLine{tudafonts}{
	The font package roboto-mono.sty could not be found. Probably your TeX-distribution is outdated.\MessageBreak
	For correct font setup either install it manually or update you distribution}
}


\ifPDFTeX
	\RequirePackage[T1]{fontenc}
\fi

\let\accentfont\robotoslab
\DeclareTextFontCommand{\textaccent}{\accentfont}

%adjust LaTeX kerning to font
\DeclareRobustCommand{\LaTeX}{%
{L\setbox\z@\hbox{\check@mathfonts \fontsize\sf@size\z@
 \math@fontsfalse\selectfont A}\kern-.57\wd\z@
 \sbox\tw@ T\vbox to \ht\tw@{\copy\z@ \vss}\kern-.2\wd\z@}%
{%
 \ifdim\fontdimen1\font=\z@ \else \count\z@=\fontdimen5\font
 \multiply\count\z@ by 64\relax\divide\count\z@ by\p@
 \count\tw@=\fontdimen1\font \multiply\count\tw@ by\count\z@
 \divide\count\tw@ by 64\relax\divide\count\tw@ by\tw@
 \kern-\the\count\tw@ sp\relax\fi}%
\TeX}

%%-----------------------------------------------------
\endinput