% lgrxenc.def
% ***********
%
% comprehensive LGR Greek font encoding definitions
% =================================================
%
% :Copyright: © 2010 Günter Milde
% :Licence:   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 any later version.
%
% :Abstract:  The LGR font encoding is the de-facto standard for Greek
%             typesetting with LaTeX. However, the encoding definition
%             file that ships with babel misses many of the definitions
%             common since the advent of the NFSS (see fntguide_ "Encodings").
%
%             This file provides a comprehensive set of macros to
%             typeset Greek with LGR encoded fonts. It works for both,
%             monotonic and polytonic Greek, independent of the `babel`
%             package.
%
%  This package is part of the lgrx_ bundle.
%
% .. contents::
%
%
% Changelog
% ---------
%
% .. class:: borderless
%
% ===== ============  ====================================================
% 0.1   2010-03-31    initial attempt
% 0.2   2010-04-20    diacritics dropped in UPPERCASE
% 0.3   2010-06-08    handle Titlecase and UPPERCASE extending
%                     ``\@uclclist``
% 0.3.1 2010-06-10    code cleanup: replace dummy accent hack
%                     with TextCommand
% 0.4   2010-06-15    more text symbols
% 0.4.1 2010-08-06    prevent multiple evaluation
% 0.5   2010-08-27    support ``\textalpha`` ... ``\textOmega``
% 0.5.1 2012-05-08    upload to CTAN
% 0.6   2012-06-29    ``\TextGreek`` wrapper command (used in lgrenc.dfu),
%                     aliases for ``puenc.def`` compatibility
% ===== ============  ====================================================
%
% Usage
% -----
%
% To prevent confusion with Babel_'s rudimentary ``lgrenc.def``, this file is
% named ``lgrxenc.def``. Load it by calling fontenc_ with the ``LGRx`` option
% or indirectly via the textalpha_ or alphabeta_ packages.
%
% Example:
%   Select font encodings `T1` (as default) and `LGR` (with the comprehensive
%   font encoding definitions)
%
%     ``\usepackage[LGRx,T1]{fontenc}``
%
% .. Attention:: The name of the font encoding defined by the option ``LGRx``
%    is **not** `LGRx` but `LGR`. Therefore, ``LGRx`` must not be the
%    last option (as fontenc uses the last option to select the default font
%    encoding). To set `LGR` as as default font encoding specify both,
%    `LGRx` and `LGR`, e.g.
%
%       ``\usepackage[LGRx,T1,LGR]{fontenc}``
%
%
% Macro names
% -----------
%
% The fntguide_ (section 6.4 Naming conventions) recommends:
%
%   Where possible, text symbols should be named as ``\text`` followed
%   by the Adobe glyph name: for example ``\textonequarter`` or
%   ``\textsterling``. Similarly, math symbols should be named as
%   ``\math`` followed by the glyph name, for example
%   ``\mathonequarter`` or ``\mathsterling``.
%
% Open questions:
%
% * Can we omit the ``text`` prefix for macros that are already
%   established in short form (e.g. via babel's ``greek.ldf``) and do
%   not have a math counterpart?
%
%   Pro:
%     + Simpler.
%
%     + Ease of use (less typing, better readability of source text).
%
%     + Backwards compatible (many established macro names).
%
%     + There are examples of encoding-specific macros
%       without the ``text``-prefix, especially for letters:
%
%       * ``\AE \DH \DJ \L \NG \OE \O \SS \TH \ae \dh \dj \guillemotleft``
%         ``\guillemotright \guilsinglleft \guilsinglright \i \j \l \ng``
%         ``\oe \o \quotedblbase \quotesinglbase \ss \th``
%         in `T1` and `OT1`,
%       * ``\CYR*`` and ``\cyr*`` in `T2*`
%       * ``\heb*`` or no prefix in `HE8`
%       * short descriptive names in the arabic part of `PU`
%         (``puarenc.def``) (but e.g. ``\textkoppagreek`` in
%         ``puenc.def``)
%
%     + ``text`` prefix does **not** mark a macro as
%
%       * encoding-specific
%       * inserting a glyph
%
%       as there are e.g. font-changing macros (``\textbf``, ``\textit``)
%       and encoding-changing macros (``\textgreek``, ``\textcyr``).
%
%
%   Contra:
%     - Less consistent.
%
%     - ``text`` prefix marks a macro as confined to text mode
%
%     - Short forms can be defined in a package.
%
% * How to name *accent macros* (``\DeclareTextAccent`` definitions)?
%
%   - Should ``\texttonos`` be an accent macro or a spacing character?
%
%   - How about a common prefix ``\accent...`` or postfix ``\...Accent``?
%
%
% * How about glyph names with numbers and dots?
%
%   - Adobe recommends ``uni`` (or ``u``) + Unicode number for all
%     Unicode characters without established name.
%
%     While it is *possible* to apply this scheme to TeX macros, it is
%     hardly advisable: ``\koppa`` is far better readable than
%     ``\csname uni03DF\endcsname``.
%
% * If there exists a math-mode macro for a symbol, the corresponding text
%   macro should be formed by prepending ``text``.
%
%     Example: The glyph name for the final sigma is ``sigma1``, but the
%     corresponding math-macro is ``\varsigma``. IMO, the text symbol
%     should be available as ``\textvarsigma`` and not
%     ``\csname textsigma1\endcsname``.
%
%   Could this become a general rule?
%
%   Problems:
%     * ``\varepsilon`` and ``\varphi`` math macros map to "GREEK SMALL
%       LETTER \*", while others map to "GREEK * SYMBOL" Unicode chars.
%
%
% The `Adobe Glyph List For New Fonts`_ has names for many glyphs in the
% `Greek and Coptic` Unicode block, but not for `Greek extended`.
%
% An alternative, more complete set of short mnemonic character names is
% the `XML Entity Definitions for Characters`_ W3C Recommendation from
% 01 April 2010.
%
% For glyph names of the LGR encoding see e.g. ``CB.enc`` by Apostolos
% Syropoulos and ``xl-lgr.enc`` from the libertine_ (legacy) package.
% ``lgr.cmap`` provides a mapping to Unicode characters.
%
% A full set of ``\text*`` symbol macros is defined in ``ucsencs.def``
% from the ucs_ package.
%
% Using the names from ``puenc.def`` ensures that the hyperref_ package
% will do the right conversion to a PDF-string
% (see `<greek-part-of-puenc.def>`_).
%
% For accent macros, this file uses Greek names like in Unicode and
% ucsencs.def (without ``text`` prefix). Accent macro names are Capitalized or
% CamelCase, as they are intended for use in packages or classes. For the
% end-user "symbol macros" (``\~ \' \` \" \< \>``) are provided.
%
%
% Implementation
% --------------
%
% Read this file only once
% ~~~~~~~~~~~~~~~~~~~~~~~~
% .. note:: The use of ``\@ifundefined`` has the side-effect that the tested
%    macro becomes defined and set to ``\relax`` (polluting the namespace and
%    interfering with test via eTeX's ``\ifdefined``). However, in this case
%    no harm is done as the macro is defined by the identification_ below
%    anyway.
%
% ::

\@ifundefined{ver@lgrxenc.def}
  {\message{setting up comprehensive LGR font encoding definitions.}}
  {\message{comprehensive LGR font encoding definitions already loaded}
   \expandafter\endinput % "return"
  }

% Identification
% ~~~~~~~~~~~~~~
% ::

\ProvidesFile{lgrxenc.def}
         [2012/07/03 v0.6 %
          comprehensive LGR Greek Font Encoding definitions]


% Base setup
% ~~~~~~~~~~
%
% Declare the font encoding and substitutions.
% (from the file ``lgrenc.def`` that comes with the Babel package)::

\DeclareFontEncoding{LGR}{}{}
\DeclareFontSubstitution{LGR}{cmr}{m}{n}
\DeclareErrorFont{LGR}{cmr}{m}{n}{10}

% The ``\TextGreek`` command can be used to ensure that its argument is set in
% a font encoding with support for Greek. If the font encoding is already LGR,
% kerning between adjacent command calls (e.g.
% ``\TextGreek{A}\TextGreek{\Upsilon}``) is preserved. This allows wrapping of
% compound Unicode character definitions. ::

\DeclareTextCommand{\TextGreek}{LGR}[1]{#1}


% Text symbols
% ~~~~~~~~~~~~
%
% Greek Alphabet
% """"""""""""""
%
% Greek letters are accessible by the Latin transcription, but the mapping is
% specific to the LGR font encoding.
%
% The ``\text*`` macros provide a way to access the symbols in any font
% encoding supporting Greek independent of the specific font encoding.
% Alternative Greek font encodings are LGI (ibycus_) and PU (`PDF Unicode`
% used by hyperref_ for PDF metadata). The `textalpha.sty` package makes these
% macros available in any font encoding.
% ::

\DeclareTextSymbol{\textAlpha}{LGR}{65}
\DeclareTextSymbol{\textBeta}{LGR}{66}
\DeclareTextSymbol{\textGamma}{LGR}{71}
\DeclareTextSymbol{\textDelta}{LGR}{68}
\DeclareTextSymbol{\textEpsilon}{LGR}{69}
\DeclareTextSymbol{\textZeta}{LGR}{90}
\DeclareTextSymbol{\textEta}{LGR}{72}
\DeclareTextSymbol{\textTheta}{LGR}{74}
\DeclareTextSymbol{\textIota}{LGR}{73}
\DeclareTextSymbol{\textKappa}{LGR}{75}
\DeclareTextSymbol{\textLambda}{LGR}{76}
\DeclareTextSymbol{\textMu}{LGR}{77}
\DeclareTextSymbol{\textNu}{LGR}{78}
\DeclareTextSymbol{\textXi}{LGR}{88}
\DeclareTextSymbol{\textOmicron}{LGR}{79}
\DeclareTextSymbol{\textPi}{LGR}{80}
\DeclareTextSymbol{\textRho}{LGR}{82}
\DeclareTextSymbol{\textSigma}{LGR}{83}
\DeclareTextSymbol{\textTau}{LGR}{84}
\DeclareTextSymbol{\textUpsilon}{LGR}{85}
\DeclareTextSymbol{\textPhi}{LGR}{70}
\DeclareTextSymbol{\textChi}{LGR}{81}
\DeclareTextSymbol{\textPsi}{LGR}{89}
\DeclareTextSymbol{\textOmega}{LGR}{87}
%
\DeclareTextSymbol{\textalpha}{LGR}{97}
\DeclareTextSymbol{\textbeta}{LGR}{98}
\DeclareTextSymbol{\textgamma}{LGR}{103}
\DeclareTextSymbol{\textdelta}{LGR}{100}
\DeclareTextSymbol{\textepsilon}{LGR}{101}
\DeclareTextSymbol{\textzeta}{LGR}{122}
\DeclareTextSymbol{\texteta}{LGR}{104}
\DeclareTextSymbol{\texttheta}{LGR}{106}
\DeclareTextSymbol{\textiota}{LGR}{105}
\DeclareTextSymbol{\textkappa}{LGR}{107}
\DeclareTextSymbol{\textlambda}{LGR}{108}
\DeclareTextSymbol{\textmu}{LGR}{109}
\DeclareTextSymbol{\textnu}{LGR}{110}
\DeclareTextSymbol{\textxi}{LGR}{120}
\DeclareTextSymbol{\textomicron}{LGR}{111}
\DeclareTextSymbol{\textpi}{LGR}{112}
\DeclareTextSymbol{\textrho}{LGR}{114}
\DeclareTextCommand{\textsigma}{LGR}{s\noboundary} % σ
\DeclareTextSymbol{\textvarsigma}{LGR}{99}         % ς final sigma
\DeclareTextSymbol{\textautosigma}{LGR}{115}       % σ (ς at end of word)
\DeclareTextSymbol{\texttau}{LGR}{116}
\DeclareTextSymbol{\textupsilon}{LGR}{117}
\DeclareTextSymbol{\textphi}{LGR}{102}
\DeclareTextSymbol{\textchi}{LGR}{113}
\DeclareTextSymbol{\textpsi}{LGR}{121}
\DeclareTextSymbol{\textomega}{LGR}{119}


% Additional Greek symbols
% """"""""""""""""""""""""
%
% Ancient Greek Numbers (Athenian Numerals)
% '''''''''''''''''''''''''''''''''''''''''
%
% Names from the athnum_ package::

\DeclareTextSymbol{\PiDelta}{LGR}{2} % GREEK ACROPHONIC ATTIC FIFTY
\DeclareTextSymbol{\PiEta}{LGR}{3}   % GREEK ACROPHONIC ATTIC FIVE HUNDRED
\DeclareTextSymbol{\PiChi}{LGR}{4}   % GREEK ACROPHONIC ATTIC FIVE THOUSAND
\DeclareTextSymbol{\PiMu}{LGR}{5}    % GREEK ACROPHONIC ATTIC FIFTY THOUSAND

% Names from ``xl-lgr.enc`` (Greek numerals)::

\DeclareTextSymbol{\pentedeka}{LGR}{2}    % GREEK ACROPHONIC ATTIC FIFTY
\DeclareTextSymbol{\pentehekaton}{LGR}{3} % GREEK ACROPHONIC ATTIC FIVE HUNDRED
\DeclareTextSymbol{\penteqilioi}{LGR}{4}  % GREEK ACROPHONIC ATTIC FIVE THOUSAND
\DeclareTextSymbol{\pentemurioi}{LGR}{5}  % GREEK ACROPHONIC ATTIC FIFTY THOUSAND


% Archaic letters
% '''''''''''''''
% Names after babel_'s ``greek.ldf``, teubner_ and hyperref_'s puenc.def::

\DeclareTextSymbol{\stigma}{LGR}{6}           % ϛ (greek.df, teubner)
\DeclareTextSymbol{\textstigmagreek}{LGR}{6}  % ϛ (puenc.def)
\DeclareTextSymbol{\varstigma}{LGR}{7}        % stigma variant (CB.enc, teubner)
% \DeclareTextSymbol{\vardigamma}{LGR}{7}     % digamma variant (greek.ldf)
\DeclareTextSymbol{\koppa}{LGR}{18}           % ϟ (greek small letter koppa)
\DeclareTextSymbol{\textkoppagreek}{LGR}{18}  % ϟ (puenc.def)
\DeclareTextSymbol{\qoppa}{LGR}{19}           % ϙ (archaic koppa)
\DeclareTextSymbol{\Qoppa}{LGR}{21}           % Ϙ (archaic Koppa)
\DeclareTextSymbol{\Stigma}{LGR}{22}          % ϹΤ ligature (teubner)
\DeclareTextSymbol{\textStigmagreek}{LGR}{22} % ϹΤ ligature (puenc.def)
% \DeclareTextSymbol{\Stigma}{LGR}{??}        % Ϛ
\DeclareTextSymbol{\Sampi}{LGR}{23}           % Ϡ
\DeclareTextSymbol{\textSampigreek}{LGR}{23}  % Ϡ (puenc.def)
\DeclareTextSymbol{\sampi}{LGR}{27}           % ϡ
\DeclareTextSymbol{\textsampigreek}{LGR}{27}  % ϡ (puend.def)
\DeclareTextSymbol{\anoteleia}{LGR}{38}       % ·
\DeclareTextSymbol{\erotimatiko}{LGR}{63}     % ;
% \digamma used by amsmath for math-macro:
\DeclareTextSymbol{\ddigamma}{LGR}{147}         % ϝ (greek.ldf)
\DeclareTextSymbol{\Digamma}{LGR}{195}          % Ϝ (greek.ldf)
\DeclareTextSymbol{\textdigamma}{LGR}{147}      % ϝ with "text" prefix
\DeclareTextSymbol{\textDigamma}{LGR}{195}      % Ϝ with "text" prefix
\DeclareTextSymbol{\textdigammagreek}{LGR}{147} % ϝ (puenc.def)
\DeclareTextSymbol{\textDigammagreek}{LGR}{195} % Ϝ (puenc.def)


% numeral signs
% '''''''''''''
% See also http://en.wikipedia.org/wiki/Greek_numerals
%
% Names from babel_ and teubner_::

\DeclareTextSymbol{\anwtonos}{LGR}{254}     % ʹ (Dexia keraia)
\DeclareTextSymbol{\katwtonos}{LGR}{255}    % ͵ (Aristeri keraia)

% alias names for compatibility with hyperref's puenc.def::

\DeclareTextSymbol{\textnumeralsigngreek}{LGR}{254}
\DeclareTextSymbol{\textnumeralsignlowergreek}{LGR}{255}


% Other
% """""
%
% Characters that also exist in other font encodings
%
% * Define them for LGR if there is a matching glyph,
%   so that they work if LGR is the only chosen font encoding.
%
% * Use established macro names that match with other ``*enc.def`` files and
%   ``textcomp.sty``.
%
% ::

% all encodings: See usrguide.pdf, chapter 3.14 ff
\DeclareTextSymbol{\textendash}{LGR}{0}          % EN DASH
\DeclareTextSymbol{\textquoteleft}{LGR}{28}      % ‘
\DeclareTextSymbol{\textquoteright}{LGR}{29}     % ’
\DeclareTextSymbol{\textperiodcentered}{LGR}{46} % · = \textanoteleia
\DeclareTextSymbol{\textcompwordmark}{LGR}{118}  % ZERO WIDTH NO JOINER
\DeclareTextSymbol{\textemdash}{LGR}{127}        % EM DASH

% T1
\DeclareTextSymbol{\guillemotleft}{LGR}{123}     % «
\DeclareTextSymbol{\guillemotright}{LGR}{125}    % »

% TS1
\ProvideTextCommand{\textasciibreve}{LGR}{\char30\textcompwordmark}    % ˘
\ProvideTextCommand{\textasciimacron}{LGR}{\char31\textcompwordmark}   % ¯
\ProvideTextCommand{\textasciidieresis}{LGR}{\char34\textcompwordmark} % "
\ProvideTextCommand{\textasciiacute}{LGR}{\char39\textcompwordmark}    % '
\ProvideTextCommand{\textasciigrave}{LGR}{\char96\textcompwordmark}    % `
\DeclareTextCommand{\textasciitilde}{LGR}{\char126\textcompwordmark}   % ~
% \DeclareTextSymbol{\textohm}{LGR}{87}          % Ω (Ohm sign ≠ Omega)
\DeclareTextSymbol{\texteuro}{LGR}{24}           % € \euro in greek.ldf
\DeclareTextSymbol{\textpercent}{LGR}{37}        % %
\DeclareTextSymbol{\textperthousand}{LGR}{25}    % ‰ \permille in greek.ldf

% T3
\DeclareTextSymbol{\textschwa}{LGR}{26}          % ə

% Babel's ``lgrenc.def`` has some definitions to prevent surprises with
% macros that expect a Latin script. These definitions are problematic
% in the font-encoding definition file as they
%
% * require ``\textlatin`` which is defined in ``babel.def``,
%
% * overwrite TS1 symbols set as default by ``textcomp.sty``.
%
% ::

%\ProvideTextCommand{\textcopyright}{LGR}{\textcircled{\textlatin{c}}}
%\ProvideTextCommand{\textregistered}{LGR}{\textcircled{\textlatin{\textsc r}}}
%\ProvideTextCommand{\texttrademark}{LGR}{\textsuperscript{\textlatin{TM}}}
%\ProvideTextCommand{\SS}{LGR}{\textlatin{SS}}

% How about::

%\ProvideTextCommand{\SS}{LGR}{\UseTextSymbol{T1}{\SS}}
%\ProvideTextCommand{\textcopyright}{LGR}{{\UseTextSymbol{T1}{\textcopyright}}}
% ...?

% Diacritics
% ~~~~~~~~~~
%
% Based on the teubner_ package by Claudio Beccari and the `babel
% patch`_ by Werner Lemberg but with composite diacritic definitions
% (iterative diacritics).
%
% Advantages:
%
% * get accented characters without resorting to the
%   ligature mechanism (allows proper kerning, cf. teubner-doc_).
% * reduced probability of incompatibilities (compared to teubner_
%   diacritic macros).
% * input convention similar to LGR input encodings (just prepend a ``\``).
%
% simple diacritics
% """""""""""""""""
%
% Define Greek diacritics as named macros with shortcut alias.
%
% Direct defining of ``\<`` and ``\>`` fails with
% ```! Missing $ inserted.'`` (clash with math definitions).
% Also, we need aliases for proper upcasing (cf. `UPPERCASE`_ below). ::

\DeclareTextAccent{\Dasia}{LGR}{60} % δασεῖα spiritus asper (rough breathing)
\DeclareTextAccent{\Psili}{LGR}{62} % ψιλή spiritus lenis (smooth breathing)
\DeclareTextAccent{\Tonos}{LGR}{39} % τόνος/ὀξεῖα tonos/oxia (acute)
\DeclareTextAccent{\Varia}{LGR}{96} % βαρεῖα (grave)
\DeclareTextAccent{\Perispomeni}{LGR}{126} % περισπωμένη (circonflex/tilde)
\DeclareTextAccent{\Dialytika}{LGR}{34} % διαλυτικά (diaeresis/trema)

\DeclareTextCommand{\<}{LGR}{\Dasia}
\DeclareTextCommand{\>}{LGR}{\Psili}
\DeclareTextCommand{\'}{LGR}{\Tonos}
\DeclareTextCommand{\`}{LGR}{\Varia}
\DeclareTextCommand{\~}{LGR}{\Perispomeni}
\DeclareTextCommand{\"}{LGR}{\Dialytika}

% These are not required as the postfix ligature
% does not interfere with kerning::

\DeclareTextSymbol{\Ypogegrammeni}{LGR}{124} % "small" sub-iota
\DeclareTextSymbol{\Prosgegrammeni}{LGR}{8}  % "capital" sub-iota

% for critical editions or classical Greek::

\DeclareTextAccent{\lowbreve}{LGR}{20} %   low breve
\DeclareTextAccent{\u}{LGR}{30} % breve
\DeclareTextAccent{\=}{LGR}{31} % macron

% The characters at position 16 and 17 are used in the ``\nexus`` macro
% of the teubner_ package to form an extensible, hat-like bracket. In
% ``CB.enc``, they are mapped to
%
%   16--MODIFIER LETTER LOW ACUTE ACCENT
%   17--MODIFIER LETTER LOW GRAVE ACCENT
%
% but according to the documentation of Werner Lemberg's `babel patch`_,
% they rather represent the left and right part of U+23E0 TOP TORTOISE
% SHELL BRACKET.
%
%
% composite diacritics
% """"""""""""""""""""
%
% Definitions::

%                  Unicode Name                     Teubner name
\DeclareTextAccent{\DasiaOxia}{LGR}{86}            % Ar
\DeclareTextAccent{\DasiaVaria}{LGR}{67}           % Gr
\DeclareTextAccent{\DasiaPerispomeni}{LGR}{64}     % Cr

\DeclareTextAccent{\PsiliOxia}{LGR}{94}            % As
\DeclareTextAccent{\PsiliVaria}{LGR}{95}           % Gs
\DeclareTextAccent{\PsiliPerispomeni}{LGR}{92}     % Cs

\DeclareTextAccent{\DialytikaTonos}{LGR}{35}       % Ad, tonos/oxia
\DeclareTextAccent{\DialytikaVaria}{LGR}{36}       % Gd
\DeclareTextAccent{\DialytikaPerispomeni}{LGR}{32} % Cd

% Composition from simple diacritics
% (the composition with simple "transcription characters" is done for
% the shortcut marcros, otherwise it fails with ``\Makeuppercase``)::

\DeclareTextCompositeCommand{\Dialytika}{LGR}{\Tonos}{\DialytikaTonos}
\DeclareTextCompositeCommand{\"}{LGR}{'}{\DialytikaTonos}
\DeclareTextCompositeCommand{\"}{LGR}{\'}{\DialytikaTonos}
\DeclareTextCompositeCommand{\Dialytika}{LGR}{\Varia}{\DialytikaVaria}
\DeclareTextCompositeCommand{\"}{LGR}{`}{\DialytikaVaria}
\DeclareTextCompositeCommand{\"}{LGR}{\`}{\DialytikaVaria}
\DeclareTextCompositeCommand{\Dialytika}{LGR}{\Perispomeni}{\DialytikaPerispomeni}
\DeclareTextCompositeCommand{\"}{LGR}{~}{\DialytikaPerispomeni}
\DeclareTextCompositeCommand{\"}{LGR}{\~}{\DialytikaPerispomeni}

\DeclareTextCompositeCommand{\Tonos}{LGR}{\Dialytika}{\DialytikaTonos}
\DeclareTextCompositeCommand{\'}{LGR}{"}{\DialytikaTonos}
\DeclareTextCompositeCommand{\'}{LGR}{\"}{\DialytikaTonos}
\DeclareTextCompositeCommand{\Tonos}{LGR}{\Dasia}{\DasiaOxia}
\DeclareTextCompositeCommand{\'}{LGR}{<}{\DasiaOxia}
\DeclareTextCompositeCommand{\'}{LGR}{\<}{\DasiaOxia}
\DeclareTextCompositeCommand{\Tonos}{LGR}{\Psili}{\PsiliOxia}
\DeclareTextCompositeCommand{\'}{LGR}{>}{\PsiliOxia}
\DeclareTextCompositeCommand{\'}{LGR}{\>}{\PsiliOxia}

\DeclareTextCompositeCommand{\Varia}{LGR}{\Dialytika}{\DialytikaVaria}
\DeclareTextCompositeCommand{\`}{LGR}{"}{\DialytikaVaria}
\DeclareTextCompositeCommand{\`}{LGR}{\"}{\DialytikaVaria}
\DeclareTextCompositeCommand{\Varia}{LGR}{\Dasia}{\DasiaVaria}
\DeclareTextCompositeCommand{\`}{LGR}{<}{\DasiaVaria}
\DeclareTextCompositeCommand{\`}{LGR}{\<}{\DasiaVaria}
\DeclareTextCompositeCommand{\Varia}{LGR}{\Psili}{\PsiliVaria}
\DeclareTextCompositeCommand{\`}{LGR}{>}{\PsiliVaria}
\DeclareTextCompositeCommand{\`}{LGR}{\>}{\PsiliVaria}

\DeclareTextCompositeCommand{\Perispomeni}{LGR}{\Dialytika}{\DialytikaPerispomeni}
\DeclareTextCompositeCommand{\~}{LGR}{"}{\DialytikaPerispomeni}
\DeclareTextCompositeCommand{\~}{LGR}{\"}{\DialytikaPerispomeni}
\DeclareTextCompositeCommand{\Perispomeni}{LGR}{\Dasia}{\DasiaPerispomeni}
\DeclareTextCompositeCommand{\~}{LGR}{<}{\DasiaPerispomeni}
\DeclareTextCompositeCommand{\~}{LGR}{\<}{\DasiaPerispomeni}
\DeclareTextCompositeCommand{\Perispomeni}{LGR}{\Psili}{\PsiliPerispomeni}
\DeclareTextCompositeCommand{\~}{LGR}{>}{\PsiliPerispomeni}
\DeclareTextCompositeCommand{\~}{LGR}{\>}{\PsiliPerispomeni}

\DeclareTextCompositeCommand{\Psili}{LGR}{\Tonos}{\PsiliOxia}
\DeclareTextCompositeCommand{\>}{LGR}{'}{\PsiliOxia}
\DeclareTextCompositeCommand{\>}{LGR}{\'}{\PsiliOxia}
\DeclareTextCompositeCommand{\Psili}{LGR}{\Varia}{\PsiliVaria}
\DeclareTextCompositeCommand{\>}{LGR}{`}{\PsiliVaria}
\DeclareTextCompositeCommand{\>}{LGR}{\`}{\PsiliVaria}
\DeclareTextCompositeCommand{\Psili}{LGR}{\Perispomeni}{\PsiliPerispomeni}
\DeclareTextCompositeCommand{\>}{LGR}{~}{\PsiliPerispomeni}
\DeclareTextCompositeCommand{\>}{LGR}{\~}{\PsiliPerispomeni}

\DeclareTextCompositeCommand{\Dasia}{LGR}{\Tonos}{\DasiaOxia}
\DeclareTextCompositeCommand{\<}{LGR}{'}{\DasiaOxia}
\DeclareTextCompositeCommand{\<}{LGR}{\'}{\DasiaOxia}
\DeclareTextCompositeCommand{\Dasia}{LGR}{\Varia}{\DasiaVaria}
\DeclareTextCompositeCommand{\<}{LGR}{`}{\DasiaVaria}
\DeclareTextCompositeCommand{\<}{LGR}{\`}{\DasiaVaria}
\DeclareTextCompositeCommand{\Dasia}{LGR}{\Perispomeni}{\DasiaPerispomeni}
\DeclareTextCompositeCommand{\<}{LGR}{~}{\DasiaPerispomeni}
\DeclareTextCompositeCommand{\<}{LGR}{\~}{\DasiaPerispomeni}

% Pre-composed letters with diacritics
% (from teubner_ with changed names of the composite accents)::

\DeclareTextComposite{\Varia}{LGR}{a}{128}
\DeclareTextComposite{\Dasia}{LGR}{a}{129}
\DeclareTextComposite{\Psili}{LGR}{a}{130}
\DeclareTextComposite{\DasiaVaria}{LGR}{a}{131}
\DeclareTextComposite{\Tonos}{LGR}{a}{136}
\DeclareTextComposite{\DasiaOxia}{LGR}{a}{137}
\DeclareTextComposite{\PsiliOxia}{LGR}{a}{138}
\DeclareTextComposite{\PsiliVaria}{LGR}{a}{139}
\DeclareTextComposite{\Perispomeni}{LGR}{a}{144}
\DeclareTextComposite{\DasiaPerispomeni}{LGR}{a}{145}
\DeclareTextComposite{\PsiliPerispomeni}{LGR}{a}{146}
\DeclareTextComposite{\Varia}{LGR}{h}{152}
\DeclareTextComposite{\Dasia}{LGR}{h}{153}
\DeclareTextComposite{\Psili}{LGR}{h}{154}
\DeclareTextComposite{\Tonos}{LGR}{h}{160}
\DeclareTextComposite{\DasiaOxia}{LGR}{h}{161}
\DeclareTextComposite{\PsiliOxia}{LGR}{h}{162}
\DeclareTextComposite{\DasiaVaria}{LGR}{h}{163}
\DeclareTextComposite{\Perispomeni}{LGR}{h}{168}
\DeclareTextComposite{\DasiaPerispomeni}{LGR}{h}{169}
\DeclareTextComposite{\PsiliPerispomeni}{LGR}{h}{170}
\DeclareTextComposite{\PsiliVaria}{LGR}{h}{171}
\DeclareTextComposite{\Varia}{LGR}{w}{176}
\DeclareTextComposite{\Dasia}{LGR}{w}{177}
\DeclareTextComposite{\Psili}{LGR}{w}{178}
\DeclareTextComposite{\DasiaVaria}{LGR}{w}{179}
\DeclareTextComposite{\Tonos}{LGR}{w}{184}
\DeclareTextComposite{\DasiaOxia}{LGR}{w}{185}
\DeclareTextComposite{\PsiliOxia}{LGR}{w}{186}
\DeclareTextComposite{\PsiliVaria}{LGR}{w}{187}
\DeclareTextComposite{\Perispomeni}{LGR}{w}{192}
\DeclareTextComposite{\DasiaPerispomeni}{LGR}{w}{193}
\DeclareTextComposite{\PsiliPerispomeni}{LGR}{w}{194}
\DeclareTextComposite{\Varia}{LGR}{i}{200}
\DeclareTextComposite{\Dasia}{LGR}{i}{201}
\DeclareTextComposite{\Psili}{LGR}{i}{202}
\DeclareTextComposite{\DasiaVaria}{LGR}{i}{203}
\DeclareTextComposite{\Tonos}{LGR}{i}{208}
\DeclareTextComposite{\DasiaOxia}{LGR}{i}{209}
\DeclareTextComposite{\PsiliOxia}{LGR}{i}{210}
\DeclareTextComposite{\PsiliVaria}{LGR}{i}{211}
\DeclareTextComposite{\Perispomeni}{LGR}{i}{216}
\DeclareTextComposite{\DasiaPerispomeni}{LGR}{i}{217}
\DeclareTextComposite{\PsiliPerispomeni}{LGR}{i}{218}
\DeclareTextComposite{\Dialytika}{LGR}{i}{240}
\DeclareTextComposite{\DialytikaVaria}{LGR}{i}{241}
\DeclareTextComposite{\DialytikaTonos}{LGR}{i}{242}
\DeclareTextComposite{\DialytikaPerispomeni}{LGR}{i}{243}
\DeclareTextComposite{\Varia}{LGR}{u}{204}
\DeclareTextComposite{\Dasia}{LGR}{u}{205}
\DeclareTextComposite{\Psili}{LGR}{u}{206}
\DeclareTextComposite{\DasiaVaria}{LGR}{u}{207}
\DeclareTextComposite{\Tonos}{LGR}{u}{212}
\DeclareTextComposite{\DasiaOxia}{LGR}{u}{213}
\DeclareTextComposite{\PsiliOxia}{LGR}{u}{214}
\DeclareTextComposite{\PsiliVaria}{LGR}{u}{215}
\DeclareTextComposite{\Perispomeni}{LGR}{u}{220}
\DeclareTextComposite{\DasiaPerispomeni}{LGR}{u}{221}
\DeclareTextComposite{\PsiliPerispomeni}{LGR}{u}{222}
\DeclareTextComposite{\Dialytika}{LGR}{u}{244}
\DeclareTextComposite{\DialytikaVaria}{LGR}{u}{245}
\DeclareTextComposite{\DialytikaTonos}{LGR}{u}{246}
\DeclareTextComposite{\DialytikaPerispomeni}{LGR}{u}{247}
\DeclareTextComposite{\Varia}{LGR}{e}{224}
\DeclareTextComposite{\Dasia}{LGR}{e}{225}
\DeclareTextComposite{\Psili}{LGR}{e}{226}
\DeclareTextComposite{\DasiaVaria}{LGR}{e}{227}
\DeclareTextComposite{\Tonos}{LGR}{e}{232}
\DeclareTextComposite{\DasiaOxia}{LGR}{e}{233}
\DeclareTextComposite{\PsiliOxia}{LGR}{e}{234}
\DeclareTextComposite{\PsiliVaria}{LGR}{e}{235}
\DeclareTextComposite{\Varia}{LGR}{o}{228}
\DeclareTextComposite{\Dasia}{LGR}{o}{229}
\DeclareTextComposite{\Psili}{LGR}{o}{230}
\DeclareTextComposite{\DasiaVaria}{LGR}{o}{231}
\DeclareTextComposite{\Tonos}{LGR}{o}{236}
\DeclareTextComposite{\DasiaOxia}{LGR}{o}{237}
\DeclareTextComposite{\PsiliOxia}{LGR}{o}{238}
\DeclareTextComposite{\PsiliVaria}{LGR}{o}{239}
\DeclareTextComposite{\Dasia}{LGR}{r}{251}
\DeclareTextComposite{\Psili}{LGR}{r}{252}

% Do the same for the ``\text*`` macros::

\DeclareTextComposite{\Varia}{LGR}{\textalpha}{128}
\DeclareTextComposite{\Dasia}{LGR}{\textalpha}{129}
\DeclareTextComposite{\Psili}{LGR}{\textalpha}{130}
\DeclareTextComposite{\DasiaVaria}{LGR}{\textalpha}{131}
\DeclareTextComposite{\Tonos}{LGR}{\textalpha}{136}
\DeclareTextComposite{\DasiaOxia}{LGR}{\textalpha}{137}
\DeclareTextComposite{\PsiliOxia}{LGR}{\textalpha}{138}
\DeclareTextComposite{\PsiliVaria}{LGR}{\textalpha}{139}
\DeclareTextComposite{\Perispomeni}{LGR}{\textalpha}{144}
\DeclareTextComposite{\DasiaPerispomeni}{LGR}{\textalpha}{145}
\DeclareTextComposite{\PsiliPerispomeni}{LGR}{\textalpha}{146}
\DeclareTextComposite{\Varia}{LGR}{\texteta}{152}
\DeclareTextComposite{\Dasia}{LGR}{\texteta}{153}
\DeclareTextComposite{\Psili}{LGR}{\texteta}{154}
\DeclareTextComposite{\Tonos}{LGR}{\texteta}{160}
\DeclareTextComposite{\DasiaOxia}{LGR}{\texteta}{161}
\DeclareTextComposite{\PsiliOxia}{LGR}{\texteta}{162}
\DeclareTextComposite{\DasiaVaria}{LGR}{\texteta}{163}
\DeclareTextComposite{\Perispomeni}{LGR}{\texteta}{168}
\DeclareTextComposite{\DasiaPerispomeni}{LGR}{\texteta}{169}
\DeclareTextComposite{\PsiliPerispomeni}{LGR}{\texteta}{170}
\DeclareTextComposite{\PsiliVaria}{LGR}{\texteta}{171}
\DeclareTextComposite{\Varia}{LGR}{\textomega}{176}
\DeclareTextComposite{\Dasia}{LGR}{\textomega}{177}
\DeclareTextComposite{\Psili}{LGR}{\textomega}{178}
\DeclareTextComposite{\DasiaVaria}{LGR}{\textomega}{179}
\DeclareTextComposite{\Tonos}{LGR}{\textomega}{184}
\DeclareTextComposite{\DasiaOxia}{LGR}{\textomega}{185}
\DeclareTextComposite{\PsiliOxia}{LGR}{\textomega}{186}
\DeclareTextComposite{\PsiliVaria}{LGR}{\textomega}{187}
\DeclareTextComposite{\Perispomeni}{LGR}{\textomega}{192}
\DeclareTextComposite{\DasiaPerispomeni}{LGR}{\textomega}{193}
\DeclareTextComposite{\PsiliPerispomeni}{LGR}{\textomega}{194}
\DeclareTextComposite{\Varia}{LGR}{\textiota}{200}
\DeclareTextComposite{\Dasia}{LGR}{\textiota}{201}
\DeclareTextComposite{\Psili}{LGR}{\textiota}{202}
\DeclareTextComposite{\DasiaVaria}{LGR}{\textiota}{203}
\DeclareTextComposite{\Tonos}{LGR}{\textiota}{208}
\DeclareTextComposite{\DasiaOxia}{LGR}{\textiota}{209}
\DeclareTextComposite{\PsiliOxia}{LGR}{\textiota}{210}
\DeclareTextComposite{\PsiliVaria}{LGR}{\textiota}{211}
\DeclareTextComposite{\Perispomeni}{LGR}{\textiota}{216}
\DeclareTextComposite{\DasiaPerispomeni}{LGR}{\textiota}{217}
\DeclareTextComposite{\PsiliPerispomeni}{LGR}{\textiota}{218}
\DeclareTextComposite{\Dialytika}{LGR}{\textiota}{240}
\DeclareTextComposite{\DialytikaVaria}{LGR}{\textiota}{241}
\DeclareTextComposite{\DialytikaTonos}{LGR}{\textiota}{242}
\DeclareTextComposite{\DialytikaPerispomeni}{LGR}{\textiota}{243}
\DeclareTextComposite{\Varia}{LGR}{\textupsilon}{204}
\DeclareTextComposite{\Dasia}{LGR}{\textupsilon}{205}
\DeclareTextComposite{\Psili}{LGR}{\textupsilon}{206}
\DeclareTextComposite{\DasiaVaria}{LGR}{\textupsilon}{207}
\DeclareTextComposite{\Tonos}{LGR}{\textupsilon}{212}
\DeclareTextComposite{\DasiaOxia}{LGR}{\textupsilon}{213}
\DeclareTextComposite{\PsiliOxia}{LGR}{\textupsilon}{214}
\DeclareTextComposite{\PsiliVaria}{LGR}{\textupsilon}{215}
\DeclareTextComposite{\Perispomeni}{LGR}{\textupsilon}{220}
\DeclareTextComposite{\DasiaPerispomeni}{LGR}{\textupsilon}{221}
\DeclareTextComposite{\PsiliPerispomeni}{LGR}{\textupsilon}{222}
\DeclareTextComposite{\Dialytika}{LGR}{\textupsilon}{244}
\DeclareTextComposite{\DialytikaVaria}{LGR}{\textupsilon}{245}
\DeclareTextComposite{\DialytikaTonos}{LGR}{\textupsilon}{246}
\DeclareTextComposite{\DialytikaPerispomeni}{LGR}{\textupsilon}{247}
\DeclareTextComposite{\Varia}{LGR}{\textepsilon}{224}
\DeclareTextComposite{\Dasia}{LGR}{\textepsilon}{225}
\DeclareTextComposite{\Psili}{LGR}{\textepsilon}{226}
\DeclareTextComposite{\DasiaVaria}{LGR}{\textepsilon}{227}
\DeclareTextComposite{\Tonos}{LGR}{\textepsilon}{232}
\DeclareTextComposite{\DasiaOxia}{LGR}{\textepsilon}{233}
\DeclareTextComposite{\PsiliOxia}{LGR}{\textepsilon}{234}
\DeclareTextComposite{\PsiliVaria}{LGR}{\textepsilon}{235}
\DeclareTextComposite{\Varia}{LGR}{\textomicron}{228}
\DeclareTextComposite{\Dasia}{LGR}{\textomicron}{229}
\DeclareTextComposite{\Psili}{LGR}{\textomicron}{230}
\DeclareTextComposite{\DasiaVaria}{LGR}{\textomicron}{231}
\DeclareTextComposite{\Tonos}{LGR}{\textomicron}{236}
\DeclareTextComposite{\DasiaOxia}{LGR}{\textomicron}{237}
\DeclareTextComposite{\PsiliOxia}{LGR}{\textomicron}{238}
\DeclareTextComposite{\PsiliVaria}{LGR}{\textomicron}{239}
\DeclareTextComposite{\Dasia}{LGR}{r}{251}
\DeclareTextComposite{\Psili}{LGR}{r}{252}


% Capital letters
% ~~~~~~~~~~~~~~~
%
%  In Greek, diacritics are omitted in all-uppercase words, but kept as part
%  of an uppercase initial (written before rather than above the letter).
%
%  The diaytika should also always be used in all-uppercase words (even
%  in cases where they are not needed when writing in lowercase)
%
%  -- http://en.wikipedia.org/wiki/Capitalization
%
% Title Case
% """"""""""
%
% Place diacritics before instead of above::

\DeclareTextCompositeCommand{\Dasia}{LGR}{A}{<A}
\DeclareTextCompositeCommand{\DasiaVaria}{LGR}{A}{<`A}
\DeclareTextCompositeCommand{\DasiaOxia}{LGR}{A}{<'A}
\DeclareTextCompositeCommand{\DasiaPerispomeni}{LGR}{A}{<\char126A}
\DeclareTextCompositeCommand{\Psili}{LGR}{A}{>A}
\DeclareTextCompositeCommand{\PsiliVaria}{LGR}{A}{>`A}
\DeclareTextCompositeCommand{\PsiliOxia}{LGR}{A}{>'A}
\DeclareTextCompositeCommand{\PsiliPerispomeni}{LGR}{A}{>\char126A}
\DeclareTextCompositeCommand{\Tonos}{LGR}{A}{'A}
\DeclareTextCompositeCommand{\Varia}{LGR}{A}{`A}

\DeclareTextCompositeCommand{\Dasia}{LGR}{E}{<E}
\DeclareTextCompositeCommand{\DasiaOxia}{LGR}{E}{<'E}
\DeclareTextCompositeCommand{\DasiaVaria}{LGR}{E}{<`E}
\DeclareTextCompositeCommand{\Psili}{LGR}{E}{>E}
\DeclareTextCompositeCommand{\PsiliOxia}{LGR}{E}{>'E}
\DeclareTextCompositeCommand{\PsiliVaria}{LGR}{E}{>`E}
\DeclareTextCompositeCommand{\Tonos}{LGR}{E}{'E}
\DeclareTextCompositeCommand{\Varia}{LGR}{E}{`E}

\DeclareTextCompositeCommand{\Dasia}{LGR}{H}{<H}
\DeclareTextCompositeCommand{\DasiaVaria}{LGR}{H}{<`H}
\DeclareTextCompositeCommand{\DasiaOxia}{LGR}{H}{<'H}
\DeclareTextCompositeCommand{\DasiaPerispomeni}{LGR}{H}{<\char126H}
\DeclareTextCompositeCommand{\Psili}{LGR}{H}{>H}
\DeclareTextCompositeCommand{\PsiliVaria}{LGR}{H}{>`H}
\DeclareTextCompositeCommand{\PsiliOxia}{LGR}{H}{>'H}
\DeclareTextCompositeCommand{\PsiliPerispomeni}{LGR}{H}{>\char126H}
\DeclareTextCompositeCommand{\Tonos}{LGR}{H}{'H}
\DeclareTextCompositeCommand{\Varia}{LGR}{H}{`H}

\DeclareTextCompositeCommand{\Dasia}{LGR}{I}{<I}
\DeclareTextCompositeCommand{\DasiaVaria}{LGR}{I}{<`I}
\DeclareTextCompositeCommand{\DasiaOxia}{LGR}{I}{<'I}
\DeclareTextCompositeCommand{\DasiaPerispomeni}{LGR}{I}{<\char126I}
\DeclareTextCompositeCommand{\Psili}{LGR}{I}{>I}
\DeclareTextCompositeCommand{\PsiliVaria}{LGR}{I}{>`I}
\DeclareTextCompositeCommand{\PsiliOxia}{LGR}{I}{>'I}
\DeclareTextCompositeCommand{\PsiliPerispomeni}{LGR}{I}{>\char126I}
\DeclareTextCompositeCommand{\Tonos}{LGR}{I}{'I}
\DeclareTextCompositeCommand{\Varia}{LGR}{I}{`I}

\DeclareTextCompositeCommand{\Dasia}{LGR}{O}{<O}
\DeclareTextCompositeCommand{\DasiaVaria}{LGR}{O}{<`O}
\DeclareTextCompositeCommand{\DasiaOxia}{LGR}{O}{<'O}
\DeclareTextCompositeCommand{\Psili}{LGR}{O}{>O}
\DeclareTextCompositeCommand{\PsiliVaria}{LGR}{O}{>`O}
\DeclareTextCompositeCommand{\PsiliOxia}{LGR}{O}{>'O}
\DeclareTextCompositeCommand{\Tonos}{LGR}{O}{'O}
\DeclareTextCompositeCommand{\Varia}{LGR}{O}{`O}

\DeclareTextCompositeCommand{\Dasia}{LGR}{U}{<U}
\DeclareTextCompositeCommand{\DasiaVaria}{LGR}{U}{<`U}
\DeclareTextCompositeCommand{\DasiaOxia}{LGR}{U}{<'U}
\DeclareTextCompositeCommand{\DasiaPerispomeni}{LGR}{U}{<\char126U}
\DeclareTextCompositeCommand{\Tonos}{LGR}{U}{'U}
\DeclareTextCompositeCommand{\Varia}{LGR}{U}{`U}

\DeclareTextCompositeCommand{\Dasia}{LGR}{W}{<W}
\DeclareTextCompositeCommand{\DasiaVaria}{LGR}{W}{<`W}
\DeclareTextCompositeCommand{\DasiaOxia}{LGR}{W}{<'W}
\DeclareTextCompositeCommand{\DasiaPerispomeni}{LGR}{W}{<\char126W}
\DeclareTextCompositeCommand{\Psili}{LGR}{W}{>W}
\DeclareTextCompositeCommand{\PsiliVaria}{LGR}{W}{>`W}
\DeclareTextCompositeCommand{\PsiliOxia}{LGR}{W}{>'W}
\DeclareTextCompositeCommand{\PsiliPerispomeni}{LGR}{W}{>\char126W}
\DeclareTextCompositeCommand{\Tonos}{LGR}{W}{'W}
\DeclareTextCompositeCommand{\Varia}{LGR}{W}{`W}

% Except for the dialytika::

\DeclareTextComposite{\Dialytika}{LGR}{I}{219}
\DeclareTextComposite{\Dialytika}{LGR}{U}{223}

% Do the same for the ``\text*`` macros::

\DeclareTextCompositeCommand{\Dasia}{LGR}{\textAlpha}{<A}
\DeclareTextCompositeCommand{\DasiaVaria}{LGR}{\textAlpha}{<`A}
\DeclareTextCompositeCommand{\DasiaOxia}{LGR}{\textAlpha}{<'A}
\DeclareTextCompositeCommand{\DasiaPerispomeni}{LGR}{\textAlpha}{<\char126A}
\DeclareTextCompositeCommand{\Psili}{LGR}{\textAlpha}{>A}
\DeclareTextCompositeCommand{\PsiliVaria}{LGR}{\textAlpha}{>`A}
\DeclareTextCompositeCommand{\PsiliOxia}{LGR}{\textAlpha}{>'A}
\DeclareTextCompositeCommand{\PsiliPerispomeni}{LGR}{\textAlpha}{>\char126A}
\DeclareTextCompositeCommand{\Tonos}{LGR}{\textAlpha}{'A}
\DeclareTextCompositeCommand{\Varia}{LGR}{\textAlpha}{`A}

\DeclareTextCompositeCommand{\Dasia}{LGR}{\textEpsilon}{<E}
\DeclareTextCompositeCommand{\DasiaOxia}{LGR}{\textEpsilon}{<'E}
\DeclareTextCompositeCommand{\DasiaVaria}{LGR}{\textEpsilon}{<`E}
\DeclareTextCompositeCommand{\Psili}{LGR}{\textEpsilon}{>E}
\DeclareTextCompositeCommand{\PsiliOxia}{LGR}{\textEpsilon}{>'E}
\DeclareTextCompositeCommand{\PsiliVaria}{LGR}{\textEpsilon}{>`E}
\DeclareTextCompositeCommand{\Tonos}{LGR}{\textEpsilon}{'E}
\DeclareTextCompositeCommand{\Varia}{LGR}{\textEpsilon}{`E}

\DeclareTextCompositeCommand{\Dasia}{LGR}{\textEta}{<H}
\DeclareTextCompositeCommand{\DasiaVaria}{LGR}{\textEta}{<`H}
\DeclareTextCompositeCommand{\DasiaOxia}{LGR}{\textEta}{<'H}
\DeclareTextCompositeCommand{\DasiaPerispomeni}{LGR}{\textEta}{<\char126H}
\DeclareTextCompositeCommand{\Psili}{LGR}{\textEta}{>H}
\DeclareTextCompositeCommand{\PsiliVaria}{LGR}{\textEta}{>`H}
\DeclareTextCompositeCommand{\PsiliOxia}{LGR}{\textEta}{>'H}
\DeclareTextCompositeCommand{\PsiliPerispomeni}{LGR}{\textEta}{>\char126H}
\DeclareTextCompositeCommand{\Tonos}{LGR}{\textEta}{'H}
\DeclareTextCompositeCommand{\Varia}{LGR}{\textEta}{`H}

\DeclareTextCompositeCommand{\Dasia}{LGR}{\textIota}{<I}
\DeclareTextCompositeCommand{\DasiaVaria}{LGR}{\textIota}{<`I}
\DeclareTextCompositeCommand{\DasiaOxia}{LGR}{\textIota}{<'I}
\DeclareTextCompositeCommand{\DasiaPerispomeni}{LGR}{\textIota}{<\char126I}
\DeclareTextCompositeCommand{\Psili}{LGR}{\textIota}{>I}
\DeclareTextCompositeCommand{\PsiliVaria}{LGR}{\textIota}{>`I}
\DeclareTextCompositeCommand{\PsiliOxia}{LGR}{\textIota}{>'I}
\DeclareTextCompositeCommand{\PsiliPerispomeni}{LGR}{\textIota}{>\char126I}
\DeclareTextCompositeCommand{\Tonos}{LGR}{\textIota}{'I}
\DeclareTextCompositeCommand{\Varia}{LGR}{\textIota}{`I}

\DeclareTextCompositeCommand{\Dasia}{LGR}{\textOmicron}{<O}
\DeclareTextCompositeCommand{\DasiaVaria}{LGR}{\textOmicron}{<`O}
\DeclareTextCompositeCommand{\DasiaOxia}{LGR}{\textOmicron}{<'O}
\DeclareTextCompositeCommand{\Psili}{LGR}{\textOmicron}{>O}
\DeclareTextCompositeCommand{\PsiliVaria}{LGR}{\textOmicron}{>`O}
\DeclareTextCompositeCommand{\PsiliOxia}{LGR}{\textOmicron}{>'O}
\DeclareTextCompositeCommand{\Tonos}{LGR}{\textOmicron}{'O}
\DeclareTextCompositeCommand{\Varia}{LGR}{\textOmicron}{`O}

\DeclareTextCompositeCommand{\Dasia}{LGR}{\textUpsilon}{<U}
\DeclareTextCompositeCommand{\DasiaVaria}{LGR}{\textUpsilon}{<`U}
\DeclareTextCompositeCommand{\DasiaOxia}{LGR}{\textUpsilon}{<'U}
\DeclareTextCompositeCommand{\DasiaPerispomeni}{LGR}{\textUpsilon}{<\char126U}
\DeclareTextCompositeCommand{\Tonos}{LGR}{\textUpsilon}{'U}
\DeclareTextCompositeCommand{\Varia}{LGR}{\textUpsilon}{`U}

\DeclareTextCompositeCommand{\Dasia}{LGR}{\textOmega}{<W}
\DeclareTextCompositeCommand{\DasiaVaria}{LGR}{\textOmega}{<`W}
\DeclareTextCompositeCommand{\DasiaOxia}{LGR}{\textOmega}{<'W}
\DeclareTextCompositeCommand{\DasiaPerispomeni}{LGR}{\textOmega}{<\char126W}
\DeclareTextCompositeCommand{\Psili}{LGR}{\textOmega}{>W}
\DeclareTextCompositeCommand{\PsiliVaria}{LGR}{\textOmega}{>`W}
\DeclareTextCompositeCommand{\PsiliOxia}{LGR}{\textOmega}{>'W}
\DeclareTextCompositeCommand{\PsiliPerispomeni}{LGR}{\textOmega}{>\char126W}
\DeclareTextCompositeCommand{\Tonos}{LGR}{\textOmega}{'W}
\DeclareTextCompositeCommand{\Varia}{LGR}{\textOmega}{`W}

% Except for the dialytika::

\DeclareTextComposite{\Dialytika}{LGR}{\textIota}{219}
\DeclareTextComposite{\Dialytika}{LGR}{\textUpsilon}{223}

% UPPERCASE
% ~~~~~~~~~
%
% @uclclist extension
% """""""""""""""""""
%
% If UPPERCASE (all-caps) is generated with ``\MakeUppercase``, macro
% substitutions in the ``\@uclclist`` apply. This can be used to drop the
% diacritics (except dialytika).
%
% Based on the `babel patch`_ and ``fontenc.sty``.
% (The first two lines are TeX' way of writing ``uclclist += …``)::

\expandafter\def\expandafter\@uclclist\expandafter{%
   \@uclclist
    \Dasia\do@nothing
    \DasiaOxia\@hiatus
    \DasiaVaria\do@nothing
    \DasiaPerispomeni\do@nothing
    \Psili\@hiatus
    \PsiliOxia\@hiatus
    \PsiliVaria\@hiatus
    \PsiliPerispomeni\do@nothing
    \Tonos\@hiatus
    \Varia\do@nothing
    \DialytikaTonos\up@Dialytika
    \DialytikaVaria\up@Dialytika
    \DialytikaPerispomeni\up@Dialytika
    \Perispomeni\do@nothing
    \Ypogegrammeni\Prosgegrammeni
    %
    \textalpha  \textAlpha
    \textbeta   \textBeta
    \textgamma  \textGamma
    \textdelta  \textDelta
    \textepsilon\textEpsilon
    \textzeta   \textZeta
    \texteta    \textEta
    \texttheta  \textTheta
    \textiota   \textIota
    \textkappa  \textKappa
    \textlambda \textLambda
    \textmu     \textMu
    \textnu     \textNu
    \textxi     \textXi
    \textomicron\textOmicron
    \textpi     \textPi
    \textrho    \textRho
    \textvarsigma  \textSigma
    \textsigma     \textSigma
    \textautosigma \textSigma
    \texttau    \textTau
    \textupsilon\textUpsilon
    \textphi    \textPhi
    \textchi    \textChi
    \textpsi    \textPsi
    \textomega  \textOmega
    %
    \qoppa      \Qoppa
    \varstigma  \Stigma
    \stigma     \Stigma
    \sampi      \Sampi
    \ddigamma   \Digamma
}

% Substitution macros
% """""""""""""""""""
%
% Drop diacritics
% '''''''''''''''
% ::

\DeclareTextCommand{\do@nothing}{LGR}[1]{#1}

% (The argument processing ensures that kerning is preserved)
%
% Keep dialytika.
% '''''''''''''''
%
% Define an alias so that downcasing with ``\MakeLowercase`` does not
% convert a simple dialytika to a composite accent::

\DeclareTextCommand{\up@Dialytika}{LGR}{\Dialytika}

% Mark hiatus
% '''''''''''
%
% Tonos and dasia mark a hiatus (break-up of a diphtong) if placed on the
% first vowel of a diphthong (ΑΙ, ΑΥ, ΕΙ). A dialytika must be placed on the
% second vowel if they are dropped (άυλος → ΑΫΛΟΣ, μάινα → ΜΑΪΝΑ, κέικ → ΚΕΪΚ,
% ἀυπνία → ΑΫΠΝΙΑ)::

\DeclareTextCommand{\@hiatus}{LGR}[1]{#1}
\DeclareTextCompositeCommand{\@hiatus}{LGR}{A}{\A@hiatus}
\DeclareTextCompositeCommand{\@hiatus}{LGR}{\textAlpha}{\A@hiatus}
\DeclareTextCompositeCommand{\@hiatus}{LGR}{E}{\E@hiatus}
\DeclareTextCompositeCommand{\@hiatus}{LGR}{\textEpsilon}{\E@hiatus}

% Look ahead and place a diaeresis on Ι or Υ::

\DeclareTextCommand{\A@hiatus}{LGR}{%
  \LGR@ifnextchar{I}{A\"}{%
    \LGR@ifnextchar{U}{A\"}{%
      \LGR@ifnextchar{\textIota}{A\"}{%
        \LGR@ifnextchar{\textUpsilon}{A\"}{A}%
      }%
    }%
  }%
}
\DeclareTextCommand{\E@hiatus}{LGR}{%
  \LGR@ifnextchar{I}{E\"}{%
    \LGR@ifnextchar{U}{E\"}{%
      \LGR@ifnextchar{\textIota}{E\"}{%
        \LGR@ifnextchar{\textUpsilon}{E\"}{E}%
      }%
    }%
  }%
}

% As ``\@ifnextchar`` gobbles spaces the lookahead macro definition from
% ``amsgen.sty`` is used:
%
%   This macro is a new version of LaTeX’s ``\@ifnextchar``, macro
%   that does not skip over spaces.
%
% ::

\ProvideTextCommand{\LGR@ifnextchar}{LGR}[3]{%
% \long\def\LGR@ifnextchar#1#2#3{%
  \let\reserved@d= #1%
  \def\reserved@a{#2}\def\reserved@b{#3}%
  \futurelet\@let@token\LGR@ifnch
}
\ProvideTextCommand{\LGR@ifnch}{LGR}{%
  \ifx\@let@token\reserved@d \let\reserved@b\reserved@a \fi
  \reserved@b
}

% Unfortunately, the lookahead breaks kerning.
%
% Alternatives tried:
%
% * CompositeCommands fail at the end of a macro, e.g. ``\emph{\'a}``::

  %\DeclareTextCommand{\A@hiatus}{LGR}{A}
  %\DeclareTextCommand{\E@hiatus}{LGR}{E}

  %\DeclareTextCompositeCommand{\A@hiatus}{LGR}{}{A}
  %\DeclareTextCompositeCommand{\A@hiatus}{LGR}{I}{A\"I}
  %\DeclareTextCompositeCommand{\A@hiatus}{LGR}{U}{A\"U}


% * The glyph No 12 is a special "Upcase Alpha" that in ligature with Y
%   and I adds a diaresis to them. However, it seems that it has only
%   kerning definitions for I and Y (as it is not intended for direct
%   use)::

  %\DeclareTextComposite{\@hiatus}{LGR}{A}{12}

%   No such glyph exists for E but this is no problem as E does
%   not require kerning anyway.
%
% .. References
%    ----------
%
% .. _LaTeX Project Public License: http://www.latex-project.org/lppl.txt
% .. _lgrx: http://mirror.ctan.org/help/Catalogue/entries/lgrx.html
% .. _textalpha: textalpha.sty.html
% .. _alphabeta: alphabeta.sty.html
% .. _Babel: http://mirror.ctan.org/help/Catalogue/entries/babel.html
% .. _ibycus: http://mirror.ctan.org/help/Catalogue/entries/ibycus-babel.html
% .. _libertine: http://mirror.ctan.org/help/Catalogue/entries/libertine-legacy.html
% .. _hyperref: http://mirror.ctan.org/help/Catalogue/entries/hyperref.html
% .. _fontenc:  http://mirror.ctan.org/help/Catalogue/entries/fontenc.html
% .. _Adobe Glyph List For New Fonts:
%    http://www.adobe.com/devnet/opentype/archives/aglfn.txt
% .. _athnum: http://mirror.ctan.org/help/Catalogue/entries/athnum.html
% .. _fntguide: http://mirror.ctan.org/macros/latex/doc/fntguide.pdf
% .. _babel patch: http://www.eutypon.gr/eutypon/pdf/e2008-20/e20-a03.pdf
% .. _teubner: http://mirror.ctan.org/help/Catalogue/entries/teubner.html
% .. _teubner-doc:
%    http://mirror.ctan.org/macros/latex/contrib/teubner/teubner-doc.pdf
% .. _ucs: http://mirror.ctan.org/help/Catalogue/entries/unicode.html
% .. _XML Entity Definitions for Characters:
%    http://www.w3.org/TR/xml-entity-names/
