\NeedsTeXFormat{LaTeX2e}
\def\fileversion{1.05}
\def\filedate{2020/09/28}
\ProvidesPackage{algolrevived}
    [\filedate\space v\fileversion]
\message{'algolrevived' v\fileversion, \filedate\space  Style file for AlgolRevived fonts (msharpe).}

\RequirePackage[LY1,T1]{fontenc}
\RequirePackage{textcomp}
\RequirePackage{xstring,ifthen,scalefnt}
\RequirePackage{ifthen}
\DeclareEncodingSubset{TS1}{AlgolRevived-*}{0}
\IfFileExists{mweights.sty}{\RequirePackage{mweights}}{}
\IfFileExists{fontaxes.sty}{
    \RequirePackage{fontaxes}
    \fa@naming@exception{figures}{{superior}{proportional}}{Sup}
    \fa@naming@exception{figures}{{superior}{tabular}}{Sup}
    \def\sufigures{\@nomath\sufigures
        \fontfigurestyle{superior}\selectfont}
    \DeclareTextFontCommand{\textsu}{\sufigures}
    \let\textsuperior\textsu

    \fa@naming@exception{figures}{{inferior}{proportional}}{Inf}
    \fa@naming@exception{figures}{{inferior}{tabular}}{Inf}
    \def\infigures{\@nomath\infigures
        \fontfigurestyle{inferior}\selectfont}
    \DeclareTextFontCommand{\textinf}{\infigures}
    \let\textinferior\textinf
}{}
\def\zal@foresolidus{0em}
\def\zal@aftsolidus{0em}
%\def\zal@zslash{1} % slashed zero is default in tt mode
\IfFileExists{xkeyval.sty}{
    \newcommand*{\AlgolRevived@scale}{1}
    \RequirePackage{xkeyval}
    \DeclareOptionX{scale}{\renewcommand*{\AlgolRevived@scale}{##1}}
    \DeclareOptionX{scaled}{\renewcommand*{\AlgolRevived@scale}{##1}}
}{
    \let\DeclareOptionX\DeclareOption
    \let\ExecuteOptionsX\ExecuteOptions
    \let\ProcessOptionsX\ProcessOptions
}
\edef\mdseries@rm{sb}
\edef\mdseries@rm{m}

\edef\zal@figurestyle{TLF}
\def\useosf{\edef\zal@figurestyle{OsF}}
\@onlypreamble\useosf

\newif\ifzal@tt
\newif\ifzal@hyphens
\newif\ifzal@xhyphens
\newif\ifzal@xnohyphens
\newif\ifzal@zslash
\DeclareOptionX{tt}{\zal@tttrue}
\DeclareOptionX{hyphens}{\zal@xhyphenstrue}
\DeclareOptionX{nohyphens}{\zal@xnohyphenstrue}
\DeclareOptionX{zeroslash}{\zal@zslashtrue}%\edef\zal@zslash{1}
\DeclareOptionX{nozeroslash}{\zal@zslashfalse}%\edef\zal@zslash{0}
\DeclareOptionX{lining}{\edef\zal@figurestyle{TLF}}
\DeclareOptionX{lf}{\edef\zal@figurestyle{TLF}}
\DeclareOptionX{oldstyle}{\useosf}
\DeclareOptionX{osf}{\useosf}
\DeclareOptionX{foresolidus}{\gdef\zal@foresolidus{#1}}
\DeclareOptionX{aftsolidus}{\gdef\zal@aftsolidus{#1}}
\ExecuteOptionsX{zeroslash}
\ProcessOptionsX\relax

\ifzal@tt%
  \ifzal@xhyphens\zal@hyphenstrue\fi
  \edef\zal@zslash{1}
  \ifzal@zslash\else\edef\zal@zslash{0}\fi
  \edef\zal@figurestyle{TLF} % no osf in tt mode
\else % text mode
% \edef\zal@zslash{0}
%\ifzal@zslash\else\edef\zal@zslash{1}\fi
 \zal@hyphenstrue % default is hyphens in text mode
 \ifzal@xnohyphens\zal@hyphensfalse\fi % unless turned off in options
 \newcommand{\textfrac}[3][]{% like \textfrac[1]{7}{8}
  \mbox{%
    \ifthenelse{\not\equal{#1}{}}%Test for integer portion [optional #1]
      {\textlf{#1}\kern.05em}{}%         
    \raise -.1em\hbox{\textsu{#2}}% numerator
    \StrRight{#2}{1}[\@digit@]%
    % look for  1, 2, 6, 7
    \ifcase\@digit@\kern-.02em% 0
    \or\kern.03em% 1
    \or\kern.03em% 2
    \or%\kern-.01em% 3
    \or\kern.05em% 4
    \or\kern-.01em% 5
    \or\kern-.02em% 6
    \or\kern-.14em% 7
    \or%\kern-.01em% 8
    \or\kern-.02em% 9
   \fi%
    \kern\zal@foresolidus{\fontencoding{TS1}\selectfont\char"2F}%
    \kern\zal@aftsolidus%
    \StrLeft{#3}{1}[\@digit@]%
    % look for 1, 4, 7
    \ifcase\@digit@% 0
    \or\kern -.03em% 1
    \or\kern-.02em% 2
    \or\kern-.03em% 3
    \or\kern -.06em% 4
    \or% 5
    \or% 6
    \or\kern .02em% 7
    \fi%
    \raise .15em\hbox{\textinf{#3}}%       denominator [#3]
  }%
}
\fi 

\DeclareRobustCommand{\lfstyle}{%
  \not@math@alphabet\lfstyle\relax
  \fontfamily{AlgolRevived-TLF}\selectfont %
}
\DeclareRobustCommand{\tlfstyle}{%
  \not@math@alphabet\tlfstyle\relax
  \fontfamily{AlgolRevived-TLF}\selectfont %
}% to get tlf
\DeclareRobustCommand{\osfstyle}{%
  \not@math@alphabet\osfstyle\relax
  \fontfamily{AlgolRevived-OsF}\selectfont %
}% to get osf
\DeclareRobustCommand{\tosfstyle}{%
  \not@math@alphabet\tosfstyle\relax
  \fontfamily{AlgolRevived-OsF}\selectfont %
}% to get tosf
\DeclareRobustCommand{\textlf}[1]{%
  {\lfstyle #1}%
}% to get lf
\DeclareRobustCommand{\texttlf}[1]{%
  {\tlfstyle #1}%
}% to get tlf
\DeclareRobustCommand{\textosf}[1]{%
  {\osfstyle #1}%
}% to get osf
\DeclareRobustCommand{\texttosf}[1]{%
  {\tosfstyle #1}%
}% to get tosf
\DeclareTextCommand{\textcircled}{TS1}[1]{\hmode@bgroup
   \ooalign{%
      \hfil \raise .307ex\hbox {\fontencoding{T1}\fontfamily{AlgolRevived-TLF}\fontseries{m}\fontshape{n}\selectfont\scalefont{.6}%
\uppercase{#1}}\hfil \crcr
     \char 79 %\textbigcircle 
   }%
 \egroup}

\def\zal@typewriter{} % do not prevent hyphenation
\ifzal@hyphens\else\def\zal@typewriter{\hyphenchar\font=-1}\fi
%\show\zal@typewriter


%Added textcomp symbols
\DeclareTextSymbolDefault{\textprime}{TS1}          
\DeclareTextSymbolDefault{\textdprime}{TS1}
\DeclareTextSymbolDefault{\textleftrightarrow}{TS1}
\DeclareTextSymbolDefault{\textupdownarrow}{TS1}
\DeclareTextSymbolDefault{\textLeftarrow}{TS1}
\DeclareTextSymbolDefault{\textUparrow}{TS1}
\DeclareTextSymbolDefault{\textRightarrow}{TS1}
\DeclareTextSymbolDefault{\textDownarrow}{TS1}
\DeclareTextSymbolDefault{\textLeftrightarrow}{TS1}
\DeclareTextSymbolDefault{\textUpdownarrow}{TS1}
\DeclareTextSymbolDefault{\textforall}{TS1}
\DeclareTextSymbolDefault{\textcomplement}{TS1}
\DeclareTextSymbolDefault{\textpartial}{TS1}
\DeclareTextSymbolDefault{\textexists}{TS1}
\DeclareTextSymbolDefault{\textnexists}{TS1}
\DeclareTextSymbolDefault{\textvarnothing}{TS1}
\DeclareTextSymbolDefault{\textincrement}{TS1}
\DeclareTextSymbolDefault{\textnabla}{TS1}
\DeclareTextSymbolDefault{\textin}{TS1}
\DeclareTextSymbolDefault{\textnotin}{TS1}
\DeclareTextSymbolDefault{\textsmallin}{TS1}
\DeclareTextSymbolDefault{\textni}{TS1}
\DeclareTextSymbolDefault{\textnni}{TS1}
\DeclareTextSymbolDefault{\textsmallni}{TS1}
\DeclareTextSymbolDefault{\textsmallsetminus}{TS1}
\DeclareTextSymbolDefault{\textlargebullet}{TS1}
\DeclareTextSymbolDefault{\textland}{TS1}
\DeclareTextSymbolDefault{\textlor}{TS1}
\DeclareTextSymbolDefault{\textcap}{TS1}
\DeclareTextSymbolDefault{\textcup}{TS1}
\DeclareTextSymbolDefault{\textcoloneq}{TS1}
\DeclareTextSymbolDefault{\texteqcolon}{TS1}
\DeclareTextSymbolDefault{\textneq}{TS1}
\DeclareTextSymbolDefault{\textequiv}{TS1}
\DeclareTextSymbolDefault{\textneqiv}{TS1}
\DeclareTextSymbolDefault{\textleq}{TS1}
\DeclareTextSymbolDefault{\textgeq}{TS1}
\DeclareTextSymbolDefault{\textsubset}{TS1}
\DeclareTextSymbolDefault{\textsupset}{TS1}
\DeclareTextSymbolDefault{\textnsubset}{TS1}
\DeclareTextSymbolDefault{\textnsupset}{TS1}
\DeclareTextSymbolDefault{\textsubseteq}{TS1}
\DeclareTextSymbolDefault{\textsupseteq}{TS1}
\DeclareTextSymbolDefault{\textnsubseteq}{TS1}
\DeclareTextSymbolDefault{\textnsupseteq}{TS1}
\DeclareTextSymbolDefault{\textsqsubset}{TS1}
\DeclareTextSymbolDefault{\textsqsubset}{TS1}
\DeclareTextSymbolDefault{\textsqsupset}{TS1}
\DeclareTextSymbolDefault{\textsqsubseteq}{TS1}
\DeclareTextSymbolDefault{\textsqcap}{TS1}
\DeclareTextSymbolDefault{\textsqcup}{TS1}
%
\DeclareTextSymbol{\textprime}{TS1}{192}           
\DeclareTextSymbol{\textdprime}{TS1}{193}
\DeclareTextSymbol{\textleftrightarrow}{TS1}{196}
\DeclareTextSymbol{\textupdownarrow}{TS1}{197}
\DeclareTextSymbol{\textLeftarrow}{TS1}{198}
\DeclareTextSymbol{\textUparrow}{TS1}{199}
\DeclareTextSymbol{\textRightarrow}{TS1}{200}
\DeclareTextSymbol{\textDownarrow}{TS1}{201}
\DeclareTextSymbol{\textLeftrightarrow}{TS1}{202}
\DeclareTextSymbol{\textUpdownarrow}{TS1}{203}
\DeclareTextSymbol{\textforall}{TS1}{204}
\DeclareTextSymbol{\textcomplement}{TS1}{205}
\DeclareTextSymbol{\textpartial}{TS1}{206}
\DeclareTextSymbol{\textexists}{TS1}{207}
\DeclareTextSymbol{\textnexists}{TS1}{208}
\DeclareTextSymbol{\textvarnothing}{TS1}{209}
\DeclareTextSymbol{\textincrement}{TS1}{210}
\DeclareTextSymbol{\textnabla}{TS1}{211}
\DeclareTextSymbol{\textin}{TS1}{212}
\DeclareTextSymbol{\textnotin}{TS1}{213}
\DeclareTextSymbol{\textsmallin}{TS1}{215}
\DeclareTextSymbol{\textni}{TS1}{216}
\DeclareTextSymbol{\textnni}{TS1}{217}
\DeclareTextSymbol{\textsmallni}{TS1}{218}
\DeclareTextSymbol{\textsmallsetminus}{TS1}{219}
\DeclareTextSymbol{\textlargebullet}{TS1}{220}
\DeclareTextSymbol{\textland}{TS1}{221}
\DeclareTextSymbol{\textlor}{TS1}{222}
\DeclareTextSymbol{\textcap}{TS1}{224}
\DeclareTextSymbol{\textcup}{TS1}{225}
\DeclareTextSymbol{\textcoloneq}{TS1}{226}
\DeclareTextSymbol{\texteqcolon}{TS1}{227}
\DeclareTextSymbol{\textneq}{TS1}{228}
\DeclareTextSymbol{\textequiv}{TS1}{229}
\DeclareTextSymbol{\textneqiv}{TS1}{230}
\DeclareTextSymbol{\textleq}{TS1}{231}
\DeclareTextSymbol{\textgeq}{TS1}{232}
\DeclareTextSymbol{\textsubset}{TS1}{233}
\DeclareTextSymbol{\textsupset}{TS1}{234}
\DeclareTextSymbol{\textnsubset}{TS1}{235}
\DeclareTextSymbol{\textnsupset}{TS1}{236}
\DeclareTextSymbol{\textsubseteq}{TS1}{237}
\DeclareTextSymbol{\textsupseteq}{TS1}{238}
\DeclareTextSymbol{\textnsubseteq}{TS1}{239}
\DeclareTextSymbol{\textnsupseteq}{TS1}{240}
\DeclareTextSymbol{\textsqsubset}{TS1}{241}
\DeclareTextSymbol{\textsqsubset}{TS1}{242}
\DeclareTextSymbol{\textsqsupset}{TS1}{243}
\DeclareTextSymbol{\textsqsubseteq}{TS1}{244}
\DeclareTextSymbol{\textsqcap}{TS1}{245}
\DeclareTextSymbol{\textsqcup}{TS1}{247}

\ifzal@tt
  \renewcommand*{\ttdefault}{AlgolRevived-\zal@figurestyle-TT}
\else
  \renewcommand*{\rmdefault}{AlgolRevived-\zal@figurestyle}
  \renewcommand*{\familydefault}{\rmdefault}
\fi
\normalfont
\endinput
