% This file loads Kurier or Iwona math fonts by plainTeX macros
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Petr Olsak, 2016

\message{FONT: Kurier/Iwona math fonts - \string\mathchardef's + 10 math families prepared.}
\let\mathpreloaded=R

\ifx\mfamname\undefined \def\mfamname{iwona}\fi

\def\normalmath{%
  \loadmathfamily  0 rm-\mfamname r     % Kurier/Iwona Roman
  \loadmathfamily  1 mi-\mfamname ri    % Kurier/Iwona Math Italic
  \loadmathfamily  2 sy-\mfamname rz    % Kurier/Iwona Standard symbols
  \loadmathfamily  3 ex-\mfamname r     % Kurier/Iwona extra symbols   
  \loadmathfamily  4 msam   % AMS symbols A
  \loadmathfamily  5 msbm   % AMS symbols B
  \loadmathfamily  6 rsfs   % script
  \loadmathfamily  7 eufm   % fractur
  \loadmathfamily  8 rm-\mfamname b   % sans serif bold
  \loadmathfamily  9 rm-\mfamname bi  % sans serif bold slanted
  \setmathdimens
}
\def\boldmath{%
  \loadmathfamily  0 rm-\mfamname b     % Kurier/Iwona Roman
  \loadmathfamily  1 mi-\mfamname bi    % Kurier/Iwona Math Italic
  \loadmathfamily  2 sy-\mfamname bz    % Kurier/Iwona Standard symbols
  \loadmathfamily  3 ex-\mfamname b     % Kurier/Iwona extra symbols   
  \loadmathfamily  4 msam   % AMS symbols A
  \loadmathfamily  5 msbm   % AMS symbols B
  \loadmathfamily  6 rsfs   % script
  \loadmathfamily  7 eufm   % fractur
  \loadmathfamily  8 rm-\mfamname h   % sans serif bold
  \loadmathfamily  9 rm-\mfamname hi  % sans serif bold slanted
  \setmathdimens
}
\count18=9 

\let\normalKImath=\normalmath  \let\boldKImath=\boldmath

\def\bi{\tenbi \fam\bifam} % in csplain is done \def\bi{\tenbi} only
\def\bbchar{\fam5 }        % double stroked letters
\def\frak{\fam7 }          % fraktur
\def\script{\fam6 }        % more extensive script than \cal
\chardef\bffam 8           % sans serif bold
\chardef\bifam 9           % sans serif bold slanted
\chardef\rmfam 0           % for \rm (can differ from CM Roman)
\chardef\itfam 1           % normal italic
\let\slfam=\itfam \let\ttfam=\rmfam % for raw similarity with plainTeX

\def\corrmsizes{\ptmunit=1\ptunit\relax}

% macros:

\ifx\rfontskipat\undefined \input csfontsm \fi

\def\loadmathfamily #1 #2 {\chardef\tmp#1\corrmsizes
  \let\dgsize=\sizemtext    \font\mF=\whichtfm{#2} at\dgsize \textfont#1=\mF
  \let\dgsize=\sizemscript  \font\mF=\whichtfm{#2} at\dgsize \scriptfont#1=\mF
  \let\dgsize=\sizemsscript \font\mF=\whichtfm{#2} at\dgsize \scriptscriptfont#1=\mF
  \let\dgsize=\undefined
}
\def\setmathfamily #1 #2{\let\mF=#2\chardef\tmp#1\corrmsizes
  \let\dgsize=\sizemtext    \letfont#2=#2 at\dgsize \textfont#1=#2%
  \let\dgsize=\sizemscript  \letfont#2=#2 at\dgsize \scriptfont#1=#2%
  \let\dgsize=\sizemsscript \letfont#2=#2 at\dgsize \scriptscriptfont#1=#2%
  \let\dgsize=\undefined \let#2=\mF
}
\def\itvariables{\def\rm{\fam\rmfam \tenrm}%
  \mathcodechanges C:0-9\mathcodechanges D:A-Z\mathcodechanges D:a-z}
\def\mitvariables{\def\rm{\fam0\tenrm}%
  \mathcodechanges 0:0-9\mathcodechanges 1:A-Z\mathcodechanges 1:a-z}

\def\mathcodechanges#1:#2-#3{\edef\tmp{\count0=\the\count0 \count1=\the\count1 }%
   \count0=`#2  \count1=\count0  \advance\count1 by"7#100
   \loop \mathcode\count0=\count1
         \ifnum\count0<`#3 \advance\count0 by1 \advance\count1 by1 \repeat
   \tmp\relax
}
\ifx\whichtfm\undefined \def\whichtfm#1{#1}\fi

\def\setmathdimens{% PlainTeX sets these dimens for 10pt size only:
  \delimitershortfall=0.5\fontdimen6\textfont3 
  \nulldelimiterspace=0.12\fontdimen6\textfont3
  \scriptspace=0.05\fontdimen6\textfont3
  \skewchar\textfont1=127 \skewchar\scriptfont1=127
  \skewchar\scriptscriptfont1=127
  \skewchar\textfont2=48  \skewchar\scriptfont2=48
  \skewchar\scriptscriptfont2=48
  \fontdimen8\scriptfont3 = \fontdimen8\textfont3  
  \fontdimen8\scriptscriptfont3 = \fontdimen8\textfont3
}
\def\setmathsizes[#1/#2/#3]{%
   \def\sizemtext{#1\ptmunit}\def\sizemscript{#2\ptmunit}% 
   \def\sizemsscript{#3\ptmunit}%
}
\ifx\ptuint\undefined  \def\ptunit{pt}\fi
\ifx\ptmunit\undefined \csname newdimen\endcsname\ptmunit\fi \ptmunit=1\ptunit
\ifx\sizemtext\undefined \setmathsizes[10/7/5]\fi

\ifx\tenbi\undefined \font\tenbi=ptmbi8z \relax \fi
\ifx\normalmathloading\relax\else \normalmath \fi  % load families, normal shape
\mitvariables 

%% \mathchardef declarations

\def\amsafam{4} \def\amsbfam{5}

%% AMSA

\mathchardef \boxdot   "2\amsafam 00
\mathchardef \boxplus   "2\amsafam 01
\mathchardef \boxtimes   "2\amsafam 02
\mathchardef \square   "0\amsafam 03
\mathchardef \blacksquare   "0\amsafam 04
\mathchardef \centerdot   "2\amsafam 05
\mathchardef \lozenge   "0\amsafam 06
\mathchardef \blacklozenge   "0\amsafam 07
\mathchardef \circlearrowright   "3\amsafam 08
\mathchardef \circlearrowleft   "3\amsafam 09
\mathchardef \rightleftharpoons   "3\amsafam 0A
\mathchardef \leftrightharpoons   "3\amsafam 0B
\mathchardef \boxminus   "2\amsafam 0C
\mathchardef \Vdash   "3\amsafam 0D
\mathchardef \Vvdash   "3\amsafam 0E
\mathchardef \vDash   "3\amsafam 0F
\mathchardef \twoheadrightarrow   "3\amsafam 10
\mathchardef \twoheadleftarrow   "3\amsafam 11
\mathchardef \leftleftarrows   "3\amsafam 12
\mathchardef \rightrightarrows   "3\amsafam 13
\mathchardef \upuparrows   "3\amsafam 14
\mathchardef \downdownarrows   "3\amsafam 15
\mathchardef \upharpoonright   "3\amsafam 16
\mathchardef \downharpoonright   "3\amsafam 17
\mathchardef \upharpoonleft   "3\amsafam 18
\mathchardef \downharpoonleft   "3\amsafam 19
\mathchardef \rightarrowtail   "3\amsafam 1A
\mathchardef \leftarrowtail   "3\amsafam 1B
\mathchardef \leftrightarrows   "3\amsafam 1C
\mathchardef \rightleftarrows   "3\amsafam 1D
\mathchardef \Lsh   "3\amsafam 1E
\mathchardef \Rsh   "3\amsafam 1F
\mathchardef \rightsquigarrow   "3\amsafam 20
\mathchardef \leftrightsquigarrow   "3\amsafam 21
\mathchardef \looparrowleft   "3\amsafam 22
\mathchardef \looparrowright   "3\amsafam 23
\mathchardef \circeq   "3\amsafam 24
\mathchardef \succsim   "3\amsafam 25
\mathchardef \gtrsim   "3\amsafam 26
\mathchardef \gtrapprox   "3\amsafam 27
\mathchardef \multimap   "3\amsafam 28
\mathchardef \therefore   "3\amsafam 29
\mathchardef \because   "3\amsafam 2A
\mathchardef \doteqdot   "3\amsafam 2B
\mathchardef \triangleq   "3\amsafam 2C
\mathchardef \precsim   "3\amsafam 2D
\mathchardef \lesssim   "3\amsafam 2E
\mathchardef \lessapprox   "3\amsafam 2F
\mathchardef \eqslantless   "3\amsafam 30
\mathchardef \eqslantgtr   "3\amsafam 31
\mathchardef \curlyeqprec   "3\amsafam 32
\mathchardef \curlyeqsucc   "3\amsafam 33
\mathchardef \preccurlyeq   "3\amsafam 34
\mathchardef \leqq   "3\amsafam 35
\mathchardef \leqslant   "3\amsafam 36
\mathchardef \lessgtr   "3\amsafam 37
\mathchardef \backprime   "0\amsafam 38
\mathchardef \risingdotseq   "3\amsafam 3A
\mathchardef \fallingdotseq   "3\amsafam 3B
\mathchardef \succcurlyeq   "3\amsafam 3C
\mathchardef \geqq   "3\amsafam 3D
\mathchardef \geqslant   "3\amsafam 3E
\mathchardef \gtrless   "3\amsafam 3F
\mathchardef \sqsubset   "3\amsafam 40
\mathchardef \sqsupset   "3\amsafam 41
\mathchardef \vartriangleright   "3\amsafam 42
\mathchardef \vartriangleleft   "3\amsafam 43
\mathchardef \trianglerighteq   "3\amsafam 44
\mathchardef \trianglelefteq   "3\amsafam 45
\mathchardef \bigstar   "0\amsafam 46
\mathchardef \between   "3\amsafam 47
\mathchardef \blacktriangledown   "0\amsafam 48
\mathchardef \blacktriangleright   "3\amsafam 49
\mathchardef \blacktriangleleft   "3\amsafam 4A
\mathchardef \vartriangle   "3\amsafam 4D
\mathchardef \blacktriangle   "0\amsafam 4E
\mathchardef \triangledown   "0\amsafam 4F
\mathchardef \eqcirc   "3\amsafam 50
\mathchardef \lesseqgtr   "3\amsafam 51
\mathchardef \gtreqless   "3\amsafam 52
\mathchardef \lesseqqgtr   "3\amsafam 53
\mathchardef \gtreqqless   "3\amsafam 54
\mathchardef \Rrightarrow   "3\amsafam 56
\mathchardef \Lleftarrow   "3\amsafam 57
\mathchardef \veebar   "2\amsafam 59
\mathchardef \barwedge   "2\amsafam 5A
\mathchardef \doublebarwedge   "2\amsafam 5B
\mathchardef \angle   "0\amsafam 5C
\mathchardef \measuredangle   "0\amsafam 5D
\mathchardef \sphericalangle   "0\amsafam 5E
\mathchardef \varpropto   "3\amsafam 5F
\mathchardef \smallsmile   "3\amsafam 60
\mathchardef \smallfrown   "3\amsafam 61
\mathchardef \Subset   "3\amsafam 62
\mathchardef \Supset   "3\amsafam 63
\mathchardef \Cup   "2\amsafam 64
\mathchardef \Cap   "2\amsafam 65
\mathchardef \curlywedge   "2\amsafam 66
\mathchardef \curlyvee   "2\amsafam 67
\mathchardef \leftthreetimes   "2\amsafam 68
\mathchardef \rightthreetimes   "2\amsafam 69
\mathchardef \subseteqq   "3\amsafam 6A
\mathchardef \supseteqq   "3\amsafam 6B
\mathchardef \bumpeq   "3\amsafam 6C
\mathchardef \Bumpeq   "3\amsafam 6D
\mathchardef \lll   "3\amsafam 6E
\mathchardef \ggg   "3\amsafam 6F
\def \ulcorner {\delimiter"4\amsafam 70\amsafam 70 }
\def \urcorner {\delimiter"5\amsafam 71\amsafam 71 }
\mathchardef \circledS   "0\amsafam 73
\mathchardef \pitchfork   "3\amsafam 74
\mathchardef \dotplus   "2\amsafam 75
\mathchardef \backsim   "3\amsafam 76
\mathchardef \backsimeq   "3\amsafam 77
\def \llcorner {\delimiter"4\amsafam 78\amsafam 78 }
\def \lrcorner {\delimiter"5\amsafam 79\amsafam 79 }
\mathchardef \complement   "0\amsafam 7B
\mathchardef \intercal   "2\amsafam 7C
\mathchardef \circledcirc   "2\amsafam 7D
\mathchardef \circledast   "2\amsafam 7E
\mathchardef \circleddash   "2\amsafam 7F
\mathchardef \rhd   "2\amsafam 42
\mathchardef \lhd   "2\amsafam 43
\mathchardef \unrhd   "2\amsafam 44
\mathchardef \unlhd   "2\amsafam 45

   \let\restriction\upharpoonright
   \let\Doteq\doteqdot
   \let\doublecup\Cup
   \let\doublecap\Cap
   \let\llless\lll
   \let\gggtr\ggg
   \let\Box=\square % LaTeX symbol
   \let\Box=\square % LaTeX symbol

%% AMSB

\mathchardef \lvertneqq   "3\amsbfam 00
\mathchardef \gvertneqq   "3\amsbfam 01
\mathchardef \nleq   "3\amsbfam 02
\mathchardef \ngeq   "3\amsbfam 03
\mathchardef \nless   "3\amsbfam 04
\mathchardef \ngtr   "3\amsbfam 05
\mathchardef \nprec   "3\amsbfam 06
\mathchardef \nsucc   "3\amsbfam 07
\mathchardef \lneqq   "3\amsbfam 08
\mathchardef \gneqq   "3\amsbfam 09
\mathchardef \nleqslant   "3\amsbfam 0A
\mathchardef \ngeqslant   "3\amsbfam 0B
\mathchardef \lneq   "3\amsbfam 0C
\mathchardef \gneq   "3\amsbfam 0D
\mathchardef \npreceq   "3\amsbfam 0E
\mathchardef \nsucceq   "3\amsbfam 0F
\mathchardef \precnsim   "3\amsbfam 10
\mathchardef \succnsim   "3\amsbfam 11
\mathchardef \lnsim   "3\amsbfam 12
\mathchardef \gnsim   "3\amsbfam 13
\mathchardef \nleqq   "3\amsbfam 14
\mathchardef \ngeqq   "3\amsbfam 15
\mathchardef \precneqq   "3\amsbfam 16
\mathchardef \succneqq   "3\amsbfam 17
\mathchardef \precnapprox   "3\amsbfam 18
\mathchardef \succnapprox   "3\amsbfam 19
\mathchardef \lnapprox   "3\amsbfam 1A
\mathchardef \gnapprox   "3\amsbfam 1B
\mathchardef \nsim   "3\amsbfam 1C
\mathchardef \ncong   "3\amsbfam 1D
\mathchardef \diagup   "0\amsbfam 1E
\mathchardef \diagdown   "0\amsbfam 1F
\mathchardef \varsubsetneq   "3\amsbfam 20
\mathchardef \varsupsetneq   "3\amsbfam 21
\mathchardef \nsubseteqq   "3\amsbfam 22
\mathchardef \nsupseteqq   "3\amsbfam 23
\mathchardef \subsetneqq   "3\amsbfam 24
\mathchardef \supsetneqq   "3\amsbfam 25
\mathchardef \varsubsetneqq   "3\amsbfam 26
\mathchardef \varsupsetneqq   "3\amsbfam 27
\mathchardef \subsetneq   "3\amsbfam 28
\mathchardef \supsetneq   "3\amsbfam 29
\mathchardef \nsubseteq   "3\amsbfam 2A
\mathchardef \nsupseteq   "3\amsbfam 2B
\mathchardef \nparallel   "3\amsbfam 2C
\mathchardef \nmid   "3\amsbfam 2D
\mathchardef \nshortmid   "3\amsbfam 2E
\mathchardef \nshortparallel   "3\amsbfam 2F
\mathchardef \nvdash   "3\amsbfam 30
\mathchardef \nVdash   "3\amsbfam 31
\mathchardef \nvDash   "3\amsbfam 32
\mathchardef \nVDash   "3\amsbfam 33
\mathchardef \ntrianglerighteq   "3\amsbfam 34
\mathchardef \ntrianglelefteq   "3\amsbfam 35
\mathchardef \ntriangleleft   "3\amsbfam 36
\mathchardef \ntriangleright   "3\amsbfam 37
\mathchardef \nleftarrow   "3\amsbfam 38
\mathchardef \nrightarrow   "3\amsbfam 39
\mathchardef \nLeftarrow   "3\amsbfam 3A
\mathchardef \nRightarrow   "3\amsbfam 3B
\mathchardef \nLeftrightarrow   "3\amsbfam 3C
\mathchardef \nleftrightarrow   "3\amsbfam 3D
\mathchardef \divideontimes   "2\amsbfam 3E
\mathchardef \varnothing   "0\amsbfam 3F
\mathchardef \nexists   "0\amsbfam 40
\mathchardef \Finv   "0\amsbfam 60
\mathchardef \Game   "0\amsbfam 61
\mathchardef \mho   "0\amsbfam 66
\mathchardef \eth   "0\amsbfam 67
\mathchardef \eqsim   "3\amsbfam 68
\mathchardef \beth   "0\amsbfam 69
\mathchardef \gimel   "0\amsbfam 6A
\mathchardef \daleth   "0\amsbfam 6B
\mathchardef \lessdot   "2\amsbfam 6C
\mathchardef \gtrdot   "2\amsbfam 6D
\mathchardef \ltimes   "2\amsbfam 6E
\mathchardef \rtimes   "2\amsbfam 6F
\mathchardef \shortmid   "3\amsbfam 70
\mathchardef \shortparallel   "3\amsbfam 71
\mathchardef \smallsetminus   "2\amsbfam 72
\mathchardef \thicksim   "3\amsbfam 73
\mathchardef \thickapprox   "3\amsbfam 74
\mathchardef \approxeq   "3\amsbfam 75
\mathchardef \precapprox   "3\amsbfam 76
\mathchardef \succapprox   "3\amsbfam 77
\mathchardef \curvearrowleft   "3\amsbfam 78
\mathchardef \curvearrowright   "3\amsbfam 79
\mathchardef \digamma   "0\amsbfam 7A
\mathchardef \varkappa   "0\amsbfam 7B
\mathchardef \Bbbk   "0\amsbfam 7C
\mathchardef \hslash   "0\amsbfam 7D
\mathchardef \hbar   "0\amsbfam 7E
\mathchardef \backepsilon   "3\amsbfam 7F

%%%  macros

\def\joinrel{\mathrel{\mkern-2.5mu}}  %-3mu in plain TeX

\let\circledplus\oplus
\let\circledminus\ominus
\let\circledtimes\otimes
\let\circledslash\oslash
\let\circleddot\odot

%%% \big, \bigg, etc.

\def\scalebig#1#2{{\left#1\vbox to#2\fontdimen6\textfont3{}%
                   \kern-\nulldelimiterspace\right.}}
\def\big#1{\scalebig{#1}{.85}}  
\def\Big#1{\scalebig{#1}{1.15}} 
\def\bigg#1{\scalebig{#1}{1.45}}
\def\Bigg#1{\scalebig{#1}{1.75}}

%%% \not redefined:

\mathchardef \notchar  "3236

\def\not#1{%
  \ifx\TeX\relax \noexpand\not \else % \let\TeX=\relax in \output routine
  \ifx #1<\nless \else
  \ifx #1>\ngtr \else
  \begingroup\escapechar=-1\xdef\tmpn{\string#1}\endgroup
  \expandafter\ifx \csname not\tmpn\endcsname \relax
     \expandafter\ifx \csname n\tmpn\endcsname \relax
         \mathrel{\mathord{\notchar}\mathord{#1}}%
     \else \csname n\tmpn\endcsname \fi
  \else \csname not\tmpn\endcsname \fi
  \fi\fi\fi}

\endinput

