\ProvidesPackage{ean13isbn}[2021/01/24 EAN13 with ISBN]
\PackageInfo{ean13isbn}{$Id: ean13isbn.sty 550 2021-01-23 23:47:58Z zw $\@gobble}

%% Copyright 2008, 2021 Z. Wagner, http://icebearsoft.euweb.cz
%
% This work may be distributed and/or modified under the
% conditions of the LaTeX Project Public License, either version 1.3
% of this license or (at your option) any later version.
% The latest version of this license is in
%   http://www.latex-project.org/lppl.txt
% and version 1.3 or later is part of all distributions of LaTeX
% version 2005/12/01 or later.
%
% This work has the LPPL maintenance status `maintained'.
% 
% The Current Maintainer of this work is Z. Wagner.
%
% This work consists of the files: ean13isbn.sty and
% the documentation files ean13isbn.tex, ean13isbn.pdf.

\def\zw@setean#1#2{\def\zw@scale{#1 }\def\zw@xm{#2mm }}

\RequirePackage{kvoptions}
\SetupKeyvalOptions{family=zwean,prefix=zwean@}
\DeclareStringOption{ISBN}
\DeclareVoidOption{help}{\typeout{\zwean@table}}

\def\zw@set #1 #2 #3 {\ifnum#2<1000 \let\zw@maybespace\space \else \def\zw@maybespace{}\fi
    \edef\zwean@table{\zwean@table^^J\zw@maybespace #2 0#3mm => SC#1}%
    \DeclareVoidOption{SC#1}{\zw@setean{#2}{#3}}}

\def\zw@tbline{^^J======================}
\def\zwean@table{\zw@tbline ^^J\space Mag \space Module\space \space \space \space Option\zw@tbline}

\zw@set 0 800 .264
\zw@set 0a 818 .270
\zw@set 0b 850 .281
\zw@set 1 900 .297
\zw@set 1a 950 .313
\zw@set 2 1000 .330
\zw@set 2a 1050 .346
\zw@set 3 1100 .363
\zw@set 3a 1150 .379
\zw@set 4 1200 .396
\zw@set 4a 1250 .412
\zw@set 5 1300 .429
\zw@set 5a 1350 .445
\zw@set 5b 1400 .462
\zw@set 5c 1450 .478
\zw@set 6 1500 .495
\zw@set 6a 1550 .511
\zw@set 7 1600 .528
\zw@set 7a 1650 .544
\zw@set 7b 1700 .561
\zw@set 7c 1750 .577
\zw@set 8 1800 .594
\zw@set 8a 1850 .610
\zw@set 8b 1900 .627
\zw@set 8c 1950 .643
\zw@set 9 2000 .660
\zw@set 10 2120 .700

\edef\zwean@table{\zwean@table \zw@tbline}

\setkeys{zwean}{SC2}

\InputIfFileExists{./ean13isbn.cfg}{}{}

\ProcessKeyvalOptions*

\expandafter\ifx\csname mubytein\endcsname\relax
  \let\zw@mubytein\relax
\else
  \edef\zw@mubytein{\noexpand\mubytein\the\mubytein}\mubytein0
\fi
\input{ean13}
\zw@mubytein

\newdimen\zw@isbnfsize
\newbox\zw@test@box

\def\zw@eansetup@params{\X\zw@xm
  \font\ocrb ocrb9 scaled \zw@scale
  \zw@isbnfsize 9.6pt
  \ifnum\zw@scale<1000
    \zw@isbnfsize .\zw@scale\zw@isbnfsize
  \fi
  \ifnum\zw@scale>1000
    \def\zw@next##1##2##3##4.{\zw@isbnfsize ##1.##2##3##4\zw@isbnfsize}
    \expandafter\zw@next\zw@scale.
  \fi
  \def\zw@isbnfont{\usefont{OT1}{phv}{c}{n}\fontsize{\zw@isbnfsize}{\zw@isbnfsize}\selectfont}
    \setbox\zw@test@box=\hbox{\zw@isbnfont0}%
    \ifdim\wd\zw@test@box>.65\ht\zw@test@box
      \def\zw@isbnfont{\usefont{OT1}{phv}{mc}{n}\fontsize{\zw@isbnfsize}{\zw@isbnfsize}\selectfont}
    \fi}
\zw@eansetup@params

\def\zw@EANisbn{\def\ISBNnum{\let\ocrbsmall\relax
    \hbox to 96\X{\zw@isbnfont \kern .5\X ISBN\hss \zwean@ISBN}}\barheight=45.151515\X\relax
    \expandafter\EAN \zwean@ISBN}

\def\EANisbn{\@ifnextchar[\zw@eanwitharg\zw@EANisbn}

\def\zw@eanwitharg{\begingroup \catcode`\-12 \zw@eanarg}
\def\zw@eanarg[#1]{\setkeys{zwean}{#1}\zw@eansetup@params\zw@EANisbn\endgroup}

\def\EANsetup{\begingroup \catcode`\-12 \zw@eansetup}
\def\zw@eansetup#1{\endgroup \setkeys{zwean}{#1}\zw@eansetup@params}

\def\ISBN{ISBN \zwean@ISBN}
