<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">\NeedsTeXFormat{LaTeX2e}%
\RequirePackage{keyval}%
\RequirePackage{ifluatex}%
\RequirePackage{cu-kinovar}%
\ProvidesPackage{cu-kruk}[2019/04/20 v0.2 support for kruk music notations]%
%
%% 'autocolormarks' and noautocolormarks options
\newif\ifcu@autocolormarks
\ifluatex
  \cu@autocolormarkstrue
\else
  \cu@autocolormarksfalse
\fi

\DeclareOption{autocolormarks}{
  \cu@autocolormarkstrue
  \ifluatex\relax\else\message{WARNING: autocolormarks option may not work correctly with this TeX engine. See documentation for more details.}\fi
}
\DeclareOption{noautocolormarks}{
  \cu@autocolormarksfalse
}

\ProcessOptions\relax

\let\cuKrukFont\relax %% to be defined by the user
%
\newlength{\cuKrukSylSpace}  %% spacing around kruk syllable
\newlength{\cuKrukTopMargin} %% top margin ensures that lines are nicely separated
\newlength{\cuKrukSylRuleHeight}  %% how thick placeholder rule is
\newlength{\cuKrukRaise} %% distance between text and kruk baselines
%
\setlength{\cuKrukSylSpace}{0.2em}
\setlength{\cuKrukTopMargin}{0.3em}
\setlength{\cuKrukSylRuleHeight}{0.08em}
\setlength{\cuKrukRaise}{1em}

\define@key{cuKruk}{krukFont}{\def\cuKrukFont{#1}}%
\define@key{cuKruk}{sylSpace}{\setlength{\cuKrukSylSpace}{#1}}%
\define@key{cuKruk}{topMargin}{\setlength{\cuKrukTopMargin}{#1}}%
\define@key{cuKruk}{sylRuleHeight}{\setlength{\cuKrukSylRuleHeight}{#1}}%
\define@key{cuKruk}{krukRaise}{\setlength{\cuKrukRaise}{#1}}%
\define@boolkey{cuKruk}{invertColor}[true]{}%

\newcommand{\cuKruk}[3][]{%
  \bgroup
  \setkeys{cuKruk}{#1}%
  \cu@@Kruk{#2}{#3}%
  \egroup
}%
\def\cu@@Kruk#1#2{{%
  \edef\cu@tmp{\csname \detokenize{#2}cu@@@\endcsname}%
  \setbox1=\hbox{{%
    \ifKV@cuKruk@invertColor
      \colorlet{tmp}{.}\color{kinovar}\colorlet{kinovar}{tmp}%
    \fi
    \cuKrukFont#1%
  }}%
  \dimen0=\ht1\advance\dimen0 by \cuKrukTopMargin\ht1=\dimen0%
  \if\relax\detokenize{#2}\relax
    \setbox2=\hbox{\vrule height \cuKrukSylRuleHeight width \wd1}%
  \else
    \ifx\cu@tmp\cu@Tilda
      \setbox2=\hbox{\vrule height \cuKrukSylRuleHeight width \wd1}%
    \else
      \setbox2=\hbox{#2}%
    \fi
  \fi
  \ifdim\wd1&gt;\wd2%
    \setbox2=\hbox to \wd1{\hss\box2\hss}%
  \fi
  %\discretionary{}{}{}%
  \hskip\cuKrukSylSpace\penalty5000\hbox to \wd2{%
  \hskip0.5\wd2\hskip-0.5\wd1\raise\cuKrukRaise\copy1\kern-0.5\wd2\kern-0.5\wd1\copy2\hss
  }\penalty10000\hskip\cuKrukSylSpace
}}%
%
\newlength{\cuSupRaise} %% controls extra vertical space between Sup and Base
\setlength{\cuSupRaise}{0ex}
\define@key{cuSup}{raise}{\setlength{\cuSupRaise}{#1}}%

\newcommand{\cuSup}[3][]{%
  \bgroup
  \setkeys{cuSup}{#1}%
  \cu@@Sup{#2}{#3}%
  \egroup
}%
\def\cu@@Sup#1#2{{%
  \leavevmode
  \setbox1=\hbox{#1}%
  \setbox2=\hbox{#2}%
  \dimen0=\ht2%
  \advance\dimen0 by \dp1%
  \message{\the\dimen0}%
  \advance\dimen0 by \cuSupRaise
  \advance\dimen0 by -0.25\ht1%
  \hbox to \wd2{%
  \hskip0.5\wd2\hskip-0.5\wd1\raise\dimen0\copy1\kern-0.5\wd2\kern-0.5\wd1\copy2\hss
  }%
}}
%
\newcounter{cu@KrukPos}%
\newcounter{cu@SylPos}%
%
\newcommand{\cuKrukPara}[2][]{%
  \cu@KrukPara[#1]#2\cu@End
}%
%
\def\cu@KrukPara[#1]#2\\#3\cu@End{%
\bgroup
\setkeys{cuKruk}{#1}%
\setcounter{cu@KrukPos}{0}%
\setcounter{cu@SylPos}{0}%
\cu@Kruk #2 \cu@EndKruk
\cu@Text #3 \cu@EndText
\ifnum\thecu@SylPos&lt;\thecu@KrukPos\errmessage{Too many kruk groups. Seen {\thecu@KrukPos} kruk groups and {\thecu@SylPos} text groups}\fi
\egroup
}%
%
\def\cu@Kruk#1 #2\cu@EndKruk{%
\if\relax\detokenize{#1}\relax\else
\cu@KrukAction{#1}%
\fi
\if\relax\detokenize{#2}\relax\else
  \cu@Kruk#2\cu@EndKruk
\fi
}%
%
\def\cu@KrukAction#1{%
\edef\cu@tmp{\csname \detokenize{#1}cu@@@\endcsname}%
\ifx\cu@tmp\cu@Tilda
  \expandafter\edef\csname cu@@\thecu@KrukPos\endcsname{}%
\else
  \expandafter\def\csname cu@@\thecu@KrukPos\endcsname{#1}%
\fi
\stepcounter{cu@KrukPos}%
}
%
\edef\cu@Tilda{\csname \detokenize{~}cu@@@\endcsname}%
\edef\cu@Empty{\csname \detokenize{}cu@@@\endcsname}%
%
\def\cu@Text#1 #2\cu@EndText{%
\if\relax\detokenize{#1}\relax\else
  \cu@TextDash#1-\cu@EndText\space
\fi
\if\relax\detokenize{#2}\relax\else
  \cu@Text#2\cu@EndText
\fi
}%
%
\def\cu@TextDash#1-#2\cu@EndText{%
\cu@TextAction{#1}%
\if\relax\detokenize{#2}\relax\else
  \cu@TextDash#2\cu@EndText
\fi
}%
%
\def\cu@TextAction#1{%
\ifnum\thecu@SylPos&gt;\thecu@KrukPos
  \errmessage{Too few kruk groups. Seen {\thecu@KrukPos} kruk groups and {\thecu@SylPos} text groups}%
\fi
\edef\cu@tmp{\csname \detokenize{#1}cu@@@\endcsname}%
\ifx\cu@tmp\cu@Empty
  \expandafter\cuKruk\expandafter{\csname cu@@\thecu@SylPos\endcsname}{}%
\else
  \ifx\cu@tmp\cu@Tilda
    \expandafter\cuKruk\expandafter{\csname cu@@\thecu@SylPos\endcsname}{}%
  \else
    \expandafter\cuKruk\expandafter{\csname cu@@\thecu@SylPos\endcsname}{#1}%
  \fi
\fi
\stepcounter{cu@SylPos}%
}%
%
% Automatic coloring of kruk marks (pomety)
\ifcu@autocolormarks
\catcode`ðœ¼€\active\defðœ¼€{\cuKinovar{\detokenize{ðœ¼€}}}%
\catcode`ðœ¼\active\defðœ¼{\cuKinovar{\detokenize{ðœ¼}}}%
\catcode`ðœ¼‚\active\defðœ¼‚{\cuKinovar{\detokenize{ðœ¼‚}}}%
\catcode`ðœ¼ƒ\active\defðœ¼ƒ{\cuKinovar{\detokenize{ðœ¼ƒ}}}%
\catcode`ðœ¼„\active\defðœ¼„{\cuKinovar{\detokenize{ðœ¼„}}}%
\catcode`ðœ¼…\active\defðœ¼…{\cuKinovar{\detokenize{ðœ¼…}}}%
\catcode`ðœ¼†\active\defðœ¼†{\cuKinovar{\detokenize{ðœ¼†}}}%
\catcode`ðœ¼‡\active\defðœ¼‡{\cuKinovar{\detokenize{ðœ¼‡}}}%
\catcode`ðœ¼ˆ\active\defðœ¼ˆ{\cuKinovar{\detokenize{ðœ¼ˆ}}}%
\catcode`ðœ¼‰\active\defðœ¼‰{\cuKinovar{\detokenize{ðœ¼‰}}}%
\catcode`ðœ¼Š\active\defðœ¼Š{\cuKinovar{\detokenize{ðœ¼Š}}}%
\catcode`ðœ¼‹\active\defðœ¼‹{\cuKinovar{\detokenize{ðœ¼‹}}}%
\catcode`ðœ¼Œ\active\defðœ¼Œ{\cuKinovar{\detokenize{ðœ¼Œ}}}%
\catcode`ðœ¼\active\defðœ¼{\cuKinovar{\detokenize{ðœ¼}}}%
\catcode`ðœ¼Ž\active\defðœ¼Ž{\cuKinovar{\detokenize{ðœ¼Ž}}}%
\catcode`ðœ¼\active\defðœ¼{\cuKinovar{\detokenize{ðœ¼}}}%
\catcode`ðœ¼\active\defðœ¼{\cuKinovar{\detokenize{ðœ¼}}}%
\catcode`ðœ¼‘\active\defðœ¼‘{\cuKinovar{\detokenize{ðœ¼‘}}}%
\catcode`ðœ¼’\active\defðœ¼’{\cuKinovar{\detokenize{ðœ¼’}}}%
\catcode`ðœ¼“\active\defðœ¼“{\cuKinovar{\detokenize{ðœ¼“}}}%
\catcode`ðœ¼”\active\defðœ¼”{\cuKinovar{\detokenize{ðœ¼”}}}%
\catcode`ðœ¼•\active\defðœ¼•{\cuKinovar{\detokenize{ðœ¼•}}}%
\catcode`ðœ¼–\active\defðœ¼–{\cuKinovar{\detokenize{ðœ¼–}}}%
\catcode`ðœ¼—\active\defðœ¼—{\cuKinovar{\detokenize{ðœ¼—}}}%
\catcode`ðœ¼˜\active\defðœ¼˜{\cuKinovar{\detokenize{ðœ¼˜}}}%
\catcode`ðœ¼™\active\defðœ¼™{\cuKinovar{\detokenize{ðœ¼™}}}%
\catcode`ðœ¼š\active\defðœ¼š{\cuKinovar{\detokenize{ðœ¼š}}}%
\catcode`ðœ¼›\active\defðœ¼›{\cuKinovar{\detokenize{ðœ¼›}}}%
\catcode`ðœ¼œ\active\defðœ¼œ{\cuKinovar{\detokenize{ðœ¼œ}}}%
\catcode`ðœ¼\active\defðœ¼{\cuKinovar{\detokenize{ðœ¼}}}%
\catcode`ðœ¼ž\active\defðœ¼ž{\cuKinovar{\detokenize{ðœ¼ž}}}%
\catcode`ðœ¼Ÿ\active\defðœ¼Ÿ{\cuKinovar{\detokenize{ðœ¼Ÿ}}}%
\catcode`ðœ¼&nbsp;\active\defðœ¼&nbsp;{\cuKinovar{\detokenize{ðœ¼&nbsp;}}}%
\catcode`ðœ¼¡\active\defðœ¼¡{\cuKinovar{\detokenize{ðœ¼¡}}}%
\catcode`ðœ¼¢\active\defðœ¼¢{\cuKinovar{\detokenize{ðœ¼¢}}}%
\catcode`ðœ¼£\active\defðœ¼£{\cuKinovar{\detokenize{ðœ¼£}}}%
\catcode`ðœ¼¤\active\defðœ¼¤{\cuKinovar{\detokenize{ðœ¼¤}}}%
\catcode`ðœ¼¥\active\defðœ¼¥{\cuKinovar{\detokenize{ðœ¼¥}}}%
\catcode`ðœ¼¦\active\defðœ¼¦{\cuKinovar{\detokenize{ðœ¼¦}}}%
\catcode`ðœ¼§\active\defðœ¼§{\cuKinovar{\detokenize{ðœ¼§}}}%
\catcode`ðœ¼¨\active\defðœ¼¨{\cuKinovar{\detokenize{ðœ¼¨}}}%
\catcode`ðœ¼©\active\defðœ¼©{\cuKinovar{\detokenize{ðœ¼©}}}%
\catcode`ðœ¼ª\active\defðœ¼ª{\cuKinovar{\detokenize{ðœ¼ª}}}%
\catcode`ðœ¼«\active\defðœ¼«{\cuKinovar{\detokenize{ðœ¼«}}}%
\catcode`ðœ¼¬\active\defðœ¼¬{\cuKinovar{\detokenize{ðœ¼¬}}}%
\catcode`ðœ¼­\active\defðœ¼­{\cuKinovar{\detokenize{ðœ¼­}}}%
\fi
%
\endinput%
</pre></body></html>