<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">%#!lualatex test-gckanbun
% #!ptex2pdf -l -u test-gckanbun
% #!ptex2pdf -l test-gckanbun
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{gckanbun}
  [2021/03/27 v1.2 KANBUN typesetting package (Green Cherry Ltd.)]

%% declare package errors
\def\gcknbn@error{\PackageError{gckanbun}}
\def\gcknbn@warning{\PackageWarning{gckanbun}}
\def\gcknbn@warningnoline{\PackageWarningNoLine{gckanbun}}
\def\gcknbn@info{\PackageInfo{gckanbun}}

\RequirePackage{keyval}
\DeclareOption*{\gcknbn@setkey}
\def\gcknbn@setkey{\expandafter\@gcknbn@setkey\expandafter{\CurrentOption}}
\def\@gcknbn@setkey{\setkeys{gcknbn}}
\def\gcknbn@prefix{gckanbun}%%given &lt;prefix&gt; for each commands
\define@key{gcknbn}{prefix}{\gdef\gcknbn@prefix{#1}}

\ExecuteOptions{prefix}
\ProcessOptions\relax

%% auto-detect engine
\RequirePackage{ifuptex}
\RequirePackage{ifluatex}
\ifluatex
  \@ifpackageloaded{luatexja}{}{%
    \gcknbn@error{Please load package 'luatexja' when loading this package.}}
\else\ifuptex
  \def\zw{zw}\def\zh{zh}
\else\ifptex
  \def\zw{zw}\def\zh{zh}
\else
  \gcknbn@error{Package 'gckanbun' currently supports (u)pLaTeX and LuaLaTeX.}
\fi\fi\fi

\newcommand*\gcknbn@kanjiskip@fill{%
  \ifluatex
    \ltjsetparameter{kanjiskip=\fill}%
  \else
    \kanjiskip=\fill\relax
  \fi
}

%% 繝ｫ繝�
%%  * 繧ｰ繝ｫ繝ｼ繝励Ν繝�
%%  * 貍｢譁�ｨ鍋せ縺ｫ蟇ｾ縺吶ｋ縺ｵ繧翫′縺ｪ�医Δ繝弱Ν繝難ｼ�
\let\gcknbn@rubybox@text\relax
\newdimen\gcknbn@rubybox@width
\newdimen\gcknbn@furigana@width \gcknbn@furigana@width\z@
\newdimen\gcknbn@dima
\DeclareRobustCommand*\gcknbn@ruby[2]{%
  \leavevmode% \setbox0=\hbox{#1}\setbox1=\hbox{\tiny#2}%
  \begingroup
    \gcknbn@dima\f@size\p@\relax \divide\gcknbn@dima by \tw@
    \def\tiny{\@setfontsize\tiny{\gcknbn@dima}{\z@}}%
    \setbox\z@=\hbox{#1}\setbox\@ne=\hbox{\tiny#2}%
    \gdef\gcknbn@rubybox@text{#2}%
    \global\gcknbn@rubybox@width=\wd\z@\relax
    \gcknbn@furigana@okurigana}

\def\gcknbn@furigana@okurigana{%
  \futurelet\@let@token\gcknbn@@furigana@okurigana}
\def\gcknbn@@furigana@okurigana{%
    \ifx\@let@token\gcknbn@okurigana
      \global\gcknbn@furigana@width=\wd\@ne\relax
      \dimen\z@=\wd\z@
      \smash{\hbox{%
        \vbox{\hbox to \dimen\z@{\box\@ne\hss}%
          \nointerlineskip\hbox to \dimen\z@{\hfil\box\z@\hfil}}}}%
    \else
      \ifdim\wd\z@&gt;\wd\@ne\dimen\z@=\wd\z@\else\dimen\z@=\wd\@ne\fi
      \penalty\@lowpenalty
      \smash{\hbox{\gcknbn@kanjiskip@fill
        \vbox{\hbox to \dimen\z@{\tiny\hfil\gcknbn@rubybox@text\hfil}%
          \nointerlineskip\hbox to \dimen\z@{\hfil\box\z@\hfil}}}}%
    \fi
  \endgroup}

%% 險鍋せ
\newdimen\gcknbn@okurigana@width \gcknbn@okurigana@width\z@
\newdimen\gcknbn@kaeriten@width \gcknbn@kaeriten@width\z@
%%險鍋せ騾√ｊ莉ｮ蜷�
\newcommand*\gcknbn@okurigana[1]{%
  \nobreak\leavevmode
  \begingroup
    \gcknbn@dima\f@size\p@\relax \divide\gcknbn@dima by \tw@
    \def\tiny{\@setfontsize\tiny{\gcknbn@dima}{\z@}}%
    \setbox\z@=\hbox{\tiny #1}%
    \ifdim\gcknbn@furigana@width&gt;0.9999\zw\relax
      \global\gcknbn@okurigana@width=\dimexpr\gcknbn@furigana@width + \wd\z@ - 1\zw\relax
    \else
      \global\gcknbn@okurigana@width=\dimexpr\wd\z@ - .5\zw\relax
    \fi
    \smash{\hbox{%
      \vbox{\hbox to \gcknbn@okurigana@width{%
        \ifdim\gcknbn@furigana@width&gt;0.9999\zw\relax
          \hspace*{\dimexpr\gcknbn@furigana@width - 1\zw\relax}%
        \else
          \hspace*{-.5\zw}%
        \fi
        \box\z@}%
        \nointerlineskip
        \hbox to \gcknbn@okurigana@width{\hfil\vphantom{\char\euc"A1A1%"
          }\hfil}}}}%
    \global\gcknbn@furigana@width=\z@\relax
    \gcknbn@okurigana@kaeriten}

\def\gcknbn@okurigana@kaeriten{%
  \futurelet\@let@token\gcknbn@@okurigana@kaeriten}
\def\gcknbn@@okurigana@kaeriten{%
    \ifx\@let@token縲�
      \gcknbn@okurigana@kutoten@skip
      \global\gcknbn@okurigana@width=\z@
    \else\ifx\@let@token縲�
      \gcknbn@okurigana@kutoten@skip
      \global\gcknbn@okurigana@width=\z@
    \else\ifx\@let@token\gcknbn@kaeriten
      \gcknbn@okurigana@kaeriten@skip
    \fi\fi\fi
  \endgroup}
\def\gcknbn@okurigana@kutoten@skip{%
  \hspace*{-\gcknbn@okurigana@width}}
\def\gcknbn@okurigana@kaeriten@skip{%
  \hspace*{-\gcknbn@okurigana@width}}

%%險鍋せ霑斐ｊ轤ｹ
\newcommand*\gcknbn@kaeriten{%
  \@ifnextchar-{\gcknbn@tateten@kaeriten@hh}{%
  \@ifnextchar窶須\gcknbn@tateten@kaeriten@zh}{%
    \gcknbn@@kaeriten}}}

\newcommand*\gcknbn@@kaeriten[1]{%
  \nobreak\leavevmode
  \begingroup
    \gcknbn@dima\f@size\p@\relax \divide\gcknbn@dima by \tw@
    \def\tiny{\@setfontsize\tiny{\gcknbn@dima}{\z@}}%
    \setbox\z@=\hbox{\tiny #1}%
    \global\gcknbn@kaeriten@width=\wd\z@\relax
    \smash{\lower.25\zw\hbox{\box\z@\hss}}%
  \endgroup\gcknbn@kaeriten@kutoten}

\def\gcknbn@kaeriten@kutoten{\futurelet\@let@token\gcknbn@@kaeriten@kutoten}
\def\gcknbn@@kaeriten@kutoten{%
  \ifx\@let@token縲�
    \gcknbn@kaeriten@kutoten@skip
    \global\gcknbn@kaeriten@width=\z@
  \else\ifx\@let@token縲�
    \gcknbn@kaeriten@kutoten@skip
    \global\gcknbn@kaeriten@width=\z@
  \else
    \gcknbn@kaeriten@okurigana@skip
  \fi\fi
}
\def\gcknbn@kaeriten@kutoten@skip{%
  \hspace*{-\gcknbn@kaeriten@width}%
}
\def\gcknbn@kaeriten@okurigana@skip{%
  \ifdim\gcknbn@okurigana@width&gt;\gcknbn@kaeriten@width
    \hspace*{\dimexpr\gcknbn@okurigana@width - \gcknbn@kaeriten@width}%
  \fi
}

\def\gcknbn@tateten@kaeriten@hh-{\gcknbn@@tateten@kaeriten}
\def\gcknbn@tateten@kaeriten@zh窶須\gcknbn@@tateten@kaeriten}
\newcommand*\gcknbn@@tateten@kaeriten[1]{%
  \nobreak\leavevmode
  \begingroup
    \gcknbn@dima\f@size\p@\relax \divide\gcknbn@dima by \tw@
    \def\tiny{\@setfontsize\tiny{\gcknbn@dima}{\z@}}%
    \setbox\z@=\hbox{\tiny\char"3190}%"
    \global\gcknbn@kaeriten@width=\wd\z@\relax
    \smash{\lower.35\zw\hbox{%
    \vbox{\hbox to \gcknbn@kaeriten@width{\hfil\box\z@\hfil}%
    \vspace*{-.1\zw}%
    \nointerlineskip\hbox to \gcknbn@kaeriten@width{\tiny\hfil#1\hfil}}}}%
  \endgroup}

%% Finaly, provide \&lt;prefix&gt;ruby, \&lt;prefix&gt;okurigana, \&lt;prefix&gt;kaeriten
\expandafter\let\csname\gcknbn@prefix ruby\endcsname\gcknbn@ruby
\expandafter\let\csname\gcknbn@prefix okurigana\endcsname\gcknbn@okurigana
\expandafter\let\csname\gcknbn@prefix kaeriten\endcsname\gcknbn@kaeriten

\endinput
</pre></body></html>