\ProvidesPackage{cu-kinovar}[2020/10/21 v1.2 CU Kinovar]

\RequirePackage{cu-util}
\RequirePackage{etoolbox}
\RequirePackage{xcolor}
\RequirePackage{ifluatex}
\ifluatex
  \RequirePackage{luacolor}
\fi

\newcommand{\cu@kinovar}[1]{\textcolor{kinovar}{#1}}
\newcommand{\cuKinovarColor}{\color{kinovar}}

\DeclareOption{color}{
  \colorlet{kinovar}{kinovar-red}
}
\DeclareOption{gray}{
  \colorlet{kinovar}{kinovar-gray}
}
\DeclareOption{grey}{
  \colorlet{kinovar}{kinovar-gray}
}
\DeclareOption{bw}{
  \colorlet{kinovar}{kinovar-black}
}

% define standard colors
\definecolor{kinovar-red}{rgb}{0.80,0.03,0.01}
\colorlet{kinovar-black}{.}
\definecolor{kinovar-gray}{rgb}{0.45,0.45,0.45}

\ExecuteOptions{color}
\ProcessOptions\relax

% cuKinovar command colors just one letter with all accents if any
\newrobustcmd{\cuKinovar}{\cu@tokenizeletter{\cu@kinovar@kern}}

\newcommand{\cu@kinovar@kern}[1]{%
  \cu@kinovar{#1}%
  \cu@ifnextletter{\cu@kinovar@insert@kern{#1}}{}%
}%
\newsavebox\cu@box@zero
\newsavebox\cu@box@one
\newdimen\cu@kerning
\newcommand{\cu@kinovar@insert@kern}[2]{%
  \sbox\cu@box@zero{#1#2}\sbox\cu@box@one{\mbox{#1}\mbox{#2}}%
  \dimen\cu@kerning=\dimexpr\wd\cu@box@zero-\wd\cu@box@one
  \kern\dimen\cu@kerning #2%
}%

\endinput
