% \iffalse -*- doctex -*-
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%                                                                      %%
%%                        Package ot1patch                              %%
%%                                                                      %%
%% Purpose: to provide best possible substitutes for Polish national    %%
%%          characters using OT1 Computer Modern Roman fonts            %%
%%                                                                      %%
%%                                                                      %%
%% Copyright (c) by Marcin Woli\'nski                      <1997/06/18> %%
%%                  [email protected]                                %%
%%                                                                      %%
%%                                                                      %%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%                                                                      %%
%% The package may be used freely, but you are not allowed to modify    %%
%% this file.  If you wish to make any changes please make a copy       %%
%% under a different name.                                              %%
%%                                                                      %%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% \fi
 \def\fileversion{v 0.3}
 \def\docdate{1997/05/16}
 \def\filedate{1997/10/08}
% \CheckSum{209}
%
% \title{Pakiet/Package ot1patch\thanks
%          {Version \fileversion\ dated \filedate.}}
% \author{Marcin Woli\'nski}
% \date{\docdate}
%
% \maketitle
% Celem tego pakietu jest dostarczenie substytut\'{o}w polskich
% znak\'{o}w narodowych, zbudowanych jedynie ze znak\'{o}w
% dost\k{e}pnych w fontach w uk{\l}adzie OT1, szczeg\'{o}lnie fontach
% Computer Modern.  Poniewa\.{z} wysokiej jako\'{s}ci polskie fonty
% dla \TeX a s\k{a} publicznie dost\k{e}pne, stosowanie tego pakietu
% nie jest zalecane.  Mo\.{z}na go poleci\'c jedynie mieszka\'{n}com
% bezludnych wysp bez dost\k{e}pu do Internetu (ale sk\k{a}d oni mieli
% by mie\'c ten pakiet?).
%
% Pakiet zosta{\l} pomy\'{s}lany jako dodatek do pakietu \textsf{Po
% polsku} autorstwa Mariusza Olko.  Mo\.{z}na go jednak stosowa\'c
% niezale\.{z}nie.  Skutkiem zadeklarowania jego u\.{z}ycia
% komend\k{a} |\usepackage{ot1patch}| jest zmiana definicji
% niekt\'{o}rych komend akcentowych w uk{\l}adzie OT1
% (w~szczeg\'{o}lno\'{s}ci komenda |\k| produkuj\k{a}ca ogonek,
% przestaje powodowa\'c b{\l}\k{a}d).  Uk{\l}ad OT1 nie jest w istocie
% dobrze okre\'{s}lony, bowiem fonty ,,maszynowe'' r\'{o}\.{z}ni\k{a}
% si\k{e} od pozosta{\l}ych na kilku pozycjach.  \textsf{ot1patch}
% troszczy si\k{e} i o t\k{e} spraw\k{e}.
%
% Pakiet \textsf{ot1patch} w istocie jest adaptacj\k{a} do nowego
% \LaTeX a stylu \textsf{plfonts.sty} autorstwa Leszka Holenderskiego.
% Styl ten jest najstaranniejsz\k{a} znan\k{a} mi wersj\k{a}
% dorobienia protez ogonk\'{o}w do font\'{o}w Computer Modern.
%
% \bigskip
% The purpose of this package is to provide substitutes of Polish
% national characters built using only old fonts (OT1). Besides of
% producing characters missing from OT1 this package takes care of
% less obvious matter: OT1 is not a really well-defined encoding since
% typewritter fonts differ from others in some positions.
%
% The package is loaded in the standard way with the
% |\usepackage{ot1patch}| command.
%
% \StopEventually{}
%
% \section{Implementation}
% \iffalse
% Since I hate the presence of section `Printing the documentation' in
% every DOCed package my driver is put into a metacomment.  To print
% documentation LaTeX this file. If you need to change the driver run
% DOCSTRIP and ask it to make ogonek.drv by stripping ogonek.dtx with
% option `driver'. Do *not* modify this file.
%<*driver>
\documentclass{ltxdoc}
\usepackage{ot1patch}
\DisableCrossrefs
%<driver>%\OnlyDescription
%<driver>%\EnableCrossrefs
%<driver>%\CodeLinesIndex
\begin{document}
 \DocInput{ot1patch.dtx}
\end{document}
%</driver>
% \fi
%
% \subsection{Identification}
% We start the code with standard identification of the package
%    \begin{macrocode}
%<*package>
\NeedsTeXFormat{LaTeX2e}[1994/12/01]
\ProvidesPackage{ot1patch}[\filedate\space\fileversion\space
                    A patch for some OT1 characters (MW)]
%    \end{macrocode}
%
% \subsection{The \texttt{\string\k} macro (Polish ogonek)}
% This comes from L.~Holenderski's \texttt{plfonts.sty}.
% Positioning of ogonek for specific letters is tuned for 300dpi
% Computer Modern fonts, but works reasonably well with other
% resolutions.
%
% Ogonek is made from half-circle used by \TeX\ to produce
% $\hookrightarrow$.
% \begin{macro}{\@sob}
% Macro |\@sob| positioning ogonek under a letter.   Parameters are
% letter and fractions hl,ho,vl,vo.
%    \begin{macrocode}
\dimendef\pl@left=0 \dimendef\pl@down=1
\dimendef\pl@right=2 \dimendef\pl@temp=3
\def\@sob#1#2#3#4#5{%
 \setbox0\hbox{#1}\setbox1\hbox{$_\mathchar'454$}\setbox2\hbox{p}%
 \pl@right=#2\wd0 \advance\pl@right by-#3\wd1
 \pl@down=#5\ht1 \advance\pl@down by-#4\ht0
 \pl@left=\pl@right \advance\pl@left by\wd1
 \pl@temp=-\pl@down \advance\pl@temp by\dp2 \dp1=\pl@temp
 \leavevmode
 \kern\pl@right\lower\pl@down\box1\kern-\pl@left #1}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\@iIuUogonek}
% \begin{macro}{\k}
% Here is the |\k| default macro (it is not normally defined in OT1), with
% special positioning of ogonek for some letters. We don't do this with
% |\DeclareTextCompositeCommand| because it wouldn't fit with the defaults
% mechanism.
%    \begin{macrocode}
\def\@iIuUogonek#1{%
       \ifx i#1\@sob i{.66}{.20}{0}{.90}\else
       \ifx I#1\@sob I{.80}{.50}{0}{.90}\else
       \ifx u#1\@sob u{.66}{.20}{0}{.90}\else
       \ifx U#1\@sob U{.60}{.35}{0}{.90}\else
       \@sob {#1}{.50}{.35}{0}{.90}\fi
       \fi \fi \fi
       }
\DeclareTextCommandDefault\k[1]{%
       \ifx a#1\@sob a{.66}{.20}{0}{.90}\else
       \ifx A#1\@sob A{.80}{.50}{0}{.90}\else
       \ifx e#1\@sob e{.50}{.35}{0}{.93}\else
       \ifx E#1\@sob E{.60}{.35}{0}{.90}\else
       \@iIuUogonek{#1}%
       \fi \fi \fi \fi
  }
%    \end{macrocode}
% \end{macro}
% \end{macro}
%
% \subsection{Polish crossed l}
% Since in typewritter fonts there is no cross character for Polish \l\ we
% will have to take special actions then. For that purpose we define the
% next macro. It performs a rather devious check if the font in use is
% `typewritter like'. Regular text fonts contain in position '40 the cross
% for Polish \l, but in typewritter `visible space' occurs there. Second
% of these characters has positive depth, contrary to the first, so we
% check for that. This is slow, better check is welcome.
%
%    \begin{macrocode}
\def\if@ttfont#1#2{\setbox0=\hbox{\char'40}\ifdim\dp0>0pt#1\else#2\fi}
%    \end{macrocode}
%
% \begin{macro}{\@spb}
% This definition is used to cross l or L in typewritter fonts.
% \changes{0.2}{1997/06/07}{Added leavevmode}
%    \begin{macrocode}
\def\@spb#1#2#3#4#5{%
 \setbox0\hbox{#1}\setbox2\hbox{\char'023}%
 \pl@right=#2\wd0 \advance\pl@right by-#3\wd2
 \pl@down=#5\ht2 \advance\pl@down by-#4\ht0
 \pl@left=\pl@right \advance\pl@left by\wd2
 \ht2=\pl@down \dp2=-\pl@down
 \leavevmode
 \kern\pl@right\lower\pl@down\box2\kern-\pl@left #1}
%    \end{macrocode}
% \end{macro}
%
%    And here are definitions of |\l| and |\L|. Unfortunately we have
%    to redefine \LaTeX's values.
%    \begin{macrocode}
\DeclareTextCommand\l{OT1}{%
 \if@ttfont{\@spb l{.45}{.5}{.4}{.8}}%
   {{\char32l}}}
\DeclareTextCommand\L{OT1}{%
 \if@ttfont{\@spb L{.23}{.5}{.4}{.8}}%
   {\leavevmode\setbox0\hbox{L}\hbox to\wd0{\hss\char32L}}}
%    \end{macrocode}
%
% \subsection{Dot accent}
% \begin{macro}{\@skb}
%    \changes{0.2}{1997/06/07}{Added leavevmode}
%    Typewritter fonts don't contain the dot accent so we use raised
%    period instead.  As this style is prepared with Polish language
%    in mind, this is done for \.z only.
%    \begin{macrocode}
\def\@skb#1#2#3#4#5{%
 \setbox0\hbox{#1}\setbox1\hbox{\char'056}%
 \pl@right=#2\wd0 \advance\pl@right by-#3\wd1
 \pl@down=#5\ht1 \advance\pl@down by-#4\ht0
 \pl@left=\pl@right \advance\pl@left by\wd1
 \leavevmode
 \kern\pl@right\lower\pl@down\box1\kern-\pl@left #1}
%    \end{macrocode}
%  \end{macro}
%
%    And appropriate redefinition for |\.|:
%    \begin{macrocode}
\DeclareTextCompositeCommand\.{OT1}z{%
 \if@ttfont{\@skb z{.5}{.5}{1.2}{0}}%
   {{\accent'137z}}}
\DeclareTextCompositeCommand\.{OT1}Z{%
 \if@ttfont{\@skb Z{.5}{.5}{1.1}{0}}%
   {{\accent'137Z}}}
%    \end{macrocode}
%
% \subsection{French quotes
%             (\guillemotleft guillemotes\guillemotright)}
% \changes{0.2}{1997/06/18}{Added \cs{leavevmode}}
%    Here is the best substitute for guillemotes we could think of.
%    \begin{macrocode}
\DeclareTextCommandDefault\guillemotleft
   {\leavevmode\raise.3ex
       \hbox{$\scriptscriptstyle\langle\!\langle$}}
\DeclareTextCommandDefault\guillemotright
   {\leavevmode\raise.3ex
       \hbox{$\scriptscriptstyle\rangle\!\rangle$}}
%    \end{macrocode}
%
% And that's all.
%    \begin{macrocode}
\endinput
%</package>
%    \end{macrocode}
%
%
% \Finale