%%% License %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% This package is licensed under the terms of the MIT License.

% Copyright (c) 2025-2026 Kosei Kawaguchi

% Permission is hereby granted, free of charge, 
% to any person obtaining a copy of this software and associated documentation files 
% (the "Software"), to deal in the Software without restriction, 
% including without limitation the rights to use, copy, modify, merge, publish, 
% distribute, sublicense, and/or sell copies of the Software, 
% and to permit persons to whom the Software is furnished to do so, 
% subject to the following conditions:

% The above copyright notice and this permission notice 
% shall be included in all copies or substantial portions of the Software.

% THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 
% EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 
% FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 
% IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, 
% DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 
% ARISING FROM, 
% OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{KKsymbols}[2026/04/17, Version 2.1.4]
\RequirePackage{luatexja-adjust, luacode, kvoptions}
\RequirePackage{calc}
\RequirePackage{tikz}
  \usetikzlibrary{shapes}

%%% package options
\SetupKeyvalOptions{%
  family=kksymbols,%
  prefix=kksymbols@%
}
\DeclareStringOption[1]{tsumesuji}
\ProcessKeyvalOptions*
%%%

%%% KKsymbols.lua
\directlua{require("KKsymbols")}%%%
%%%


%%% tsumesuji
\ExplSyntaxOn
\str_new:N \l_kks_tmp_str
\DeclareRobustCommand{\kks@ShrinkedNumber@internal}[1]{
  \str_set:Nx \l_kks_tmp_str { \text_expand:n { #1 } }
  \regex_match:nVTF { \A \d+ \Z } \l_kks_tmp_str
    % 先頭・末尾が数字かつ1桁以上
    {
      \directlua{KKsymbols.narrow_ones("\luaescapestring{\l_kks_tmp_str}")}
    }
    {
      #1
    }
}


\msg_new:nnn { KKsymbols } { invalid-tsumesuji }
  { 
    The~input~of~the~`tsumesuji`~option~should~be~0~or~1. 
  }
\int_compare:nNnTF {\number\kksymbols@tsumesuji} = { 1 } 
  {
    \tl_set_eq:NN {\kks@ShrinkedNumber} {\kks@ShrinkedNumber@internal} 
  }
  {
    \int_compare:nNnTF {\number\kksymbols@tsumesuji} = {0}
      {
        \tl_set_eq:NN {\kks@ShrinkedNumber} {\relax} 
      }
      {
        \msg_error:nnn { KKsymbols } { invalid-tsumesuji } { #1 }
      }
  }
\ExplSyntaxOff
%%%


%%% interface commands
\DeclareRobustCommand{\maru}{%
  \@ifstar{\maru@new@no}{\maru@new}%
}

\DeclareRobustCommand{\kuromaru}{%
  \@ifstar{\kuromaru@new@no}{\kuromaru@new}%
}

\DeclareRobustCommand{\nmaru}{%
  \@ifstar{\nmaru@new@no}{\nmaru@new}%
}

\DeclareRobustCommand{\jegg}{%
  \@ifstar{\jegg@new@black}{\jegg@new}%
}

\DeclareRobustCommand{\seihou}{%
  \@ifstar{\seihou@new@no}{\seihou@new}%
}

\DeclareRobustCommand{\kuroseihou}{%
  \@ifstar{\kuroseihou@new@no}{\kuroseihou@new}%
}

\DeclareRobustCommand{\seimaru}{%
  \@ifstar{\seimaru@new@no}{\seimaru@new}%
}

\DeclareRobustCommand{\kuroseimaru}{%
  \@ifstar{\kuroseimaru@new@no}{\kuroseimaru@new}%
}

\DeclareRobustCommand{\hishi}{%
  \@ifstar{\hishi@new@no}{\hishi@new}%
}

\DeclareRobustCommand{\kurohishi}{%
  \@ifstar{\kurohishi@new@no}{\kurohishi@new}%
}

\DeclareRobustCommand{\maruhishi}{%
  \@ifstar{\kurohishi@new@no}{\kurohishi@new}%
}

\DeclareRobustCommand{\kuromaruhishi}{%
  \@ifstar{\kuromaruhishi@new@no}{\kuromaruhishi@new}%
}

\DeclareRobustCommand{\ichimoji}{%
  \@ifstar{\ichimoji@new@no}{\ichimoji@new}%
}

\DeclareRobustCommand{\kakko@y@internal}[1]{\kakko@byouga@internal{（}{）}{#1}}
\DeclareRobustCommand{\kakko@y@internal@no}[1]{\kakko@byouga@internal@no{（}{）}{#1}}
\DeclareRobustCommand{\kakko@t@internal}[1]{\kakko@byouga@internal@tate{（}{）}{#1}}
\DeclareRobustCommand{\kakko@t@internal@no}[1]{\kakko@byouga@internal@tate@no{（}{）}{#1}}
\DeclareRobustCommand{\kakko}{%
  \@ifstar{\kakko@star}{\kakko@nostar}% 
}
\newcommand{\kakko@star}[1]{%
  \ifnum\ltjgetparameter{direction}=3\relax
    \kakko@t@internal@no{#1}%
  \else
    \kakko@y@internal@no{#1}%
  \fi
}
\newcommand{\kakko@nostar}[1]{%
  \ifnum\ltjgetparameter{direction}=3\relax
    \kakko@t@internal{#1}%
  \else
    \kakko@y@internal{#1}%
  \fi
}

\DeclareRobustCommand{\sumikakko@y@internal}[1]{\kakko@byouga@internal{【}{】}{#1}}
\DeclareRobustCommand{\sumikakko@y@internal@no}[1]{\kakko@byouga@internal@no{【}{】}{#1}}
\DeclareRobustCommand{\sumikakko@t@internal}[1]{\kakko@byouga@internal@tate{【}{】}{#1}}
\DeclareRobustCommand{\sumikakko@t@internal@no}[1]{\kakko@byouga@internal@tate@no{【}{】}{#1}}
\DeclareRobustCommand{\sumikakko}{%
  \@ifstar{\sumikakko@star}{\sumikakko@nostar}% 
}
\newcommand{\sumikakko@star}[1]{%
  \ifnum\ltjgetparameter{direction}=3\relax
    \sumikakko@t@internal@no{#1}%
  \else
    \sumikakko@y@internal@no{#1}%
  \fi
}
\newcommand{\sumikakko@nostar}[1]{%
  \ifnum\ltjgetparameter{direction}=3\relax
    \sumikakko@t@internal{#1}%
  \else
    \sumikakko@y@internal{#1}%
  \fi
}

\DeclareRobustCommand{\kakukakko@y@internal}[1]{\kakko@byouga@internal{［}{］}{#1}}
\DeclareRobustCommand{\kakukakko@y@internal@no}[1]{\kakko@byouga@internal@no{［}{］}{#1}}
\DeclareRobustCommand{\kakukakko@t@internal}[1]{\kakko@byouga@internal@tate{［}{］}{#1}}
\DeclareRobustCommand{\kakukakko@t@internal@no}[1]{\kakko@byouga@internal@tate@no{［}{］}{#1}}
\DeclareRobustCommand{\kakukakko}{%
  \@ifstar{\kakukakko@star}{\kakukakko@nostar}% 
}
\newcommand{\kakukakko@star}[1]{%
  \ifnum\ltjgetparameter{direction}=3\relax
    \kakukakko@t@internal@no{#1}%
  \else
    \kakukakko@y@internal@no{#1}%
  \fi
}
\newcommand{\kakukakko@nostar}[1]{%
  \ifnum\ltjgetparameter{direction}=3\relax
    \kakukakko@t@internal{#1}%
  \else
    \kakukakko@y@internal{#1}%
  \fi
}

\DeclareRobustCommand{\kikakko@y@internal}[1]{\kakko@byouga@internal{〔}{〕}{#1}}
\DeclareRobustCommand{\kikakko@y@internal@no}[1]{\kakko@byouga@internal@no{〔}{〕}{#1}}
\DeclareRobustCommand{\kikakko@t@internal}[1]{\kakko@byouga@internal@tate{〔}{〕}{#1}}
\DeclareRobustCommand{\kikakko@t@internal@no}[1]{\kakko@byouga@internal@tate@no{〔}{〕}{#1}}
\DeclareRobustCommand{\kikakko}{%
  \@ifstar{\kikakko@star}{\kikakko@nostar}% 
}
\newcommand{\kikakko@star}[1]{%
  \ifnum\ltjgetparameter{direction}=3\relax
    \kikakko@t@internal@no{#1}%
  \else
    \kikakko@y@internal@no{#1}%
  \fi
}
\newcommand{\kikakko@nostar}[1]{%
  \ifnum\ltjgetparameter{direction}=3\relax
    \kikakko@t@internal{#1}%
  \else
    \kikakko@y@internal{#1}%
  \fi
}

\DeclareRobustCommand{\ykakko@y@internal}[1]{\kakko@byouga@internal{〈}{〉}{#1}}
\DeclareRobustCommand{\ykakko@y@internal@no}[1]{\kakko@byouga@internal@no{〈}{〉}{#1}}
\DeclareRobustCommand{\ykakko@t@internal}[1]{\kakko@byouga@internal@tate{〈}{〉}{#1}}
\DeclareRobustCommand{\ykakko@t@internal@no}[1]{\kakko@byouga@internal@tate@no{〈}{〉}{#1}}
\DeclareRobustCommand{\ykakko}{%
  \@ifstar{\ykakko@star}{\ykakko@nostar}% 
}
\newcommand{\ykakko@star}[1]{%
  \ifnum\ltjgetparameter{direction}=3\relax
    \ykakko@t@internal@no{#1}%
  \else
    \ykakko@y@internal@no{#1}%
  \fi
}
\newcommand{\ykakko@nostar}[1]{%
  \ifnum\ltjgetparameter{direction}=3\relax
    \ykakko@t@internal{#1}%
  \else
    \ykakko@y@internal{#1}%
  \fi
}

\DeclareRobustCommand{\nykakko@y@internal}[1]{\kakko@byouga@internal{《}{》}{#1}}
\DeclareRobustCommand{\nykakko@y@internal@no}[1]{\kakko@byouga@internal@no{《}{》}{#1}}
\DeclareRobustCommand{\nykakko@t@internal}[1]{\kakko@byouga@internal@tate{《}{》}{#1}}
\DeclareRobustCommand{\nykakko@t@internal@no}[1]{\kakko@byouga@internal@tate@no{《}{》}{#1}}
\DeclareRobustCommand{\nykakko}{%
  \@ifstar{\nykakko@star}{\nykakko@nostar}% 
}
\newcommand{\nykakko@star}[1]{%
  \ifnum\ltjgetparameter{direction}=3\relax
    \nykakko@t@internal@no{#1}%
  \else
    \nykakko@y@internal@no{#1}%
  \fi
}
\newcommand{\nykakko@nostar}[1]{%
  \ifnum\ltjgetparameter{direction}=3\relax
    \nykakko@t@internal{#1}%
  \else
    \nykakko@y@internal{#1}%
  \fi
}

\DeclareRobustCommand{\namikakko@y@internal}[1]{\kakko@byouga@internal{｛}{｝}{#1}}
\DeclareRobustCommand{\namikakko@y@internal@no}[1]{\kakko@byouga@internal@no{｛}{｝}{#1}}
\DeclareRobustCommand{\namikakko@t@internal}[1]{\kakko@byouga@internal@tate{｛}{｝}{#1}}
\DeclareRobustCommand{\namikakko@t@internal@no}[1]{\kakko@byouga@internal@tate@no{｛}{｝}{#1}}
\DeclareRobustCommand{\namikakko}{%
  \@ifstar{\namikakko@star}{\namikakko@nostar}% 
}
\newcommand{\namikakko@star}[1]{%
  \ifnum\ltjgetparameter{direction}=3\relax
    \namikakko@t@internal@no{#1}%
  \else
    \namikakko@y@internal@no{#1}%
  \fi
}
\newcommand{\namikakko@nostar}[1]{%
  \ifnum\ltjgetparameter{direction}=3\relax
    \namikakko@t@internal{#1}%
  \else
    \namikakko@y@internal{#1}%
  \fi
}

\DeclareRobustCommand{\kagikakko@y@internal}[1]{\kakko@byouga@internal{「}{」}{#1}}
\DeclareRobustCommand{\kagikakko@y@internal@no}[1]{\kakko@byouga@internal@no{「}{」}{#1}}
\DeclareRobustCommand{\kagikakko@t@internal}[1]{\kakko@byouga@internal@tate{「}{」}{#1}}
\DeclareRobustCommand{\kagikakko@t@internal@no}[1]{\kakko@byouga@internal@tate@no{「}{」}{#1}}
\DeclareRobustCommand{\kagikakko}{%
  \@ifstar{\kagikakko@star}{\kagikakko@nostar}% 
}
\newcommand{\kagikakko@star}[1]{%
  \ifnum\ltjgetparameter{direction}=3\relax
    \kagikakko@t@internal@no{#1}%
  \else
    \kagikakko@y@internal@no{#1}%
  \fi
}
\newcommand{\kagikakko@nostar}[1]{%
  \ifnum\ltjgetparameter{direction}=3\relax
    \kagikakko@t@internal{#1}%
  \else
    \kagikakko@y@internal{#1}%
  \fi
}

\DeclareRobustCommand{\nkagikakko@y@internal}[1]{\kakko@byouga@internal{『}{』}{#1}}
\DeclareRobustCommand{\nkagikakko@y@internal@no}[1]{\kakko@byouga@internal@no{『}{』}{#1}}
\DeclareRobustCommand{\nkagikakko@t@internal}[1]{\kakko@byouga@internal@tate{『}{』}{#1}}
\DeclareRobustCommand{\nkagikakko@t@internal@no}[1]{\kakko@byouga@internal@tate@no{『}{』}{#1}}
\DeclareRobustCommand{\nkagikakko}{%
  \@ifstar{\nkagikakko@star}{\nkagikakko@nostar}% 
}
\newcommand{\nkagikakko@star}[1]{%
  \ifnum\ltjgetparameter{direction}=3\relax
    \nkagikakko@t@internal@no{#1}%
  \else
    \nkagikakko@y@internal@no{#1}%
  \fi
}
\newcommand{\nkagikakko@nostar}[1]{%
  \ifnum\ltjgetparameter{direction}=3\relax
    \nkagikakko@t@internal{#1}%
  \else
    \nkagikakko@y@internal{#1}%
  \fi
}
%%%


% 全体で使用
\NewDocumentCommand{\shukushou@adj@new}{ m m m }{%
  \ifdim #1 < #2%
    \resizebox*{\width}{#2}{#3}%
  \else%
    \resizebox*{#2}{#2}{#3}%
  \fi%
}
\NewDocumentCommand{\shukushou@adj@new@no}{ m m m }{%
  \ifdim #1 < #2%
    #3%
  \else%
    \resizebox*{!}{#2}{#3}%
  \fi%
}
\NewDocumentCommand{\RotYoko}{O{0}}{%
  \def\KKsymbolsRot@val@y{#1}%
}
\NewDocumentCommand{\RotTate}{O{90}}{%
  \def\KKsymbolsRot@val@t{#1}%
}
\def\KKsymbolsRot@val@t{90}
\def\KKsymbolsRot@val@y{0}
\NewDocumentCommand{\rot@or@not@kksym}{}{%
  \ifnum\ltjgetparameter{direction}=3
    \def\rot@kksym@tateyoko{\KKsymbolsRot@val@t}%
  \else
    \def\rot@kksym@tateyoko{\KKsymbolsRot@val@y}%
  \fi
}
%%%


% \maru
\NewDocumentCommand{\vertical@adj@maru@new}{}{%
  \ifnum\ltjgetparameter{direction}=3
    -.5\zw%
  \else
    -.12\zw%
  \fi
}
\newlength{\maru@boxwidth@new}
\newlength{\maru@boxwidth@inner}
\newlength{\maru@var@yokohaba}
\newlength{\maru@var@yokohaba@cal}
\newlength{\maru@var@tate}
\newlength{\maru@var@fuka}
\newlength{\maru@var@zenkou}

\ExplSyntaxOn
\newcommand{\kks@chech@maru@onedigit}[1]{
  \str_set:Nx \l_tmpa_str { \text_expand:n { #1 } }
  \str_if_eq:VnTF \l_tmpa_str { 0 } { \kksdigit@maru@newtrue } {
  \str_if_eq:VnTF \l_tmpa_str { 1 } { \kksdigit@maru@newtrue } {
  \str_if_eq:VnTF \l_tmpa_str { 2 } { \kksdigit@maru@newtrue } {
  \str_if_eq:VnTF \l_tmpa_str { 3 } { \kksdigit@maru@newtrue } {
  \str_if_eq:VnTF \l_tmpa_str { 4 } { \kksdigit@maru@newtrue } {
  \str_if_eq:VnTF \l_tmpa_str { 5 } { \kksdigit@maru@newtrue } {
  \str_if_eq:VnTF \l_tmpa_str { 6 } { \kksdigit@maru@newtrue } {
  \str_if_eq:VnTF \l_tmpa_str { 7 } { \kksdigit@maru@newtrue } {
  \str_if_eq:VnTF \l_tmpa_str { 8 } { \kksdigit@maru@newtrue } {
  \str_if_eq:VnTF \l_tmpa_str { 9 } { \kksdigit@maru@newtrue } {
    \kksdigit@maru@newfalse
  }}}}}}}}}}
}
\ExplSyntaxOff

\NewDocumentCommand{\shukushou@adj@new@maru@onedigit}{ m m m }{%
  \resizebox*{!}{#2}{#3}%
}

\NewDocumentCommand{\shukushou@adj@new@no@maru}{ m m m m }{%
  \ifdim #1 < #2%
    \ifdim #3 > #2%
      \resizebox*{#3}{!}{#4}%
    \else%
      \scalebox{.9}{#4}%
    \fi%
  \else%
    \resizebox*{!}{#2}{#4}%
  \fi%
}

\newif\ifkksdigit@maru@new

\DeclareRobustCommand{\maru@new}[1]{%
  \kks@chech@maru@onedigit{#1}%
  \rot@or@not@kksym%
  \setlength{\maru@boxwidth@new}{\zw}%
  \settowidth{\maru@var@yokohaba}{#1}%
  \pgfmathsetlength{\maru@boxwidth@inner}{0.87 * \maru@boxwidth@new / sqrt(2)}%
  \leavevmode%
  \ltjghostbeforejachar%
  \hbox to \maru@boxwidth@new{%
  \raisebox{\vertical@adj@maru@new}{%
  \vbox to \maru@boxwidth@new{%
  \vss%
  \hbox to \maru@boxwidth@new{%
    \hss%
    \tikz[baseline=(char.base)]{%
      \node[
        shape=circle,
        line width=.04\maru@boxwidth@new,  
        minimum size=.9\maru@boxwidth@new, 
        draw,
        inner sep=.02\maru@boxwidth@new,
        rotate=\rot@kksym@tateyoko
      ] (char){%
      \vbox to \maru@boxwidth@inner{
        \vss%
        \hbox to \maru@boxwidth@inner{%
        \hss%
          \ifkksdigit@maru@new%
            \shukushou@adj@new@maru@onedigit{\maru@var@yokohaba}{\maru@boxwidth@inner}{\kks@ShrinkedNumber{#1}}%
          \else%
            \shukushou@adj@new{\maru@var@yokohaba}{\maru@boxwidth@inner}{\kks@ShrinkedNumber{#1}}%
          \fi%
        \hss%
        }%
        \vss%
      }%
      };
    }%
    \hss%
  }%
  \vss%
  }%
  }%
  }%
  \ltjghostafterjachar%
}
\DeclareRobustCommand{\maru@new@no}[1]{%
  \rot@or@not@kksym%
  \setlength{\maru@boxwidth@new}{\zw}%
  \settowidth{\maru@var@yokohaba}{#1}%
  \settoheight{\maru@var@tate}{#1}%
  \settodepth{\maru@var@fuka}{#1}%
  \pgfmathsetlength{\maru@var@zenkou}{\maru@var@tate + \maru@var@fuka}%
  \pgfmathsetlength{\maru@var@yokohaba@cal}{0.85 * \maru@var@yokohaba}%
  \pgfmathsetlength{\maru@boxwidth@inner}{0.87 * \maru@boxwidth@new / sqrt(2)}%
  \leavevmode%
  \ltjghostbeforejachar%
  \hbox to \maru@boxwidth@new{%
  \raisebox{\vertical@adj@maru@new}{%
  \vbox to \maru@boxwidth@new{%
  \vss%
  \hbox to \maru@boxwidth@new{%
    \hss%
    \tikz[baseline=(char.base)]{%
      \node[
        shape=circle,
        line width=.04\maru@boxwidth@new,  
        minimum size=.9\maru@boxwidth@new, 
        draw,
        inner sep=.02\maru@boxwidth@new,
        rotate=\rot@kksym@tateyoko
      ] (char){%
      \vbox to \maru@boxwidth@inner{
        \vss%
        \hbox to \maru@boxwidth@inner{%
        \hss%
          \shukushou@adj@new@no@maru{\maru@var@zenkou}{\maru@boxwidth@inner}{\maru@var@yokohaba@cal}{\kks@ShrinkedNumber{#1}}%
        \hss%
        }%
        \vss%
      }%
      };
    }%
    \hss%
  }%
  \vss%
  }%
  }%
  }%
  \ltjghostafterjachar%
}


\DeclareRobustCommand{\kuromaru@new}[1]{%
  \kks@chech@maru@onedigit{#1}%
  \rot@or@not@kksym%
  \setlength{\maru@boxwidth@new}{\zw}%
  \settowidth{\maru@var@yokohaba}{#1}%
  \pgfmathsetlength{\maru@boxwidth@inner}{0.87 * \maru@boxwidth@new / sqrt(2)}%
  \leavevmode%
  \ltjghostbeforejachar%
  \hbox to \maru@boxwidth@new{%
  \raisebox{\vertical@adj@maru@new}{%
  \vbox to \maru@boxwidth@new{%
  \vss%
  \hbox to \maru@boxwidth@new{%
    \hss%
    \tikz[baseline=(char.base)]{%
      \node[
        shape=circle,
        fill=black,%%%
        line width=.04\maru@boxwidth@new,  
        minimum size=.9\maru@boxwidth@new, 
        draw,
        inner sep=.02\maru@boxwidth@new,
        rotate=\rot@kksym@tateyoko
      ] (char){%
      \vbox to \maru@boxwidth@inner{
        \vss%
        \hbox to \maru@boxwidth@inner{%
        \hss%
          \ifkksdigit@maru@new%
            \shukushou@adj@new@maru@onedigit{\maru@var@yokohaba}{\maru@boxwidth@inner}{\textcolor{white}{\kks@ShrinkedNumber{#1}}}%
          \else%
            \shukushou@adj@new{\maru@var@yokohaba}{\maru@boxwidth@inner}{\textcolor{white}{\kks@ShrinkedNumber{#1}}}%
          \fi%
        \hss%
        }%
        \vss%
      }%
      };
    }%
    \hss%
  }%
  \vss%
  }%
  }%
  }%
  \ltjghostafterjachar%
}
\DeclareRobustCommand{\kuromaru@new@no}[1]{%
  \rot@or@not@kksym%
  \setlength{\maru@boxwidth@new}{\zw}%
  \settowidth{\maru@var@yokohaba}{#1}%
  \settoheight{\maru@var@tate}{#1}%
  \settodepth{\maru@var@fuka}{#1}%
  \pgfmathsetlength{\maru@var@zenkou}{\maru@var@tate + \maru@var@fuka}%
  \pgfmathsetlength{\maru@var@yokohaba@cal}{0.85 * \maru@var@yokohaba}%
  \pgfmathsetlength{\maru@boxwidth@inner}{0.87 * \maru@boxwidth@new / sqrt(2)}%
  \leavevmode%
  \ltjghostbeforejachar%
  \hbox to \maru@boxwidth@new{%
  \raisebox{\vertical@adj@maru@new}{%
  \vbox to \maru@boxwidth@new{%
  \vss%
  \hbox to \maru@boxwidth@new{%
    \hss%
    \tikz[baseline=(char.base)]{%
      \node[
        shape=circle,
        fill=black,%%%
        line width=.04\maru@boxwidth@new,  
        minimum size=.9\maru@boxwidth@new, 
        draw,
        inner sep=.02\maru@boxwidth@new,
        rotate=\rot@kksym@tateyoko
      ] (char){%
      \vbox to \maru@boxwidth@inner{
        \vss%
        \hbox to \maru@boxwidth@inner{%
        \hss%
          \shukushou@adj@new@no@maru{\maru@var@zenkou}{\maru@boxwidth@inner}{\maru@var@yokohaba@cal}{%
            \textcolor{white}{\kks@ShrinkedNumber{#1}}}%
        \hss%
        }%
        \vss%
      }%
      };
    }%
    \hss%
  }%
  \vss%
  }%
  }%
  }%
  \ltjghostafterjachar%
}


\DeclareRobustCommand{\nmaru@new}[1]{%
  \kks@chech@maru@onedigit{#1}%
  \rot@or@not@kksym%
  \setlength{\maru@boxwidth@new}{\zw}%
  \settowidth{\maru@var@yokohaba}{#1}%
  \pgfmathsetlength{\maru@boxwidth@inner}{0.85 * \maru@boxwidth@new / sqrt(2)}%
  \leavevmode%
  \ltjghostbeforejachar%
  \hbox to \maru@boxwidth@new{%
  \raisebox{\vertical@adj@maru@new}{%
  \vbox to \maru@boxwidth@new{%
  \vss%
  \hbox to \maru@boxwidth@new{%
    \hss%
    \tikz[baseline=(char.base)]{%
      \node[
        shape=circle,
        line width=.03\maru@boxwidth@new,  
        minimum size=.88\maru@boxwidth@new, 
        draw, double, double distance=.03\zw,%%%
        inner sep=.06\maru@boxwidth@new,
        rotate=\rot@kksym@tateyoko,
        scale=.87
      ] (char){%
      \vbox to \maru@boxwidth@inner{
        \vss%
        \hbox to \maru@boxwidth@inner{%
        \hss%
          \ifkksdigit@maru@new%
            \shukushou@adj@new@maru@onedigit{\maru@var@yokohaba}{\maru@boxwidth@inner}{\kks@ShrinkedNumber{#1}}%
          \else%
            \shukushou@adj@new{\maru@var@yokohaba}{\maru@boxwidth@inner}{\kks@ShrinkedNumber{#1}}%
          \fi%
        \hss%
        }%
        \vss%
      }%
      };
    }%
    \hss%
  }%
  \vss%
  }%
  }%
  }%
  \ltjghostafterjachar%
}
\DeclareRobustCommand{\nmaru@new@no}[1]{%
  \rot@or@not@kksym%
  \setlength{\maru@boxwidth@new}{\zw}%
  \settowidth{\maru@var@yokohaba}{#1}%
  \settoheight{\maru@var@tate}{#1}%
  \settodepth{\maru@var@fuka}{#1}%
  \pgfmathsetlength{\maru@var@zenkou}{\maru@var@tate + \maru@var@fuka}%
  \pgfmathsetlength{\maru@var@yokohaba@cal}{0.85 * \maru@var@yokohaba}%
  \pgfmathsetlength{\maru@boxwidth@inner}{0.82 * \maru@boxwidth@new / sqrt(2)}%
  \leavevmode%
  \ltjghostbeforejachar%
  \hbox to \maru@boxwidth@new{%
  \raisebox{\vertical@adj@maru@new}{%
  \vbox to \maru@boxwidth@new{%
  \vss%
  \hbox to \maru@boxwidth@new{%
    \hss%
    \tikz[baseline=(char.base)]{%
      \node[
        shape=circle,
        line width=.03\maru@boxwidth@new,  
        minimum size=.88\maru@boxwidth@new, 
        draw, double, double distance=.03\zw,%%%
        inner sep=.06\maru@boxwidth@new,
        rotate=\rot@kksym@tateyoko,
        scale=.9
      ] (char){%
      \vbox to \maru@boxwidth@inner{%
        \vss%
        \hbox to \maru@boxwidth@inner{%
        \hss%
          \shukushou@adj@new@no@maru{\maru@var@zenkou}{\maru@boxwidth@inner}{\maru@var@yokohaba@cal}{\kks@ShrinkedNumber{#1}}%
        \hss%
        }%
        \vss%
      }%
      };
    }%
    \hss%
  }%
  \vss%
  }%
  }%
  }%
  \ltjghostafterjachar%
}


\newlength{\jegg@boxwidth@inner@cal}%%%
\DeclareRobustCommand{\jegg@new}[1]{%
  \kks@chech@maru@onedigit{#1}%
  \rot@or@not@kksym%
  \setlength{\maru@boxwidth@new}{\zw}%
  \settowidth{\maru@var@yokohaba}{#1}%
  \pgfmathsetlength{\maru@boxwidth@inner}{0.87 * \maru@boxwidth@new / sqrt(2)}%
  \pgfmathsetlength{\jegg@boxwidth@inner@cal}{0.77 * \maru@boxwidth@inner}%%%
  \leavevmode%
  \ltjghostbeforejachar%
  \hbox to \maru@boxwidth@new{%
  \raisebox{\vertical@adj@maru@new}{%
  \vbox to \maru@boxwidth@new{%
  \vss%
  \hbox to \maru@boxwidth@new{%
    \hss%
    \tikz[baseline=(char.base)]{%
      \node[
        shape=ellipse,
        line width=.04\maru@boxwidth@new,  
        minimum height=.9\maru@boxwidth@new, 
        minimum width=.7\maru@boxwidth@new, 
        draw,
        inner sep=0\maru@boxwidth@new,
        rotate=\rot@kksym@tateyoko
      ] (char){%
      \vbox to \maru@boxwidth@inner{
        \vss%
        \hbox to \jegg@boxwidth@inner@cal{%
        \hss%
          \ifkksdigit@maru@new%
            \shukushou@adj@new@maru@onedigit{\maru@var@yokohaba}{\jegg@boxwidth@inner@cal}{\kks@ShrinkedNumber{#1}}%
          \else%
            \shukushou@adj@new{\maru@var@yokohaba}{\jegg@boxwidth@inner@cal}{\kks@ShrinkedNumber{#1}}%
          \fi%
        \hss%
        }%
        \vss%
      }%
      };
    }%
    \hss%
  }%
  \vss%
  }%
  }%
  }%
  \ltjghostafterjachar%
}
\DeclareRobustCommand{\jegg@new@black}[1]{%
  \rot@or@not@kksym%
  \setlength{\maru@boxwidth@new}{\zw}%
  \settowidth{\maru@var@yokohaba}{#1}%
  \pgfmathsetlength{\maru@boxwidth@inner}{0.87 * \maru@boxwidth@new / sqrt(2)}%
  \pgfmathsetlength{\jegg@boxwidth@inner@cal}{0.77 * \maru@boxwidth@inner}%%%
  \leavevmode%
  \ltjghostbeforejachar%
  \hbox to \maru@boxwidth@new{%
  \raisebox{\vertical@adj@maru@new}{%
  \vbox to \maru@boxwidth@new{%
  \vss%
  \hbox to \maru@boxwidth@new{%
    \hss%
    \tikz[baseline=(char.base)]{%
      \node[
        shape=ellipse,
        line width=.04\maru@boxwidth@new,  
        minimum height=.9\maru@boxwidth@new, 
        minimum width=.7\maru@boxwidth@new, 
        draw,
        fill=black!70,
        inner sep=0\maru@boxwidth@new,
        rotate=\rot@kksym@tateyoko
      ] (char){%
      \vbox to \maru@boxwidth@inner{
        \vss%
        \hbox to \jegg@boxwidth@inner@cal{%
        \hss%
          \ifkksdigit@maru@new%
            \shukushou@adj@new@maru@onedigit{\maru@var@yokohaba}{\jegg@boxwidth@inner@cal}{\kks@ShrinkedNumber{#1}}%
          \else%
            \shukushou@adj@new{\maru@var@yokohaba}{\jegg@boxwidth@inner@cal}{\kks@ShrinkedNumber{#1}}%
          \fi%
        \hss%
        }%
        \vss%
      }%
      };
    }%
    \hss%
  }%
  \vss%
  }%
  }%
  }%
  \ltjghostafterjachar%
}
%%%


% \seihou
\NewDocumentCommand{\vertical@adj@seihou@new}{}{%
  \ifnum\ltjgetparameter{direction}=3
    -.5\zw%
  \else
    -.12\zw%
  \fi
}
\newlength{\seihou@boxwidth@new}
\newlength{\seihou@boxwidth@inner}
\newlength{\seihou@var@yokohaba@cal}
\newlength{\seihou@var@yokohaba}
\newlength{\seihou@var@tate}
\newlength{\seihou@var@fuka}
\newlength{\seihou@var@zenkou}

\NewDocumentCommand{\shukushou@adj@new@no@seihou}{ m m m m }{%
  \ifdim #1 < #2%
    \ifdim #3 > #2%
      \resizebox*{#3}{!}{#4}%
    \else%
      \scalebox{.9}{#4}%
    \fi%
  \else%
    \resizebox*{!}{#2}{#4}%
  \fi%
}

\DeclareRobustCommand{\seihou@new}[1]{%
  \kks@chech@maru@onedigit{#1}%
  \rot@or@not@kksym%
  \setlength{\seihou@boxwidth@new}{\zw}%
  \settowidth{\seihou@var@yokohaba}{#1}%
  \pgfmathsetlength{\seihou@boxwidth@inner}{0.68 * \seihou@boxwidth@new}%
  \leavevmode%
  \ltjghostbeforejachar%
  \hbox to \seihou@boxwidth@new{%
  \raisebox{\vertical@adj@maru@new}{%
  \vbox to \seihou@boxwidth@new{%
  \vss%
  \hbox to \seihou@boxwidth@new{%
    \hss%
    \tikz[baseline=(char.base)]{%
      \node[
        line width=.04\seihou@boxwidth@new,  
        minimum size=.85\seihou@boxwidth@new, 
        draw,
        inner sep=.1\seihou@boxwidth@new,
        rotate=\rot@kksym@tateyoko
      ] (char){%
      \vbox to \seihou@boxwidth@inner{
        \vss%
        \hbox to \seihou@boxwidth@inner{%
        \hss%
          \ifkksdigit@maru@new%
            \shukushou@adj@new@maru@onedigit{\seihou@var@yokohaba}{\seihou@boxwidth@inner}{\kks@ShrinkedNumber{#1}}%
          \else%
            \shukushou@adj@new{\seihou@var@yokohaba}{\seihou@boxwidth@inner}{\kks@ShrinkedNumber{#1}}%
          \fi%
        \hss%
        }%
        \vss%
      }%
      };
    }%
    \hss%
  }%
  \vss%
  }%
  }%
  }%
  \ltjghostafterjachar%
}
\DeclareRobustCommand{\seihou@new@no}[1]{%
  \rot@or@not@kksym%
  \setlength{\seihou@boxwidth@new}{\zw}%
  \settowidth{\seihou@var@yokohaba}{#1}%
  \settoheight{\seihou@var@tate}{#1}%
  \settodepth{\seihou@var@fuka}{#1}%
  \pgfmathsetlength{\seihou@var@zenkou}{\seihou@var@tate + \seihou@var@fuka}%
  \pgfmathsetlength{\seihou@var@yokohaba@cal}{0.85 * \seihou@var@yokohaba}%
  \pgfmathsetlength{\seihou@boxwidth@inner}{0.68 * \seihou@boxwidth@new}%
  \leavevmode%
  \ltjghostbeforejachar%
  \hbox to \seihou@boxwidth@new{%
  \raisebox{\vertical@adj@maru@new}{%
  \vbox to \seihou@boxwidth@new{%
  \vss%
  \hbox to \seihou@boxwidth@new{%
    \hss%
    \tikz[baseline=(char.base)]{%
      \node[
        line width=.04\seihou@boxwidth@new,  
        minimum size=.85\seihou@boxwidth@new, 
        draw,
        inner sep=.1\seihou@boxwidth@new,
        rotate=\rot@kksym@tateyoko
      ] (char){%
      \vbox to \seihou@boxwidth@inner{
        \vss%
        \hbox to \seihou@boxwidth@inner{%
        \hss%
          \shukushou@adj@new@no@seihou{\seihou@var@zenkou}{\seihou@boxwidth@inner}{\seihou@var@yokohaba@cal}{\kks@ShrinkedNumber{#1}}%
        \hss%
        }%
        \vss%
      }%
      };
    }%
    \hss%
  }%
  \vss%
  }%
  }%
  }%
  \ltjghostafterjachar%
}


\DeclareRobustCommand{\kuroseihou@new}[1]{%
  \kks@chech@maru@onedigit{#1}%
  \rot@or@not@kksym%
  \setlength{\seihou@boxwidth@new}{\zw}%
  \settowidth{\seihou@var@yokohaba}{#1}%
  \pgfmathsetlength{\seihou@boxwidth@inner}{0.68 * \seihou@boxwidth@new}%
  \leavevmode%
  \ltjghostbeforejachar%
  \hbox to \seihou@boxwidth@new{%
  \raisebox{\vertical@adj@maru@new}{%
  \vbox to \seihou@boxwidth@new{%
  \vss%
  \hbox to \seihou@boxwidth@new{%
    \hss%
    \tikz[baseline=(char.base)]{%
      \node[
        line width=.04\seihou@boxwidth@new,  
        minimum size=.85\seihou@boxwidth@new, 
        draw,
        fill=black,%%%
        inner sep=.1\seihou@boxwidth@new,
        rotate=\rot@kksym@tateyoko
      ] (char){%
      \vbox to \seihou@boxwidth@inner{
        \vss%
        \hbox to \seihou@boxwidth@inner{%
        \hss%
          \ifkksdigit@maru@new%
            \shukushou@adj@new@maru@onedigit{\seihou@var@yokohaba}{\seihou@boxwidth@inner}{\textcolor{white}{\kks@ShrinkedNumber{#1}}}%
          \else%
            \shukushou@adj@new{\seihou@var@yokohaba}{\seihou@boxwidth@inner}{\textcolor{white}{\kks@ShrinkedNumber{#1}}}%
          \fi%
        \hss%
        }%
        \vss%
      }%
      };
    }%
    \hss%
  }%
  \vss%
  }%
  }%
  }%
  \ltjghostafterjachar%
}
\DeclareRobustCommand{\kuroseihou@new@no}[1]{%
  \rot@or@not@kksym%
  \setlength{\seihou@boxwidth@new}{\zw}%
  \settowidth{\seihou@var@yokohaba}{#1}%
  \settoheight{\seihou@var@tate}{#1}%
  \settodepth{\seihou@var@fuka}{#1}%
  \pgfmathsetlength{\seihou@var@zenkou}{\seihou@var@tate + \seihou@var@fuka}%
  \pgfmathsetlength{\seihou@var@yokohaba@cal}{0.85 * \seihou@var@yokohaba}%
  \pgfmathsetlength{\seihou@boxwidth@inner}{0.68 * \seihou@boxwidth@new}%
  \leavevmode%
  \ltjghostbeforejachar%
  \hbox to \seihou@boxwidth@new{%
  \raisebox{\vertical@adj@maru@new}{%
  \vbox to \seihou@boxwidth@new{%
  \vss%
  \hbox to \seihou@boxwidth@new{%
    \hss%
    \tikz[baseline=(char.base)]{%
      \node[
        line width=.04\seihou@boxwidth@new,  
        minimum size=.85\seihou@boxwidth@new, 
        draw,
        fill=black,%%%
        inner sep=.1\seihou@boxwidth@new,
        rotate=\rot@kksym@tateyoko
      ] (char){%
      \vbox to \seihou@boxwidth@inner{
        \vss%
        \hbox to \seihou@boxwidth@inner{%
        \hss%
          \shukushou@adj@new@no@seihou{\seihou@var@zenkou}{\seihou@boxwidth@inner}{\seihou@var@yokohaba@cal}{%
            \textcolor{white}{\kks@ShrinkedNumber{#1}}}%
        \hss%
        }%
        \vss%
      }%
      };
    }%
    \hss%
  }%
  \vss%
  }%
  }%
  }%
  \ltjghostafterjachar%
}


\DeclareRobustCommand{\seimaru@new}[1]{%
  \kks@chech@maru@onedigit{#1}%
  \rot@or@not@kksym%
  \setlength{\seihou@boxwidth@new}{\zw}%
  \settowidth{\seihou@var@yokohaba}{#1}%
  \pgfmathsetlength{\seihou@boxwidth@inner}{0.68 * \seihou@boxwidth@new}%
  \leavevmode%
  \ltjghostbeforejachar%
  \hbox to \seihou@boxwidth@new{%
  \raisebox{\vertical@adj@maru@new}{%
  \vbox to \seihou@boxwidth@new{%
  \vss%
  \hbox to \seihou@boxwidth@new{%
    \hss%
    \tikz[baseline=(char.base)]{%
      \node[
        line width=.04\seihou@boxwidth@new,  
        minimum size=.85\seihou@boxwidth@new, 
        draw,
        rounded corners=.13\zw,%%%
        inner sep=.1\seihou@boxwidth@new,
        rotate=\rot@kksym@tateyoko
      ] (char){%
      \vbox to \seihou@boxwidth@inner{
        \vss%
        \hbox to \seihou@boxwidth@inner{%
        \hss%
          \ifkksdigit@maru@new%
            \shukushou@adj@new@maru@onedigit{\seihou@var@yokohaba}{\seihou@boxwidth@inner}{\kks@ShrinkedNumber{#1}}%
          \else%
            \shukushou@adj@new{\seihou@var@yokohaba}{\seihou@boxwidth@inner}{\kks@ShrinkedNumber{#1}}%
          \fi%
        \hss%
        }%
        \vss%
      }%
      };
    }%
    \hss%
  }%
  \vss%
  }%
  }%
  }%
  \ltjghostafterjachar%
}
\DeclareRobustCommand{\seimaru@new@no}[1]{%
  \rot@or@not@kksym%
  \setlength{\seihou@boxwidth@new}{\zw}%
  \settowidth{\seihou@var@yokohaba}{#1}%
  \settoheight{\seihou@var@tate}{#1}%
  \settodepth{\seihou@var@fuka}{#1}%
  \pgfmathsetlength{\seihou@var@zenkou}{\seihou@var@tate + \seihou@var@fuka}%
  \pgfmathsetlength{\seihou@var@yokohaba@cal}{0.85 * \seihou@var@yokohaba}%
  \pgfmathsetlength{\seihou@boxwidth@inner}{0.68 * \seihou@boxwidth@new}%
  \leavevmode%
  \ltjghostbeforejachar%
  \hbox to \seihou@boxwidth@new{%
  \raisebox{\vertical@adj@maru@new}{%
  \vbox to \seihou@boxwidth@new{%
  \vss%
  \hbox to \seihou@boxwidth@new{%
    \hss%
    \tikz[baseline=(char.base)]{%
      \node[
        line width=.04\seihou@boxwidth@new,  
        minimum size=.85\seihou@boxwidth@new, 
        draw,
        rounded corners=.13\zw,%%%
        inner sep=.1\seihou@boxwidth@new,
        rotate=\rot@kksym@tateyoko
      ] (char){%
      \vbox to \seihou@boxwidth@inner{
        \vss%
        \hbox to \seihou@boxwidth@inner{%
        \hss%
          \shukushou@adj@new@no@seihou{\seihou@var@zenkou}{\seihou@boxwidth@inner}{\seihou@var@yokohaba@cal}{\kks@ShrinkedNumber{#1}}%
        \hss%
        }%
        \vss%
      }%
      };
    }%
    \hss%
  }%
  \vss%
  }%
  }%
  }%
  \ltjghostafterjachar%
}


\DeclareRobustCommand{\kuroseimaru@new}[1]{%
  \kks@chech@maru@onedigit{#1}%
  \rot@or@not@kksym%
  \setlength{\seihou@boxwidth@new}{\zw}%
  \settowidth{\seihou@var@yokohaba}{#1}%
  \pgfmathsetlength{\seihou@boxwidth@inner}{0.68 * \seihou@boxwidth@new}%
  \leavevmode%
  \ltjghostbeforejachar%
  \hbox to \seihou@boxwidth@new{%
  \raisebox{\vertical@adj@maru@new}{%
  \vbox to \seihou@boxwidth@new{%
  \vss%
  \hbox to \seihou@boxwidth@new{%
    \hss%
    \tikz[baseline=(char.base)]{%
      \node[
        line width=.04\seihou@boxwidth@new,  
        minimum size=.85\seihou@boxwidth@new, 
        draw,
        fill=black,%%%
        rounded corners=.13\zw,%%%
        inner sep=.1\seihou@boxwidth@new,
        rotate=\rot@kksym@tateyoko
      ] (char){%
      \vbox to \seihou@boxwidth@inner{
        \vss%
        \hbox to \seihou@boxwidth@inner{%
        \hss%
          \ifkksdigit@maru@new%
            \shukushou@adj@new@maru@onedigit{\seihou@var@yokohaba}{\seihou@boxwidth@inner}{\textcolor{white}{\kks@ShrinkedNumber{#1}}}%
          \else%
            \shukushou@adj@new{\seihou@var@yokohaba}{\seihou@boxwidth@inner}{\textcolor{white}{\kks@ShrinkedNumber{#1}}}%
          \fi%
        \hss%
        }%
        \vss%
      }%
      };
    }%
    \hss%
  }%
  \vss%
  }%
  }%
  }%
  \ltjghostafterjachar%
}
\DeclareRobustCommand{\kuroseimaru@new@no}[1]{%
  \rot@or@not@kksym%
  \setlength{\seihou@boxwidth@new}{\zw}%
  \settowidth{\seihou@var@yokohaba}{#1}%
  \settoheight{\seihou@var@tate}{#1}%
  \settodepth{\seihou@var@fuka}{#1}%
  \pgfmathsetlength{\seihou@var@zenkou}{\seihou@var@tate + \seihou@var@fuka}%
  \pgfmathsetlength{\seihou@var@yokohaba@cal}{0.85 * \seihou@var@yokohaba}%
  \pgfmathsetlength{\seihou@boxwidth@inner}{0.68 * \seihou@boxwidth@new}%
  \leavevmode%
  \ltjghostbeforejachar%
  \hbox to \seihou@boxwidth@new{%
  \raisebox{\vertical@adj@maru@new}{%
  \vbox to \seihou@boxwidth@new{%
  \vss%
  \hbox to \seihou@boxwidth@new{%
    \hss%
    \tikz[baseline=(char.base)]{%
      \node[
        line width=.04\seihou@boxwidth@new,  
        minimum size=.85\seihou@boxwidth@new, 
        draw,
        fill=black,%%%
        rounded corners=.13\zw,%%%
        inner sep=.1\seihou@boxwidth@new,
        rotate=\rot@kksym@tateyoko
      ] (char){%
      \vbox to \seihou@boxwidth@inner{
        \vss%
        \hbox to \seihou@boxwidth@inner{%
        \hss%
          \shukushou@adj@new@no@seihou{\seihou@var@zenkou}{\seihou@boxwidth@inner}{\seihou@var@yokohaba@cal}{%
            \textcolor{white}{\kks@ShrinkedNumber{#1}}}%
        \hss%
        }%
        \vss%
      }%
      };
    }%
    \hss%
  }%
  \vss%
  }%
  }%
  }%
  \ltjghostafterjachar%
}


\DeclareRobustCommand{\hishi@new}[1]{%
  \rot@or@not@kksym%
  \setlength{\seihou@boxwidth@new}{\zw}%
  \settowidth{\seihou@var@yokohaba}{#1}%
  \pgfmathsetlength{\seihou@boxwidth@inner}{0.85 * \seihou@boxwidth@new / 2}%
  \leavevmode%
  \ltjghostbeforejachar%
  \hbox to \seihou@boxwidth@new{%
  \raisebox{\vertical@adj@maru@new}{%
  \vbox to \seihou@boxwidth@new{%
  \vss%
  \hbox to \seihou@boxwidth@new{%
    \hss%
    \tikz[baseline=(char.base)]{%
      \node[
        line width=.04\seihou@boxwidth@new,  
        minimum size=.5\seihou@boxwidth@new, 
        draw,
        shape=diamond,
        inner sep=.03\seihou@boxwidth@new,
        rotate=\rot@kksym@tateyoko
      ] (char){%
      \vbox to \seihou@boxwidth@inner{
        \vss%
        \hbox to \seihou@boxwidth@inner{%
        \hss%
          \shukushou@adj@new{\seihou@var@yokohaba}{\seihou@boxwidth@inner}{\kks@ShrinkedNumber{#1}}%
        \hss%
        }%
        \vss%
      }%
      };
    }%
    \hss%
  }%
  \vss%
  }%
  }%
  }%
  \ltjghostafterjachar%
}
\DeclareRobustCommand{\hishi@new@no}[1]{%
  \rot@or@not@kksym%
  \setlength{\seihou@boxwidth@new}{\zw}%
  \settowidth{\seihou@var@yokohaba}{#1}%
  \settoheight{\seihou@var@tate}{#1}%
  \settodepth{\seihou@var@fuka}{#1}%
  \pgfmathsetlength{\seihou@var@zenkou}{(\seihou@var@tate + \seihou@var@fuka)*99}%
  \pgfmathsetlength{\seihou@boxwidth@inner}{0.85 * \seihou@boxwidth@new / 2}%
  \leavevmode%
  \ltjghostbeforejachar%
  \hbox to \seihou@boxwidth@new{%
  \raisebox{\vertical@adj@maru@new}{%
  \vbox to \seihou@boxwidth@new{%
  \vss%
  \hbox to \seihou@boxwidth@new{%
    \hss%
    \tikz[baseline=(char.base)]{%
      \node[
        line width=.04\seihou@boxwidth@new,  
        minimum size=.5\seihou@boxwidth@new, 
        draw,
        shape=diamond,
        inner sep=.03\seihou@boxwidth@new,
        rotate=\rot@kksym@tateyoko
      ] (char){%
      \vbox to \seihou@boxwidth@inner{
        \vss%
        \hbox to \seihou@boxwidth@inner{%
        \hss%
          % これだけ他のやつと違うので注意！
          \shukushou@adj@new{\seihou@var@yokohaba}{\seihou@boxwidth@inner}{\kks@ShrinkedNumber{#1}}%
        \hss%
        }%
        \vss%
      }%
      };
    }%
    \hss%
  }%
  \vss%
  }%
  }%
  }%
  \ltjghostafterjachar%
}


\DeclareRobustCommand{\maruhishi@new}[1]{%
  \rot@or@not@kksym%
  \setlength{\seihou@boxwidth@new}{\zw}%
  \settowidth{\seihou@var@yokohaba}{#1}%
  \pgfmathsetlength{\seihou@boxwidth@inner}{0.85 * \seihou@boxwidth@new / 2}%
  \leavevmode%
  \ltjghostbeforejachar%
  \hbox to \seihou@boxwidth@new{%
  \raisebox{\vertical@adj@maru@new}{%
  \vbox to \seihou@boxwidth@new{%
  \vss%
  \hbox to \seihou@boxwidth@new{%
    \hss%
    \tikz[baseline=(char.base)]{%
      \node[
        line width=.04\seihou@boxwidth@new,  
        minimum size=.5\seihou@boxwidth@new, 
        draw,
        rounded corners=.06\zw,%%%
        shape=diamond,
        inner sep=.03\seihou@boxwidth@new,
        rotate=\rot@kksym@tateyoko
      ] (char){%
      \vbox to \seihou@boxwidth@inner{
        \vss%
        \hbox to \seihou@boxwidth@inner{%
        \hss%
          \shukushou@adj@new{\seihou@var@yokohaba}{\seihou@boxwidth@inner}{\kks@ShrinkedNumber{#1}}%
        \hss%
        }%
        \vss%
      }%
      };
    }%
    \hss%
  }%
  \vss%
  }%
  }%
  }%
  \ltjghostafterjachar%
}
\DeclareRobustCommand{\maruhishi@new@no}[1]{%
  \rot@or@not@kksym%
  \setlength{\seihou@boxwidth@new}{\zw}%
  \settowidth{\seihou@var@yokohaba}{#1}%
  \settoheight{\seihou@var@tate}{#1}%
  \settodepth{\seihou@var@fuka}{#1}%
  \pgfmathsetlength{\seihou@var@zenkou}{(\seihou@var@tate + \seihou@var@fuka)*99}%
  \pgfmathsetlength{\seihou@boxwidth@inner}{0.85 * \seihou@boxwidth@new / 2}%
  \leavevmode%
  \ltjghostbeforejachar%
  \hbox to \seihou@boxwidth@new{%
  \raisebox{\vertical@adj@maru@new}{%
  \vbox to \seihou@boxwidth@new{%
  \vss%
  \hbox to \seihou@boxwidth@new{%
    \hss%
    \tikz[baseline=(char.base)]{%
      \node[
        line width=.04\seihou@boxwidth@new,  
        minimum size=.5\seihou@boxwidth@new, 
        draw,
        rounded corners=.06\zw,%%%
        shape=diamond,
        inner sep=.03\seihou@boxwidth@new,
        rotate=\rot@kksym@tateyoko
      ] (char){%
      \vbox to \seihou@boxwidth@inner{
        \vss%
        \hbox to \seihou@boxwidth@inner{%
        \hss%
          % これだけ他のやつと違うので注意！
          \shukushou@adj@new{\seihou@var@yokohaba}{\seihou@boxwidth@inner}{\kks@ShrinkedNumber{#1}}%
        \hss%
        }%
        \vss%
      }%
      };
    }%
    \hss%
  }%
  \vss%
  }%
  }%
  }%
  \ltjghostafterjachar%
}


\DeclareRobustCommand{\kurohishi@new}[1]{%
  \rot@or@not@kksym%
  \setlength{\seihou@boxwidth@new}{\zw}%
  \settowidth{\seihou@var@yokohaba}{#1}%
  \pgfmathsetlength{\seihou@boxwidth@inner}{0.85 * \seihou@boxwidth@new / 2}%
  \leavevmode%
  \ltjghostbeforejachar%
  \hbox to \seihou@boxwidth@new{%
  \raisebox{\vertical@adj@maru@new}{%
  \vbox to \seihou@boxwidth@new{%
  \vss%
  \hbox to \seihou@boxwidth@new{%
    \hss%
    \tikz[baseline=(char.base)]{%
      \node[
        line width=.04\seihou@boxwidth@new,  
        minimum size=.5\seihou@boxwidth@new, 
        draw,
        fill=black,%%%
        shape=diamond,
        inner sep=.03\seihou@boxwidth@new,
        rotate=\rot@kksym@tateyoko
      ] (char){%
      \vbox to \seihou@boxwidth@inner{
        \vss%
        \hbox to \seihou@boxwidth@inner{%
        \hss%
          \shukushou@adj@new{\seihou@var@yokohaba}{\seihou@boxwidth@inner}{%
            \textcolor{white}{\kks@ShrinkedNumber{#1}}}%
        \hss%
        }%
        \vss%
      }%
      };
    }%
    \hss%
  }%
  \vss%
  }%
  }%
  }%
  \ltjghostafterjachar%
}
\DeclareRobustCommand{\kurohishi@new@no}[1]{%
  \rot@or@not@kksym%
  \setlength{\seihou@boxwidth@new}{\zw}%
  \settowidth{\seihou@var@yokohaba}{#1}%
  \settoheight{\seihou@var@tate}{#1}%
  \settodepth{\seihou@var@fuka}{#1}%
  \pgfmathsetlength{\seihou@var@zenkou}{(\seihou@var@tate + \seihou@var@fuka)*99}%
  \pgfmathsetlength{\seihou@boxwidth@inner}{0.85 * \seihou@boxwidth@new / 2}%
  \leavevmode%
  \ltjghostbeforejachar%
  \hbox to \seihou@boxwidth@new{%
  \raisebox{\vertical@adj@maru@new}{%
  \vbox to \seihou@boxwidth@new{%
  \vss%
  \hbox to \seihou@boxwidth@new{%
    \hss%
    \tikz[baseline=(char.base)]{%
      \node[
        line width=.04\seihou@boxwidth@new,  
        minimum size=.5\seihou@boxwidth@new, 
        draw,
        fill=black,%%%
        shape=diamond,
        inner sep=.03\seihou@boxwidth@new,
        rotate=\rot@kksym@tateyoko
      ] (char){%
      \vbox to \seihou@boxwidth@inner{
        \vss%
        \hbox to \seihou@boxwidth@inner{%
        \hss%
          % これだけ他のやつと違うので注意！
          \shukushou@adj@new{\seihou@var@yokohaba}{\seihou@boxwidth@inner}{%
            \textcolor{white}{\kks@ShrinkedNumber{#1}}}%
        \hss%
        }%
        \vss%
      }%
      };
    }%
    \hss%
  }%
  \vss%
  }%
  }%
  }%
  \ltjghostafterjachar%
}


\DeclareRobustCommand{\kuromaruhishi@new}[1]{%
  \rot@or@not@kksym%
  \setlength{\seihou@boxwidth@new}{\zw}%
  \settowidth{\seihou@var@yokohaba}{#1}%
  \pgfmathsetlength{\seihou@boxwidth@inner}{0.85 * \seihou@boxwidth@new / 2}%
  \leavevmode%
  \ltjghostbeforejachar%
  \hbox to \seihou@boxwidth@new{%
  \raisebox{\vertical@adj@maru@new}{%
  \vbox to \seihou@boxwidth@new{%
  \vss%
  \hbox to \seihou@boxwidth@new{%
    \hss%
    \tikz[baseline=(char.base)]{%
      \node[
        line width=.04\seihou@boxwidth@new,  
        minimum size=.5\seihou@boxwidth@new, 
        draw,
        fill=black,%%%
        rounded corners=.06\zw,%%%
        shape=diamond,
        inner sep=.03\seihou@boxwidth@new,
        rotate=\rot@kksym@tateyoko
      ] (char){%
      \vbox to \seihou@boxwidth@inner{%
        \vss%
        \hbox to \seihou@boxwidth@inner{%
        \hss%
          \shukushou@adj@new{\seihou@var@yokohaba}{\seihou@boxwidth@inner}{%
            \textcolor{white}{\kks@ShrinkedNumber{#1}}}%
        \hss%
        }%
        \vss%
      }%
      };
    }%
    \hss%
  }%
  \vss%
  }%
  }%
  }%
  \ltjghostafterjachar%
}
\DeclareRobustCommand{\kuromaruhishi@new@no}[1]{%
  \rot@or@not@kksym%
  \setlength{\seihou@boxwidth@new}{\zw}%
  \settowidth{\seihou@var@yokohaba}{#1}%
  \settoheight{\seihou@var@tate}{#1}%
  \settodepth{\seihou@var@fuka}{#1}%
  \pgfmathsetlength{\seihou@var@zenkou}{(\seihou@var@tate + \seihou@var@fuka)*99}%
  \pgfmathsetlength{\seihou@boxwidth@inner}{0.85 * \seihou@boxwidth@new / 2}%
  \leavevmode%
  \ltjghostbeforejachar%
  \hbox to \seihou@boxwidth@new{%
  \raisebox{\vertical@adj@maru@new}{%
  \vbox to \seihou@boxwidth@new{%
  \vss%
  \hbox to \seihou@boxwidth@new{%
    \hss%
    \tikz[baseline=(char.base)]{%
      \node[
        line width=.04\seihou@boxwidth@new,  
        minimum size=.5\seihou@boxwidth@new, 
        draw,
        fill=black,%%%
        rounded corners=.06\zw,%%%
        shape=diamond,
        inner sep=.03\seihou@boxwidth@new,
        rotate=\rot@kksym@tateyoko
      ] (char){%
      \vbox to \seihou@boxwidth@inner{
        \vss%
        \hbox to \seihou@boxwidth@inner{%
        \hss%
          % これだけ他のやつと違うので注意！
          \shukushou@adj@new{\seihou@var@yokohaba}{\seihou@boxwidth@inner}{%
            \textcolor{white}{\kks@ShrinkedNumber{#1}}}%
        \hss%
        }%
        \vss%
      }%
      };
    }%
    \hss%
  }%
  \vss%
  }%
  }%
  }%
  \ltjghostafterjachar%
}
%%%


% \kakko
\newlength{\kakko@boxwidth@new}
\newlength{\kakko@boxwidth@inner}
\newlength{\kakko@var@yokohaba}
\newlength{\kakko@var@yokohaba@cal}
\newlength{\kakko@var@tate}
\newlength{\kakko@var@fuka}
\newlength{\kakko@var@zenkou}

\NewDocumentCommand{\shukushou@adj@new@no@kakko}{ m m m m }{%
  \ifdim #1 < #2%
    \ifdim #3 > #2%
      \resizebox*{#3}{!}{#4}%
    \else%
      \scalebox{.9}{#4}%
    \fi%
  \else%
    \resizebox*{!}{#2}{#4}%
  \fi%
}

\DeclareRobustCommand{\kakko@byouga@internal}[3]{% 横の方
  \rot@or@not@kksym%
  \setlength{\kakko@boxwidth@new}{\zw}%
  \settowidth{\kakko@var@yokohaba}{#3}%
  \pgfmathsetlength{\kakko@boxwidth@inner}{0.8 * \kakko@boxwidth@new}%
  \leavevmode%
  \ltjghostbeforejachar%
    \hbox to \zw{\hss%
      \scalebox{.63}[1]{#1}\hspace*{-.1\zw}%
      \raisebox{-.03\zw}{%
        \vbox to \kakko@boxwidth@inner{%
          \vss%
          \hbox to \kakko@boxwidth@inner{%
          \hss%
            \rotatebox[origin=c]{\rot@kksym@tateyoko}{%
              \shukushou@adj@new{\kakko@var@yokohaba}{\kakko@boxwidth@inner}{\kks@ShrinkedNumber{#3}}}%
          \hss%
          }%
          \vss%
        }%
      }%
      \hspace*{-.1\zw}\scalebox{.63}[1]{#2}%
    \hss}%
  \ltjghostafterjachar%
}
\DeclareRobustCommand{\kakko@byouga@internal@no}[3]{% 横の方
  \rot@or@not@kksym%
  \setlength{\kakko@boxwidth@new}{\zw}%
  \settowidth{\kakko@var@yokohaba}{#3}%
  \settoheight{\kakko@var@tate}{#3}%
  \settodepth{\kakko@var@fuka}{#3}%
  \pgfmathsetlength{\kakko@var@zenkou}{\kakko@var@tate + \kakko@var@fuka}%
  \pgfmathsetlength{\kakko@var@yokohaba@cal}{0.9 * \kakko@var@yokohaba}%
  \pgfmathsetlength{\kakko@boxwidth@inner}{0.8 * \kakko@boxwidth@new}%
  \leavevmode%
  \ltjghostbeforejachar%
    \hbox to \zw{\hss%
      \scalebox{.63}[1]{#1}\hspace*{-.1\zw}%
      \raisebox{-.03\zw}{%
        \vbox to \kakko@boxwidth@inner{%
          \vss%
          \hbox to \kakko@boxwidth@inner{%
          \hss%
            \rotatebox[origin=c]{\rot@kksym@tateyoko}{%
              \shukushou@adj@new@no@kakko{\kakko@var@zenkou}{\kakko@boxwidth@inner}{\kakko@var@yokohaba@cal}{\kks@ShrinkedNumber{#3}}}%
          \hss%
          }%
          \vss%
        }%
      }%
      \hspace*{-.1\zw}\scalebox{.63}[1]{#2}%
    \hss}%
  \ltjghostafterjachar%
}

\DeclareRobustCommand{\kakko@byouga@internal@tate}[3]{% 縦の方
  \rot@or@not@kksym%
  \ifnum\ltjgetparameter{direction}=3\pgfmathsetmacro{\rot@kksym@tateyoko}{\rot@kksym@tateyoko - 90}\fi%
  \setlength{\kakko@boxwidth@new}{\zw}%
  \settowidth{\kakko@var@yokohaba}{#3}%
  \pgfmathsetlength{\kakko@boxwidth@inner}{0.8 * \kakko@boxwidth@new}%
  \leavevmode%
  \ltjghostbeforejachar%
    \raisebox{-.5\zw}{%
    \rotatebox[origin=c]{90}{%
    \hbox to \zw{\hss%
    \vbox to \zw{\vss%
      \hbox to \zw{\hss%
      \scalebox{.63}[1]{#1}\hspace*{-.1\zw}%
        \vbox to \kakko@boxwidth@inner{%
        \vss%
        \hbox to \kakko@boxwidth@inner{%
        \hss%
          \raisebox{-1.2\zw}{%
            \rotatebox[origin=c]{\rot@kksym@tateyoko}{%
              \shukushou@adj@new{\kakko@var@yokohaba}{\kakko@boxwidth@inner}{\kks@ShrinkedNumber{#3}}%
            }%
          }%
        \hss%
        }%
        \vss%
      }%
      \hspace*{-.1\zw}\scalebox{.63}[1]{#2}\vspace*{.3\zw}%
    \hss}%
    \vss}%
    \hss}%
    }%
    }%
  \ltjghostafterjachar%
}
\DeclareRobustCommand{\kakko@byouga@internal@tate@no}[3]{% 縦の方
  \rot@or@not@kksym%
  \ifnum\ltjgetparameter{direction}=3\pgfmathsetmacro{\rot@kksym@tateyoko}{\rot@kksym@tateyoko - 90}\fi%
  \setlength{\kakko@boxwidth@new}{\zw}%
  \settowidth{\kakko@var@yokohaba}{#3}%
  \settoheight{\kakko@var@tate}{#3}%
  \settodepth{\kakko@var@fuka}{#3}%
  \pgfmathsetlength{\kakko@var@zenkou}{\kakko@var@tate + \kakko@var@fuka}%
  \pgfmathsetlength{\kakko@var@yokohaba@cal}{0.9 * \kakko@var@yokohaba}%
  \pgfmathsetlength{\kakko@boxwidth@inner}{0.8 * \kakko@boxwidth@new}%
  \leavevmode%
  \ltjghostbeforejachar%
    \raisebox{-.5\zw}{%
    \rotatebox[origin=c]{90}{%
    \hbox to \zw{\hss%
    \vbox to \zw{\vss%
      \hbox to \zw{\hss%
      \scalebox{.63}[1]{#1}\hspace*{-.1\zw}%
        \vbox to \kakko@boxwidth@inner{%
        \vss%
        \hbox to \kakko@boxwidth@inner{%
        \hss%
          \raisebox{-1.6\zw}{%
            \vbox to \kakko@boxwidth@inner{%
            \vss%
            \hbox to \kakko@boxwidth@inner{%
            \hss%
            \rotatebox[origin=c]{\rot@kksym@tateyoko}{%
              \shukushou@adj@new@no@kakko{\kakko@var@zenkou}{\kakko@boxwidth@inner}{\kakko@var@yokohaba@cal}{\kks@ShrinkedNumber{#3}}%
            }\hss}\vss}%
          }%
        \hss%
        }%
        \vss%
      }%
      \hspace*{-.1\zw}\scalebox{.63}[1]{#2}\vspace*{.3\zw}%
    \hss}%
    \vss}%
    \hss}%
    }%
    }%
  \ltjghostafterjachar%
}
%%%


% \ichimoji
\newlength{\ichimoji@yk@new}
\newlength{\ichimoji@ht@new}
\newlength{\ichimoji@dp@new}
\newlength{\ichimoji@zenkou@new}
\DeclareRobustCommand{\ichimoji@scaling}[1]{%
  \ifdim\ichimoji@yk@new > \zw%
    \pgfmathsetmacro{\ratio@ichimoji@yk}{\strip@pt\zw/\strip@pt\ichimoji@yk@new}%
    \scalebox{\ratio@ichimoji@yk}[1]{#1}%
  \else%
    #1%
  \fi%
}
\DeclareRobustCommand{\ichimoji@new}[1]{%
  \ifnum\ltjgetparameter{direction}=3%
    \leavevmode%
    \ltjghostbeforejachar%
    \raisebox{-.5\zw}{%
      \hbox to \zw {\hss%
      \vbox to \zw {\vss%
      \hbox to \zw {\hss%
        \resizebox*{\zw}{\zw}{#1}%
      \hss}%
      \vss}%
      \hss}%
    }%
    \ltjghostafterjachar%
  \else%
    \leavevmode%
    \ltjghostbeforejachar%
    \raisebox{-.12\zw}{%
      \hbox to \zw {\hss%
      \vbox to \zw {\vss%
      \hbox to \zw {\hss%
        \resizebox*{\zw}{\zw}{#1}%
      \hss}%
      \vss}%
      \hss}%
    }%
    \ltjghostafterjachar%
  \fi%
}
\DeclareRobustCommand{\ichimoji@new@no}[1]{%
  \settowidth{\ichimoji@yk@new}{#1}%
  \settoheight{\ichimoji@ht@new}{#1}%
  \settodepth{\ichimoji@dp@new}{#1}%
  \pgfmathsetlength{\ichimoji@zenkou@new}{\ichimoji@ht@new + \ichimoji@dp@new}%
  \ifnum\ltjgetparameter{direction}=3%
    \leavevmode%
    \ltjghostbeforejachar%
    \raisebox{-.5\zw}{%
      \hbox to \zw {\hss%
      \vbox to \zw {\vss%
      \hbox to \zw {\hss%
        \ichimoji@scaling{#1}%
      \hss}%
      \vss}%
      \hss}%
    }%
    \ltjghostafterjachar%
  \else%
    \leavevmode%
    \ltjghostbeforejachar%
    \raisebox{-.12\zw}{%
      \hbox to \zw {\hss%
      \vbox to \zw {\vss%
      \hbox to \zw {\hss%
        \ichimoji@scaling{#1}%
      \hss}%
      \vss}%
      \hss}%
    }%
    \ltjghostafterjachar%
  \fi%
}
%%%


% \zenkakuhabafixer
\newlength{\zenkakuhabafixer@yk@new}
\DeclareRobustCommand{\zenkakuhabafixer}[1]{%
  \leavevmode%
  \settowidth{\zenkakuhabafixer@yk@new}{#1}%
  \ifdim\zenkakuhabafixer@yk@new>\zw%
    \ltjghostbeforejachar%
    \hbox to \zw {%
      \resizebox{\zw}{\height}{#1}%
    }%
    \ltjghostafterjachar%
  \else%
    \ltjghostbeforejachar%
    \hbox to \zw {%
      \hss #1\hss%
    }%
    \ltjghostafterjachar%
  \fi%
}
%%%
\endinput