
% needs XeLaTeX



\ProvidesPackage{jizuradictionary}


% ==========================================================================================================
% Unicode and CJK Handling
% ----------------------------------------------------------------------------------------------------------
\usepackage{fontspec}
\usepackage{xeCJK}
% \usepackage{/home/flow/own/tex-packages/xeCJK-2.4.6-r306/xeCJK}
\usepackage{leading}
\usepackage{/Users/flow/JIZURA/flow/dictionary/tex-inputs/utils}
% \usepackage{/Users/flow/JIZURA/flow/dictionary/tex-inputs/accentbx/accentbx}
\usepackage{cxltx-style-accentbox}
% \usepackage{/Volumes/Storage/cnd/node_modules/jizura-xelatex/tex-inputs/background-grid}
% \usepackage{tabu}
\usepackage{pbox}
\usepackage{array}
% \usepackage{leading}
% \usepackage{fancyhdr}
\usepackage{fixltx2e}
\usepackage{multicol}
\usepackage[usenames,dvipsnames,svgnames,table,x11names]{xcolor}

% ==========================================================================================================
% Nifty stuff
% ----------------------------------------------------------------------------------------------------------
\usepackage{float}
\usepackage{wrapfig}
\usepackage{enumitem}
% \usepackage[protrusion=true,final]{/home/flow/own/tex-packages/microtype/microtype} % doesn't work yet
% \usepackage[protrusion=true,final]{microtype} % doesn't work yet
\newcommand{\insertblankpage}{\thispagestyle{empty}\mbox{}\newpage}

% ==========================================================================================================
% CJK Glyph Bullets
% ----------------------------------------------------------------------------------------------------------

\usepackage{tikz}
\newcommand*\circled[1]{\tikz[baseline=(char.base),line width=0.25mm,blue]{
            \node[shape=circle,draw,inner sep=0.25mm] (char) {#1};}}

% ==========================================================================================================
% Drop Caps
% ----------------------------------------------------------------------------------------------------------
\usepackage{lettrine}
\setcounter{DefaultLines}{2}
\renewcommand{\DefaultLoversize}{-0.0}
\renewcommand{\DefaultLraise}{0.1}
\renewcommand{\DefaultLhang}{0.07}
\setlength{\DefaultFindent}{0.5em}
\setlength{\DefaultNindent}{0.0em}

% ==========================================================================================================
% General Document Style
% Preliminarily set up to work with document class `article` and will likely change.
% ----------------------------------------------------------------------------------------------------------
\usepackage{polyglossia}
\setdefaultlanguage{english}
\setlength{\parskip}{\baselineskip}
\setlength{\parindent}{0pt}


% ==========================================================================================================
% Font Usage
% ----------------------------------------------------------------------------------------------------------
% gotta figure out how to get proper ligatures,
% maybe just do replacements in the source (but that will affect line breaking / hyphenation):
% \setmainfont{gentium2-regular}
% \setmainfont[Mapping=tex-text,Path=/home/flow/own/resources/fonts/]{EBGaramond12-Regular.otf}
\setmainfont[Mapping=tex-text]{EB Garamond 12 Regular}
% \newfontfamily\glossFont{gentium2-italic}
% ..........................................................................................................
% \setCJKmainfont{Droid Sans Japanese}
\setCJKmainfont{Sun-ExtA}
% \setCJKmainfont[Path=/home/flow/own/resources/fonts/]{EBGaramond12-Regular.otf}
% ..........................................................................................................
\newfontfamily\latinBoldFont{Ubuntu Bold}
\newfontfamily\ttFont[Scale=0.8]{Flow DejaVu Sans Mono}
\newfontfamily\tinyTtFont[Scale=0.5]{Flow DejaVu Sans Mono}
% \newfontfamily\scFont[Path=/home/flow/own/resources/fonts/]{EBGaramond12-SC.otf}
\newfontfamily\scFont{EB Garamond 12 Regular SmallCaps}
\newfontfamily\ttboldFont{DejaVu Sans Mono Bold}
% ..........................................................................................................
\newCJKfontfamily\cjkIdeographFont[Scale=1.05,AutoFakeBold=2]{Sun-ExtA}
\newCJKfontfamily\cjkxbIdeographFont[Scale=1.05,AutoFakeBold=1]{sunflower-u-cjk-xb}
\newCJKfontfamily\cjkxcIdeographFont[Scale=1.05,AutoFakeBold=1]{BabelStone Han} % ??????????????????????
\newCJKfontfamily\cjksymIdeographFont[Scale=1.05,AutoFakeBold=1]{HanaMinA}
\newCJKfontfamily\cjkxdIdeographFont[Scale=1.05,AutoFakeBold=1]{BabelStone Han}
\newfontfamily\jzrFont[Scale=1.05,AutoFakeBold=1]{jizura3a}
% \newfontfamily\pinyinFont[Scale=0.8,Path=/usr/share/fonts/truetype/ubuntu-font-family/]{Ubuntu-C.ttf}
\newfontfamily\pinyinFont[Scale=0.8]{Ubuntu}
\newfontfamily\pinyinItalicFont[Scale=0.8]{Ubuntu Italic}
\newCJKfontfamily\katakanaFont[Scale=0.95,AutoFakeBold=0]{NanumMyeongjo}
\newCJKfontfamily\hiraganaFont[Scale=0.95,AutoFakeBold=1]{NanumMyeongjo}
\newCJKfontfamily\hangeulFont[Scale=1.05,AutoFakeBold=1]{NanumMyeongjo}
\newfontfamily\glossFont[Mapping=tex-text]{EB Garamond 12 Regular}
% ..........................................................................................................
% \newfontfamily\narrowFont{Futura Condensed Medium}
% \newfontfamily\narrowFont{Ubuntu Condensed}
% \newfontfamily\narrowFont{Didot}
% \newfontfamily\narrowFont{Letter Gothic Std}
% \newfontfamily\narrowFont{Plantagenet Cherokee}% !!!!!!!! mediaeval numerals
\newfontfamily\narrowFont{PT Sans Narrow}% looks nice
% \newfontfamily\narrowFont{Liberation Sans Narrow}
% ..........................................................................................................
\newCJKfontfamily\missingFont[Scale=1.05,AutoFakeBold=1,Color=red]{Sun-ExtA}

% ==========================================================================================================
% Display Styles
% ----------------------------------------------------------------------------------------------------------
\newcommand{\cjkInterchrSpacing}{\hskip -0.4pt plus 3pt minus 1pt}
% \newcommand{\adjustCjkIdeograph}[1]{\cjkInterchrSpacing\lower0.3ex\hbox{\textbf{#1}}}
% \newcommand{\adjustKatakana}[1]{\cjkInterchrSpacing\lower0.5ex\hbox{\textbf{#1}}}
% \newcommand{\adjustHiragana}[1]{\cjkInterchrSpacing\lower0.5ex\hbox{\textbf{#1}}}
% \newcommand{\adjustHangeul}[1]{\cjkInterchrSpacing\lower0.3ex\hbox{\textbf{#1}}}
\newcommand{\adjustCjkIdeograph}[1]{\cjkInterchrSpacing\lower0.3ex\hbox{#1}}
\newcommand{\adjustKatakana}[1]{\cjkInterchrSpacing\lower0.3ex\hbox{#1}}
\newcommand{\adjustHiragana}[1]{\cjkInterchrSpacing\lower0.3ex\hbox{#1}}
\newcommand{\adjustHangeul}[1]{\cjkInterchrSpacing\lower0.3ex\hbox{#1}}
% ..........................................................................................................
\newcommand{\py}[1]{{\pinyinFont#1}}
\newcommand{\gloss}[1]{{\glossFont#1}}
\newcommand{\cn}[1]{\adjustCjkIdeograph{\cjkIdeographFont#1}}
\newcommand{\cnxa}[1]{\adjustCjkIdeograph{\cjkIdeographFont#1}}
\newcommand{\cnxb}[1]{\adjustCjkIdeograph{\cjkxbIdeographFont#1}}
\newcommand{\cnxc}[1]{\adjustCjkIdeograph{\cjkxcIdeographFont#1}}
\newcommand{\cnxd}[1]{\adjustCjkIdeograph{\cjkxdIdeographFont#1}}
\newcommand{\cncone}[1]{\adjustCjkIdeograph{\cjkxcIdeographFont#1}}
\newcommand{\cnctwo}[1]{\adjustCjkIdeograph{\cjkxcIdeographFont#1}}
\newcommand{\cnrone}[1]{\adjustCjkIdeograph{\cjkIdeographFont#1}}
\newcommand{\cnrtwo}[1]{\adjustCjkIdeograph{\cjkIdeographFont#1}}
% \newcommand{\cnsym}[1]{\adjustCjkIdeograph{\cjkIdeographFont#1}}
\newcommand{\cnsym}[1]{\adjustCjkIdeograph{\cjksymIdeographFont#1}}
\newcommand{\cnstrk}[1]{\adjustCjkIdeograph{\cjkIdeographFont#1}}
\newcommand{\cnjzr}[1]{\adjustCjkIdeograph{\jzrFont#1}}
\newcommand{\cnextra}[1]{\adjustCjkIdeograph{\cjkxcIdeographFont#1}}
\newcommand{\ka}[1]{\adjustKatakana{\katakanaFont#1}}
\newcommand{\hi}[1]{\adjustHiragana{\hiraganaFont#1}}
\newcommand{\hg}[1]{\adjustHangeul{\hangeulFont#1}}
% ..........................................................................................................
\newcommand{\missing}[1]{\missingFont#1}

% ==========================================================================================================
% Extras
% ----------------------------------------------------------------------------------------------------------
\newcommand{\hirabar}{\hskip0.4ex plus 0.2ex minus 0.2ex%
	\vrule width 0.2mm height 0.7em depth 0.3em%
	\hskip0.8ex plus 0.2ex minus 0.2ex}


% ----------------------------------------------------------------------------------------------------------
\newcommand{\jzrpagenumber}[1]{%
  {\pinyinFont #1}%
  }%

% ----------------------------------------------------------------------------------------------------------
\newcommand{\jzrpagenumberitalic}[1]{%
  {\pinyinItalicFont #1}%
  }%

% ..........................................................................................................
\makepagestyle{jzrshapeclasses}
\makeevenhead{jzrshapeclasses}{\jzrpagenumber{\thepage}}{\jzrpagenumber{Shapeclasses}}{}
\makeoddhead{jzrshapeclasses}{}{\jzrpagenumber{Shapeclasses}}{\jzrpagenumber{\thepage}}
% ..........................................................................................................
\makepagestyle{jzrguideindex}
\makeevenhead{jzrguideindex}{\jzrpagenumber{\thepage}}{\jzrpagenumber{Guides}}{}
\makeoddhead{jzrguideindex}{}{\jzrpagenumber{Guides}}{\jzrpagenumber{\thepage}}
% ..........................................................................................................
\makepagestyle{jzrmainpart}
\makeevenhead{jzrmainpart}{\jzrpagenumber{\thepage}}{\jzrpagenumber{Characters}}{}
\makeoddhead{jzrmainpart}{}{\jzrpagenumber{Characters}}{\jzrpagenumber{\thepage}}
% ..........................................................................................................

% ----------------------------------------------------------------------------------------------------------
% \newcommand{\fncr}[2]{%
  % {\lower0.3ex\vbox{\ttFont\hbox{#1}\hbox{#2}}}}
\newcommand{\fncr}[2]{%
  {\fontsize{2.25mm}{2mm}\leading{2mm}\ttFont\lower0.6ex\vbox{\hbox{#1}\hbox{#2}}}}
\newcommand{\fncrB}[2]{%
  {\fontsize{2.25mm}{2mm}\leading{2mm}\ttboldFont\lower0.6ex\vbox{\hbox{#1}\hbox{#2}}}}
% \newcommand{\fncrNG}[3]{%
%   {\fontsize{2.25mm}{2mm}\leading{2mm}\narrowFont\lower0.6ex\vbox{\hbox{#1}\hbox{#2·#3}}}}
\newcommand{\fncrNG}[3]{%
  {\leavevmode%
    {\leading{1mm}%
      \lower0.6ex%
      \vbox to 8.5mm{%
        \vfill%
        \hbox to 8.5mm{%
          \hfil#1\hfil}%
        \vfill%
        \hbox to 8.5mm{%
          \fontsize{2.5mm}{2mm}\narrowFont%
          \hfil#2-#3\hfil}%
        }%
      }%
    }%
  }
\newcommand{\fncrC}[3]{%
  {\leavevmode%
    {\leading{1mm}%
      \lower0.6ex%
      \vbox to \nominalfontsize{%
        \hbox to 10mm{%
          \fontsize{2.8mm}{2mm}\pinyinFont%
          % \hfil%
          #1%
          \hfil}%
        \vfill%
        \hbox to 10mm{%
          \fontsize{2.8mm}{2mm}\pinyinFont%
          % \hfil%
          #2-#3%
          \hfil}%
        % \vfill%
        }%
      }%
    }%
  }
% ..........................................................................................................
\newcommand{\usageCode}[2]{%
  {\fontsize{2.25mm}{2mm}\leading{2mm}\ttFont\lower0.6ex\vbox{\hbox{#1}\hbox{#2}}}}
\newcommand{\usageCodeB}[2]{%
  {\fontsize{2.25mm}{2mm}\leading{2mm}\ttboldFont\lower0.6ex\vbox{\hbox{#1}\hbox{#2}}}}


% ==========================================================================================================
% STRUTS
% ----------------------------------------------------------------------------------------------------------
\newcommand{\jzrdivider}{\vskip0pt\hrule\vskip-0.4pt}
\newcommand{\jzrdividerinvisible}{\vskip0pt\hrule width0mm\vskip-0.4pt}
\newdimen\nominalfontsize
\newdimen\gridstrutheight
\newdimen\gridstrutwidth
\newdimen\gridstrutdepth
\newdimen\gridstrutlength
\nominalfontsize=4.5mm
\gridstrutheight=4.25mm
\gridstrutwidth=0mm
\gridstrutdepth=2.25mm
\gridstrutlength=\dimexpr\gridstrutheight+\gridstrutdepth
\newcommand{\gridstrut}{{\color{blue}\vrule height\gridstrutheight width\gridstrutwidth depth\gridstrutdepth}}
% \newcommand{\gridstrut}{}
% \newcommand{\gridstrut}{{\color{blue}\rule[\gridstrutdepth]{\gridstrutwidth}{\gridstrutlength}}}

\setlength{\multicolsep}{\gridstrutlength}
\setlength{\columnsep}{1mm}
\setlength{\columnseprule}{0.15mm}
% \setlength{\multicolovershoot}{0mm}


% ==========================================================================================================
% ENVIRONMENTS FOR THE DICTIONARY
% ----------------------------------------------------------------------------------------------------------
% jzrplain
\newenvironment{jzrplain}{%
% ..........................................................................................................
% begin
  % thx to http://www.tug.org/TUGboat/tb28-1/tb88bazargan.pdf for the next two settings:
  \lineskiplimit=-10pt%
  \lineskip=0pt%
  \topskip=0pt%
  \setlength{\parskip}{0mm}%
  \setlength{\parindent}{0mm}%
  \fontsize{\nominalfontsize}{\gridstrutlength}%
  \leading{\gridstrutlength}}%
% end
  {\par}

% ----------------------------------------------------------------------------------------------------------
\newcommand{\emphasizeguide}[1]{%
  % {\color{DodgerBlue4}\addfontfeatures{FakeBold=5.5}#1}}
  {\color{DodgerBlue4}\textbf{#1}}}

% ----------------------------------------------------------------------------------------------------------
\newcommand{\emphasizestrokeclass}[1]{%
  {\colorbox{DodgerBlue4}{\color{white}{\latinBoldFont #1}}}}

% ----------------------------------------------------------------------------------------------------------
\newcounter{jzrglyphcount}

% ==========================================================================================================
% BASE LINE GRID
% ----------------------------------------------------------------------------------------------------------
\newcommand{\showbaselinegrid}{
  \usepackage{atbegshi,picture,xcolor}
  \AtBeginShipout{%
    \AtBeginShipoutUpperLeft{%
      \color{red}%
      \put(\dimexpr 1in+\oddsidemargin,
           -\dimexpr 1in+\topmargin+\headheight+\headsep+\topskip-\gridstrutdepth-1.255mm)%
        {%
         \vtop to\dimexpr\vsize+0mm{
           \hrule
           \leaders\vbox to \gridstrutlength{\hrule height0.1pt width\hsize\vfill}\vfill
         }}}}}



% ==========================================================================================================
% PAGE SIZE
% ----------------------------------------------------------------------------------------------------------
% original
\usepackage[
  left=20mm,
  right=10mm,
  top=8mm,
  bottom=12mm,
  headsep=1mm,
  footskip=5mm,
  marginparsep=1mm,
  marginparwidth=14mm,
  headheight=5mm,
  includehead,
  includefoot,
  paperwidth=210mm,
  paperheight=297mm]{geometry}
% experimental
% \usepackage[
%   left=10mm,
%   right=10mm,
%   top=30mm,
%   bottom=10mm,
%   headsep=1mm,
%   footskip=5mm,
%   marginparsep=1mm,
%   marginparwidth=14mm,
%   headheight=5mm,
%   includehead,
%   includefoot,
%   % paperwidth=110mm,
%   paperwidth=155mm,
%   paperheight=297mm]{geometry}
\newcommand*{\mainentry}[1]{#1\markboth{#1}{#1}}


% ==========================================================================================================
% RULER WIDTHS
% ----------------------------------------------------------------------------------------------------------
\setlength{\arrayrulewidth}{0.15mm}
\setlength{\doublerulesep}{0.5mm}
% ----------------------------------------------------------------------------------------------------------


% ==========================================================================================================
% TITLE PAGE
% ----------------------------------------------------------------------------------------------------------
% \usepackage{swrule}
% \hfil\swrule{100mm}{0.5mm}\hfil
% \usepackage[object=vectorian]{pgfornament}
% \newcommand{\sectionline}{%
%   \noindent
%   \begin{center}
%   {\color{DarkViolet}
%     \resizebox{0.5\linewidth}{1ex}
%     {{%
%     {\begin{tikzpicture}
%     \node  (C) at (0,0) {};
%     \node (D) at (9,0) {};
%     \path (C) to [ornament=85] (D);
%     \end{tikzpicture}}}}}%
%     \end{center}
%   }
\newcommand*{\jzrtitle}{\begingroup% AW, Design of Books
\pagestyle{empty}
\centering
% {\Huge \cn{中日韓文}}\\[\baselineskip]
% {\Huge \cn{字形索引}}\\[\baselineskip]
~\vspace{4\baselineskip}\\
\includegraphics[width=0.75\linewidth]{/Volumes/Storage/temp/french-rule-swell-dash-englische-line/swell-dash.pdf}\\[3\baselineskip]
\par

{\HUGE \textit{The}}\\[0.75\baselineskip]
{\HUGE \scFont Jizura Index}\\[0.75\baselineskip]
{\HUGE \cn{字面索引}}\\[\baselineskip]
{\HUGE \textit{of}}\\[0.75\baselineskip]
{\HUGE \scFont Chinese, Japanese \textit{\&} Korean}\\[0.75\baselineskip]
{\HUGE \scFont \textit{Characters}}\\[3\baselineskip]
\par

\includegraphics[width=0.75\linewidth]{/Volumes/Storage/temp/french-rule-swell-dash-englische-line/swell-dash.pdf}\\[\baselineskip]
\par

\vspace{2\baselineskip}
% {Containing \thejzrglyphcount\ characters}\\[8\baselineskip]
{\LARGE\textit{Containing}}\\[0.25\baselineskip]
{\Huge 9980 characters}\\[0.25\baselineskip]
% {\LARGE\textit{grouped}}\\%[0.5\baselineskip]
% {\LARGE\textit{on geometric principles}}\\%[0.5\baselineskip]
% {\LARGE\textit{by}}\\[0.5\baselineskip]
{\LARGE\textit{grouped on geometric principles by}}\\[0.25\baselineskip]
{\Huge 657 guides}\\[0.25\baselineskip]
{\LARGE\textit{which are divided into}}\\[0.25\baselineskip]
{\Huge 119 shapeclasses}\\[0.25\baselineskip]
{\LARGE\textit{according to their initial strokes}}\\[0.25\baselineskip]
\vfill
\thispagestyle{empty} % repeated here as per http://tug.org/pipermail/macostex-archives/2010-February/043062.html
% {\small\sffamily THE PUBLISHER}\par
\endgroup}



% ..........................................................................................................
% \usepackage{./usecolumndots}
% \usepackage{../tex-inputs/usecolumndots}

% \usepackage[realmainfile,parent]{currfile}
% \expandafter\newcommand{\FILENAME}{\currfilepath}
% \edef\FILENAME{\currfilepath}
% \usepackage{usecolumndots}









