% \CheckSum{180}
% \iffalse
%
% file `ibycus.dtx'.
% Copyright (c) 2004  Peter Heslin, Walter Schmidt
%
% 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 2003/12/01 or later.
%
% This work has the LPPL maintenance status "maintained".
%
% This Current Maintainers of this work are P.~Heslin and W.~Schmidt
%
% This work consists of the files 
% ibycus-babel.dtx, ibycus-babel.ins, ibyhyph.pl, 
% and the derived files 
% ibycus.ldf and ufib.fd
%
%<*driver>
\ProvidesFile{ibycus-babel.dtx}
%</driver>
%
%<ibycus>\ProvidesLanguage{ibycus}
%<ufib>\ProvidesFile{ufib.fd}%
           [2004/11/19 v2.4 (PH/WaS)]
%
%<*driver>
\documentclass{ltxdoc}    
\usepackage{url}
\OnlyDescription
\begin{document}
   \DocInput{ibycus-babel.dtx}
\end{document}
%</driver>
%
% \fi
%
% \GetFileInfo{ibycus-babel.dtx}
% \title{Typesetting ancient Greek\\ using the Ibycus fonts with the Babel system}
% \author{Peter Heslin\thanks{\texttt{p.j.heslin@dur.ac.uk}} \and Walter Schmidt\thanks{\texttt{w-a-schmidt@gmx.net}}}
% \date{\fileversion{} -- \filedate}
% \makeatletter
% \def\eTeX{$\m@th\varepsilon$-\TeX}
% \makeatother
%
% \maketitle
%
% \sloppy
%
% \section{Overview}
% The present document describes a new interface for the Ibycus fonts
% to use them in conjunction with the Babel system for multilanguage typesetting.
% It constitutes an alternative to the well-known macro packages 
% |ibycus4.sty| and |psibycus.sty|, which are distributed together with the
% fonts.  The main advantage over these packages is that automatic
% hyphenation is provided for the Greek language.  Notice, however, that 
% a \TeX\ program with the so-called \eTeX\ extensions is required.
%
% The implementation is available for \LaTeXe\ only; there are no
% corresponding macro files for plain~\TeX\ or \LaTeX~2.09.
%
%
% \section{{\boldmath Why \eTeX?}}
% With `ordinary' \TeX, 
% hyphenation of Greek words will not work properly, if the end of a mixed Greek
% and Latin-alphabet paragraph does not coincide with the end of the
% Greek.  This is due to a misfeature in \TeX: Only one set of
% so-called lccodes is used throughout the length of a paragraph -- only
% those which are valid at its end.  These codes must be adjusted for
% the Ibycus notation in order to tell \TeX\ that accents and breathings 
% a part of the words, rather than punctuation.  So if you have reverted back 
% to a Latin-written language  at the end of the paragraph, the wrong 
% codes for Greek hyphenation are in effect, and the diacritics in Greek words 
% are wrongly considered as punctuation.  
% The problem does, however, \emph{not} occur with an \eTeX\ program; i.e., a 
% \TeX\ program with certain extended capabilites.  In fact, you are
% probably already using \eTeX, even if you did not realize it.
% All up-to-date \LaTeX\ systems are now built upon an \eTeX\ typesetting
% engine, rather than on the classical \TeX\ program.
%
% \section{Usage}
% The Ibycus fonts are assigned a (pseudo-)language named |ibycus|,
% which can be used (almost) like any other language supported by
% Babel.  To enable the use of this language in your document, specify
% it as an option to the Babel package just as you would do for any
% other language.  For instance, to write a document in German with
% some Greek passages:
% \begin{verse}
%   |\usepackage[ibycus,ngerman]{babel}|
% \end{verse}
% 
% A few caveats:  Do  not declare |ibycus| as the default
% language of the document; it is not suitable for this purpose!
% In other words, |ibycus| must never be the last option for Babel.
% And, of course, do not use it together with the packages |ibycus4| 
% or |psibycus|.
%
% The language |ibycus| should be selected only locally.  Either use
% the |ibycus| environment
% to typeset larger passages of Greek text:
% \begin{verse}
%   |\begin{ibycus}                                     | \\
%   |  (Hrodo'tou Qouri'ou i(stori'hs a)po'decis h('de, | \\
%   |  ...                                              | \\
%   |  h(`n ai)ti'hn e)pole'mhsan a)llh'loisi.          | \\
%   |\end{ibycus}                                       |
% \end{verse}
% or use the command |\ibygr|, which is more appropriate for
% short pieces of Greek within Latin-written text:
% \begin{verse}
%      |blah blah \ibygr{a)rxai=a gra'mmata} blah...|
% \end{verse}
% In fact, the environment |ibycus| is nothing but an abbreviation for 
% Babel's |otherlanguage| environment with the option |ibycus|, and 
% |\ibygr{...}| is the same as |\foreignlanguage{ibycus}{...}|.
%
% Within the environment |ibycus| or the argument of |\ibygr|,
% the Ibycus-specific input notation is to be used to enter Greek.  This
% notation is described in the documentation that comes with the Ibycus
% fonts.
% 
% The typeface Ibycus and the related input notation can also be
% selected without changing the hyphenation tables; to do so, use the
% declaration |\ibycustext| or the text-generating command
% |\textibycus{...}|.  These macros exist more or less only as a
% side-effect of the implementation; they should normally not be
% needed.
%
% To switch temporarily back to the Latin alphabet within a piece of
% Greek text (without, however, changing the hyphenation table), use
% the declaration |\latintext| or the text-generating macro
% |\textlatin{...}|.  When Babel is loaded with the option |ibycus|,
% these commands not only switch back to the default latin text font
% encoding as usual; they also select the default roman font family
% (just like |\rmfamily| or |\textrm|).
%
% Notice a particular difference between |ibycus| and other languages
% of the Babel system:  Switching to the language |ibycus|  selects
% both a particular font encoding (|U|) and a particular font family (|fib|), 
% regardless of the font family that was active before. 
%
% The Ibycus typeface provides a few traditional text-editor symbols 
% for critical editions:
% 
% \begin{center}
% \begin{tabular}{ll}
% \verb+\braceleft     + & left curly brace \\
% \verb+\braceright    + & right curly brace\\
% \verb+\bracketleftbt + & left half square bracket\\
% \verb+\bracketrightbt+ & right half square bracket\\
% \verb+\sdagger       + & single dagger\\
% \verb+\dbldagger     + & double dagger\\
% \end{tabular}
% \end{center}
% Use of these symbols is not restricted to Greek
% passages.  \textbf{Caution:} 
% In the Ibycus4 package the single dagger carries the name |\dagger|.
% However, this macro belongs to the \LaTeX\ kernel and should not be redefined,
% so the name |\sdagger| is now used for the Ibycus-specific symbol.
%
% \section{Scaling the Ibycus fonts}
% The Ibycus typeface was primarily designed to go with Computer Modern;
% yet it can be used with other Latin typefaces, too.  In this case it
% may sometimes be useful to typeset the Ibycus fonts a little bit larger
% or smaller, to make them blend better with the Latin typeface.
% This can be accomplished through the macro |\setgreekfontsize|.  For instance,
% |\setgreekfontsize{1.05}| will enlarge the Ibycus fonts by 5\%, as compared
% with their nominal size.  The command can be issued in the preamble only.
%
%
% \section{The hyphenation patterns}
% The hyphenation patterns for the Ibycus encoding were
% generated by running the Perl script \path{ibyhyph.pl} on
% Dimitrios Filippou's \path{GRAhyph4.tex}, which can be found in the
% CTAN directory \path{language/hyphenation/elhyphen}.  This is an
% improved set of hyphenation patterns for ancient Greek with LGR encoding;
% Babel does not currently use it by default.  
% 
% Dimitrios Filippou's improved hyphenation patterns discover far more
% hyphenation points than the default Babel patterns, and are more
% accurate, especially for compound words.  
% You will notice that there are more hyphenation
% points right after the first letter of words beginning
% with a vowel + consonant + vowel.  Some may find such hyphenations
% surprising, but they are legal, according to the rules for hyphenation
% of Greek, ancient and modern; see the account by Yannis Haralambous:
% `From Unicode to Typography, a Case Study: the Greek Script'
% \path{<http://omega.enstb.org/yannis/pdf/boston99.pdf>}, pp~18f.
% If you find these hyphenation points ugly, issue the command
% \begin{verse}
%   |\def\ibycushyphenmins{2 2}|
% \end{verse}
% after loading of Babel in order to suppress them.
%
% Filippou's patterns also include legal hyphenation points
% immediately before the last letter of a word.  However, the
% Ibycus-Babel interface suppreses them, since they are not only ugly
% but also of little practical use.
%
% Please contact Peter Heslin if you come across any words that
% Ibycus hyphenates differently from the corresponding LGR-encoded
% patterns (except for the suppressed hyphenation before the last
% letter of a word).
%
%
% \section{Problems and deficiencies}
% \begin{itemize}
% \item  After a sequence such as
%   \begin{verse}
%   |\selectlanguage{ibycus}| \\
%   \textit{Greek text\dots}  \\
%   |\selectlanguage{|\textit{anything}|}| \\
%   \end{verse}
%   the font family is changed to the default roman typeface,
%   just as after |\rmfamily|.  This can be avoided by selecting
%   the language |ibycus| only within a group or environment,
%   or by using the commands |\ibygr| or |\foreignlanguage|.
% \item  The command |\setgreekfontscale| has no effect
%   when the Ibycus fonts are already in use;
%   this situation is, however, rather unlikely in the preamble.
% \end{itemize}
%
%
% \section{Changes since version 1.5}
% The names of several commands and environments have been changed:
%
% \begin{center}
% \begin{tabular}{ll}
% Version 1.5:                  & Version 2.4      \\ \hline
% \cmd{\gk}                     & \cmd{\ibygr}     \\
% \texttt{greek} (environment)  & \texttt{ibycus}  \\
% \cmd{\ibylatintext}           & \cmd{\latintext} \\
% \cmd{\dagger}                 & \cmd{\sdagger}
% \end{tabular}
% \end{center} 
% Furthermore, hyphenation before the last letter of a word is now
% suppressed by default.
%
% \StopEventually{}
%
%
% \section{The Implementation}
% \subsection{The \texttt{.ldf} file for use with babel}
%
% When the \TeX\ engine used is not an \eTeX, we issue an appropriate warning:
%    \begin{macrocode}
%<*ibycus>
\ifx\eTeXversion\@undefined
  \PackageError{ibycus-babel}{%
    The TeX engine used by LaTeX \MessageBreak
    does not provide the the eTeX extensions.\MessageBreak
    This may cause wrong hyphenation\MessageBreak
    in mixed Latin/Greek paragraphs}
    {Proceed, with fingers crossed...}
\fi    
%    \end{macrocode}
%
%  The macro |\LdfInit| takes care of preventing that this file is
%  loaded more than once:
%    \begin{macrocode}
\LdfInit{ibycus}{captionsibycus}
%    \end{macrocode}
%  When this file is read as an option, i.e., by the |\usepackage|
%  command, \texttt{ibycus} could be an `unknown' language in
%  which case we have to make it known.  So we check for the
%  existence of |\l@ibycus| to see whether we have to do
%  something here:
%    \begin{macrocode}
\ifx\undefined\l@ibycus
  \@nopatterns{Ibycus}
  \adddialect\l@ibycus0\fi
%    \end{macrocode}
%
% We declare a command |\ibygr| and an environment |ibycus| to make
% entering of Greek text easier, as compared with Babel's macros:
%    \begin{macrocode}
\DeclareRobustCommand{\ibygr}[1]{\foreignlanguage{ibycus}{#1}}
\newenvironment{ibycus}%
  {\begin{otherlanguage}{ibycus}}{\end{otherlanguage}}%
%    \end{macrocode}
%
% A command is provided to set a scaling factor for the Ibycus fonts.
% When the fonts are already in use, the command has no effect.
% We make sure that it can be used only in the preamble, even though this
% does not really make sure that the fonts have not yet been loaded.
%    \begin{macrocode}
\newcommand*{\setgreekfontscale}[1]{%
  \def\fib@scale{#1}}
\@onlypreamble\setgreekfontscale
%    \end{macrocode}
% The macro |\fib@scale|, which is defined here, will be evaluated
% in the file \texttt{ufib.fd}, see below.
%
% All text-editor symbols of the old package |ibycus4| are provided.
% However, |\dagger| is named |\sdagger| now.
%    \begin{macrocode}
\newcommand{\braceleft}{%
  {\fontencoding{U}\fontfamily{fib}\selectfont\char'333}}
\newcommand{\braceright}{%
  {\fontencoding{U}\fontfamily{fib}\selectfont\char'337}}
\newcommand{\bracketleftbt}{%
  {\fontencoding{U}\fontfamily{fib}\selectfont\char'363}}
\newcommand{\bracketrightbt}{%
  {\fontencoding{U}\fontfamily{fib}\selectfont\char'367}}
\newcommand{\sdagger}{%
  {\fontencoding{U}\fontfamily{fib}\selectfont\char'375}}
\newcommand{\dbldagger}{%
  {\fontencoding{U}\fontfamily{fib}\selectfont\char'376}}
%    \end{macrocode}
%
% Finally, the code to integrate the pseudo-language Ibycus into Babel.
% We start with the default values of |\lefthyphenmin| and |\righthyphenmin|.
%    \begin{macrocode}
\providehyphenmins{ibycus}{\@ne\tw@}
\def\captionsibycus{}
\def\dateibycus{}
%    \end{macrocode}
% |\latintext| needs to be changed slightly, as compared with the
% default definition from the Babel kernel.   The macro 
% must not only switch back to the default Latin font encoding;
% it must also switch back to an appropriate font \emph{family}, since the family
% is always changed to |fib| within the Greek passages.  
%    \begin{macrocode}
\DeclareRobustCommand{\latintext}{%
  \fontencoding{\latinencoding}\fontfamily{\rmdefault}\selectfont
  \def\encodingdefault{\latinencoding}}
%    \end{macrocode}
% Should we save and  restore the actual family name, 
% instead of simply forcing |\rmdefault|?
%    \begin{macrocode}
\DeclareRobustCommand{\ibycustext}{%
  \fontencoding{U}\fontfamily{fib}\selectfont
  \def\encodingdefault{U}}
\DeclareRobustCommand{\textibycus}[1]{\leavevmode{\ibycustext #1}}
\addto\extrasibycus{\ibycustext}
\addto\noextrasibycus{\latintext}
\addto\extrasibycus{%
  \babel@savevariable{\lccode`\(}\lccode`\(=`\(%
  \babel@savevariable{\lccode`\)}\lccode`\)=`\)%
  \babel@savevariable{\lccode`\=}\lccode`\==`\=%
  \babel@savevariable{\lccode`\|}\lccode`\|=`\|%
  \babel@savevariable{\lccode`\`}\lccode`\`=`\`%
  \babel@savevariable{\lccode`\'}\lccode`\'=`\'%
  \babel@savevariable{\lccode`\+}\lccode`\+=`\+}
\ldf@finish{ibycus}
%</ibycus>
%    \end{macrocode}
%
% \subsection{The \texttt{.fd} file}
% We provide a correct \texttt{fd} file of our own for the Ibycus font family,
% instead of relying on the weird file from the Ibycus4 collection,
% and we use only those fonts, that exist also in Postscript format.
%    \begin{macrocode}
%<*ufib>
\ifx\aliasfont\@undefined\else\ifx\aliasfont\relax\else
%    \end{macrocode}
% This piece of code is executed with V\TeX\ only.
% It enables the use of the artificially slanted font.
%    \begin{macrocode}
  \begingroup
    \catcode32=10 %
    \aliasfont fibo84 = fibr84 slant 167 %
  \endgroup
\fi\fi
%    \end{macrocode}
%    \begin{macrocode}
\expandafter\ifx\csname fib@scale\endcsname\relax
 \let\fib@@scale\@empty
\else
 \edef\fib@@scale{s*[\csname fib@scale\endcsname]}%
\fi
\DeclareFontFamily{U}{fib}{}
\DeclareFontShape{U}{fib}{m}{n}{<-> \fib@@scale fibr84}{}
\DeclareFontShape{U}{fib}{m}{sl}{<-> \fib@@scale fibo84}{}
\DeclareFontShape{U}{fib}{b}{n}{<-> \fib@@scale fibb84}{}
\DeclareFontShape{U}{fib}{m}{it}{<-> ssub * fib/m/sl}{}
\DeclareFontShape{U}{fib}{bx}{n}{<-> ssub * fib/b/n}{}
%</ufib>
%    \end{macrocode}
%
% \Finale
%
% \iffalse
%
% The next line of code prevents DocStrip from adding the
% character table to the generated files(s).
\endinput
%
% \fi
%
%% \CharacterTable
%%  {Upper-case    \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z
%%   Lower-case    \a\b\c\d\e\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u\v\w\x\y\z
%%   Digits        \0\1\2\3\4\5\6\7\8\9
%%   Exclamation   \!     Double quote  \"     Hash (number) \#
%%   Dollar        \$     Percent       \%     Ampersand     \&
%%   Acute accent  \'     Left paren    \(     Right paren   \)
%%   Asterisk      \*     Plus          \+     Comma         \,
%%   Minus         \-     Point         \.     Solidus       \/
%%   Colon         \:     Semicolon     \;     Less than     \<
%%   Equals        \=     Greater than  \>     Question mark \?
%%   Commercial at \@     Left bracket  \[     Backslash     \\
%%   Right bracket \]     Circumflex    \^     Underscore    \_
%%   Grave accent  \`     Left brace    \{     Vertical bar  \|
%%   Right brace   \}     Tilde         \~}
%%
