% Test definitions for accents and composite accents in Greek
% \RequirePackage{latexbug}
\documentclass[a4paper]{article}
\usepackage{lmodern}
\usepackage{parskip}

% Load encoding definitions
% \usepackage[LGR,T1]{fontenc}
\usepackage{textalpha}  % "Greek script everywhere"

% With TL22, the special handling of Greek UPPERCASE is only triggered
% if the text language is set to "greek" with Babel:
%
\usepackage[greek,english]{babel}  % babel-greek
% \usepackage[greek,english,provide=*]{babel}    % Babel's Greek "ini"


\IfFormatAtLeastTF{2022/06/01}
  {\newcommand*{\uppercaseversion}{new (post-2022/06/01)}}
  {\newcommand*{\uppercaseversion}{old (pre-2022/06/01)}}

\begin{document}

\section*{Test Greek diacritics with 8-bit TeX}

This document tests support for the Greek non-standard LGR fonts with the
contributed packages \emph{greek-fontenc} and \emph{greek-inputenc}.
It is compiled with the \textbf{\uppercaseversion{}} \verb|\MakeUppercase|
version.

The LGR font encoding definition file \texttt{lgrenc.def} defines LICR
macros for all non-ASCII characters in the LGR font encoding and loads
definitions shared with the TU font encoding from
\texttt{greek-fontenc.def}.

In addition to the LICR, Greek letters can also be input via a Latin
transliteration.

Greek accent macros have names starting with \verb|\acc| followed by the
Greek accent name as used in the Unicode standard (e.g. \verb|\acctonos|).
The standard symbol accents \verb|\' \` \~ \"| should behave according to
Greek typography if used with Greek letters.

Apart from the diacritical marks native to Greek itself, linguists also
regularly mark vowel length with macrons (¯) and breves (˘).
Both keep the ``Latin'' behaviour also with capital Greek letters.

The \emph{textalpha} or \emph{alphabeta} packages define the symbol macros
\verb|\<| and \verb|\>| as alias for the breathings (Dasia and Psili).

Diacritics can be specified as named macro, short macro, or combined accent
macros, e.\,g.
\verb| \accpsiliperispomeni{w} \accpsili\accperispomeni w| and
\verb|\>\~w \~>{w} \~\>w \>~w| all become
%
\newcommand*{\accsample}{\accpsiliperispomeni{w} \accpsili\accperispomeni w
                         \>\~w \~>{w} \~\>w \>~w}
\ensuregreek{\accsample}.

The pre-June 22 version of \verb+\MakeUppercase+ works correctly, with one
exception: There is a spurious space in upcased combined accents with a
literal tilde like \verb|\>~|. This can be fixed by using a tilde accent
(\verb|\>\~| or \verb|\~>|) or loading Babel with the "greek" language option
(even in text parts only changing the font encoding without selecting the
Greek language).
\begin{quote}
  \ensuregreek{\accsample\ → \MakeUppercase{\accsample}}
\end{quote}

Test the upcasing of the different input methods:

\subsection*{Accent macro + Latin transliteration}

\begin{quotation}
  single accent (named, [alias], short)

  \ensuregreek{\acctonos w \accoxia w \'w →
     \MakeUppercase{\acctonos w \accoxia w \'w}}

  \ensuregreek{\accvaria w \`w → \MakeUppercase{\accvaria w \`w}}

  \ensuregreek{\accperispomeni w \~w → \MakeUppercase{\accperispomeni w \~w}}

  \ensuregreek{\accdasia w \<w → \MakeUppercase{\accdasia w \<w}}

  \ensuregreek{\accpsili w \>w → \MakeUppercase{\accpsili w \>w}}

  \ensuregreek{\accdialytika u \"u → \MakeUppercase{\accdialytika u \"u}}

  \ensuregreek{w\ypogegrammeni{} w| → \MakeUppercase{w\ypogegrammeni{} w|}}

  combined accents (name, name+name, short+short, short+char)

    \ensuregreek{\accdasiaperispomeni w     \accdasia\accperispomeni     w \<\~w \~<w
  → \MakeUppercase{\accdasiaperispomeni w     \accdasia\accperispomeni     w \<\~w \~<w}}

    \ensuregreek{\accdasiavaria       w     \accdasia\accvaria           w \<\`w \<`w
  → \MakeUppercase{\accdasiavaria       w     \accdasia\accvaria           w \<\`w \<`w}}

    \ensuregreek{\accdasiaoxia        w     \accdasia\accoxia            w \<\'w \<'w
  → \MakeUppercase{\accdasiaoxia        w     \accdasia\accoxia            w \<\'w \<'w}}

    \ensuregreek{\accpsiliperispomeni w     \accpsili\accperispomeni     w \>\~w \~>w
  → \MakeUppercase{\accpsiliperispomeni w     \accpsili\accperispomeni     w \>\~w \~>w}}

    \ensuregreek{\accpsilioxia        w     \accpsili\accoxia  w         \>\'w \>'w
  → \MakeUppercase{\accpsilioxia        w     \accpsili\accoxia  w         \>\'w \>'w}}

    \ensuregreek{\accpsilivaria       w     \accpsili\accvaria w         \>\`w \>`w
  → \MakeUppercase{\accpsilivaria       w     \accpsili\accvaria w         \>\`w \>`w}}

    \ensuregreek{\accdialytikaperispomeni u \accdialytika\accperispomeni u \"\~u \~"u
  → \MakeUppercase{\accdialytikaperispomeni u \accdialytika\accperispomeni u \"\~u \~"u}}

    \ensuregreek{\accdialytikatonos   u     \accdialytika\acctonos u     \"\'u \"'u
  → \MakeUppercase{\accdialytikatonos   u     \accdialytika\acctonos u     \"\'u \"'u}}

    \ensuregreek{\accdialytikavaria   u     \accdialytika\accvaria u     \"\`u \"`u
  → \MakeUppercase{\accdialytikavaria   u     \accdialytika\accvaria u     \"\`u \"`u}}

    \ensuregreek{\accpsilivaria w\ypogegrammeni{} \accpsili\accvaria w| \>\`w| \>`w|
  → \MakeUppercase{\accpsilivaria w\ypogegrammeni{} \accpsili\accvaria w| \>\`w| \>`w|}}

\end{quotation}

With TeXLive 2020 (Debian/stable), all accents except dialytika and
ypogegrammeni/prosgegrammeni are dropped in ALL CAPS.

With current (2023/01/28) TeXLive, upcasing short accent macros does no
longer work as expected: accents are not dropped.

The mute iota is kept (as expected).

\subsection*{Accent macro + Latin transliteration}

\begin{quotation}
  single accent (named, [alias], short)

  \ensuregreek{\acctonos \textomega{} \accoxia \textomega{} \'\textomega{}
     → \MakeUppercase{\acctonos \textomega{} \accoxia \textomega{} \'\textomega{}}}

  \ensuregreek{\accvaria \textomega{} \`\textomega{} → \MakeUppercase{\accvaria \textomega{} \`\textomega{}}}

  \ensuregreek{\accperispomeni \textomega{} \~\textomega{} → \MakeUppercase{\accperispomeni \textomega{} \~\textomega{}}}

  \ensuregreek{\accdasia \textomega{} \<\textomega{} → \MakeUppercase{\accdasia \textomega{} \<\textomega{}}}

  \ensuregreek{\accpsili \textomega{} \>\textomega{} → \MakeUppercase{\accpsili \textomega{} \>\textomega{}}}

  \ensuregreek{\accdialytika \textupsilon{} \"\textupsilon{} → \MakeUppercase{\accdialytika \textupsilon{} \"\textupsilon{}}}

  \ensuregreek{\textomega\ypogegrammeni{} \textomega| → \MakeUppercase{\textomega\ypogegrammeni{} \textomega|}}

  combined accents (name, name+name, short+short, short+char)

    \ensuregreek{\accdasiaperispomeni \textomega{}     \accdasia\accperispomeni     \textomega{} \<\~\textomega{} \~<\textomega{}
  → \MakeUppercase{\accdasiaperispomeni \textomega{}     \accdasia\accperispomeni     \textomega{} \<\~\textomega{} \~<\textomega{}}}

    \ensuregreek{\accdasiavaria       \textomega{}     \accdasia\accvaria           \textomega{} \<\`\textomega{} \<`\textomega{}
  → \MakeUppercase{\accdasiavaria       \textomega{}     \accdasia\accvaria           \textomega{} \<\`\textomega{} \<`\textomega{}}}

    \ensuregreek{\accdasiaoxia        \textomega{}     \accdasia\accoxia            \textomega{} \<\'\textomega{} \<'\textomega{}
  → \MakeUppercase{\accdasiaoxia        \textomega{}     \accdasia\accoxia            \textomega{} \<\'\textomega{} \<'\textomega{}}}

    \ensuregreek{\accpsiliperispomeni \textomega{}     \accpsili\accperispomeni     \textomega{} \>\~\textomega{} \~>\textomega{}
  → \MakeUppercase{\accpsiliperispomeni \textomega{}     \accpsili\accperispomeni     \textomega{} \>\~\textomega{} \~>\textomega{}}}

    \ensuregreek{\accpsilioxia        \textomega{}     \accpsili\accoxia  \textomega{}         \>\'\textomega{} \>'\textomega{}
  → \MakeUppercase{\accpsilioxia        \textomega{}     \accpsili\accoxia  \textomega{}         \>\'\textomega{} \>'\textomega{}}}

    \ensuregreek{\accpsilivaria       \textomega{}     \accpsili\accvaria \textomega{}         \>\`\textomega{} \>`\textomega{}
  → \MakeUppercase{\accpsilivaria       \textomega{}     \accpsili\accvaria \textomega{}         \>\`\textomega{} \>`\textomega{}}}

    \ensuregreek{\accdialytikaperispomeni \textupsilon{} \accdialytika\accperispomeni \textupsilon{} \"\~\textupsilon{} \~"\textupsilon{}
  → \MakeUppercase{\accdialytikaperispomeni \textupsilon{} \accdialytika\accperispomeni \textupsilon{} \"\~\textupsilon{} \~"\textupsilon{}}}

    \ensuregreek{\accdialytikatonos   \textupsilon{}     \accdialytika\acctonos \textupsilon{}     \"\'\textupsilon{} \"'\textupsilon{}
  → \MakeUppercase{\accdialytikatonos   \textupsilon{}     \accdialytika\acctonos \textupsilon{}     \"\'\textupsilon{} \"'\textupsilon{}}}

    \ensuregreek{\accdialytikavaria   \textupsilon{}     \accdialytika\accvaria \textupsilon{}     \"\`\textupsilon{} \"`\textupsilon{}
  → \MakeUppercase{\accdialytikavaria   \textupsilon{}     \accdialytika\accvaria \textupsilon{}     \"\`\textupsilon{} \"`\textupsilon{}}}

    \ensuregreek{\accpsilivaria \textomega\ypogegrammeni{} \accpsili\accvaria \textomega| \>\`\textomega| \>`\textomega|
  → \MakeUppercase{\accpsilivaria \textomega\ypogegrammeni{} \accpsili\accvaria \textomega| \>\`\textomega| \>`\textomega|}}

\end{quotation}

With TeXLive 2020 (Debian/stable), all Greek accents except dialytika and
prosgegrammeni are dropped in ALL CAPS. (The standard accents macron and
breve are kept as well.)

With current (2023/01/28) TeXLive, upcasing the \verb|\~| accent macro and
combining accents with dialytika (\verb|\~" \"' \"`|) does no longer work as
expected: accents are not dropped (only the dialytika, macron and breve must
be kept).

Upcasing keeps the mute iota (as expected).

\subsection*{Accent macro + literal Greek character}
Accent + literal Greek (utf-8) character is not supported in 8-bit TeX.


\subsection*{The hiatus feature}

Tonos and dasia mark a \emph{hiatus} (break-up of a diphthong) if
placed on the first vowel of a diphthong.
A dialytika must be placed on the second vowel if they are dropped:

\newcommand{\Hiatus}{\acctonos\textalpha\textiota,
                     \acctonos\textalpha\textupsilon,
                     \acctonos\textepsilon\textiota,
                     \accdasiaoxia\textalpha\textiota,
                     \accdasiaoxia\textalpha\textupsilon,
                     \accdasiaoxia\textepsilon\textiota}%
Named + LICR:
\ensuregreek{\Hiatus\ → \MakeUppercase{\Hiatus}}.

\renewcommand{\Hiatus}{\'\textalpha\textiota,
                       \'\textalpha\textupsilon,
     		       \'\textepsilon\textiota,
                       \'>\textalpha\textiota,
                       \'>\textalpha\textupsilon,
                       \'>\textepsilon\textiota}%
Short + LICR:
\ensuregreek{\Hiatus\ → \MakeUppercase{\Hiatus}}.

\renewcommand{\Hiatus}{\acctonos ai,
                       \acctonos au,
                       \acctonos ei,
                       \accdasiaoxia ai,
                       \accdasiaoxia au,
                       \accdasiaoxia ei}%
Named + transliteration:
\ensuregreek{\Hiatus\ → \MakeUppercase{\Hiatus}}.

\renewcommand{\Hiatus}{\'ai,
                       \'au,
                       \'ei,
                       \'>ai,
                       \'>au,
                       \'>ei}%
Short + transliteration:
\ensuregreek{\Hiatus\ → \MakeUppercase{\Hiatus}}.

In current TeXLive, the \emph{hiatus} feature keeps working with named
accend macros but fails with short accent macros.


\subsection*{Pre-composed literal Greek character}

The Greek and Coptic Unicode Block

\newcommand{\GreekAndCoptic}{%
                   ͺ ; ΄   ΅    Ά ·  Έ  Ή  Ί  Ό  Ύ  Ώ  \\
               ΐ Α Β Γ  Δ Ε Ζ Η Θ Ι  Κ  Λ  Μ  Ν  Ξ  Ο  \\
               Π Ρ   Σ  Τ Υ Φ Χ Ψ Ω  Ϊ  Ϋ  ά  έ  ή  ί  \\
               ΰ α β γ  δ ε ζ η θ ι  κ  λ  μ  ν  ξ  ο  \\
               π ρ ς σ  τ υ φ χ ψ ω  ϊ  ϋ  ό  ύ  ώ     \\
}
\begin{quote}
  \ifdefined\extrasgreek
    \selectlanguage{greek}
  \fi
  \greekscript
  \GreekAndCoptic
\end{quote}
%
MakeUppercase:
\begin{quote}
  \ifdefined\extrasgreek
    \selectlanguage{greek}
  \fi
  \greekscript
  \MakeUppercase{\GreekAndCoptic}
\end{quote}
%
% MakeLowercase:
% \begin{quote}
%   \greekscript
%   \MakeLowercase{\GreekAndCoptic}
% \end{quote}

Greek extended Unicode block

\newcommand{\GreekExtended}{\raggedright
  ἀ   ἁ   ἂ   ἃ   ἄ   ἅ   ἆ    ἇ    Ἀ   Ἁ   Ἂ   Ἃ   Ἄ   Ἅ   Ἆ  Ἇ \\
  ἐ   ἑ   ἒ   ἓ   ἔ   ἕ \ \  \ \    Ἐ   Ἑ   Ἒ   Ἓ   Ἔ   Ἕ        \\
  ἠ   ἡ   ἢ   ἣ   ἤ   ἥ   ἦ    ἧ    Ἠ   Ἡ   Ἢ   Ἣ   Ἤ   Ἥ   Ἦ  Ἧ \\
  ἰ   ἱ   ἲ   ἳ   ἴ   ἵ   ἶ    ἷ    Ἰ   Ἱ   Ἲ   Ἳ   Ἴ   Ἵ   Ἶ  Ἷ \\
  ὀ   ὁ   ὂ   ὃ   ὄ   ὅ \ \  \ \    Ὀ   Ὁ   Ὂ   Ὃ   Ὄ   Ὅ        \\
  ὐ   ὑ   ὒ   ὓ   ὔ   ὕ   ὖ    ὗ  \ \   Ὑ \ \   Ὓ \ \   Ὕ \ \  Ὗ \\
  ὠ   ὡ   ὢ   ὣ   ὤ   ὥ   ὦ    ὧ    Ὠ   Ὡ   Ὢ   Ὣ   Ὤ   Ὥ   Ὦ  Ὧ \\
  ὰ   ά   ὲ   έ   ὴ   ή   ὶ    ί    ὸ   ό   ὺ   ύ   ὼ   ώ        \\
  ᾀ   ᾁ   ᾂ   ᾃ   ᾄ   ᾅ   ᾆ    ᾇ    ᾈ   ᾉ   ᾊ   ᾋ   ᾌ   ᾍ   ᾎ  ᾏ \\
  ᾐ   ᾑ   ᾒ   ᾓ   ᾔ   ᾕ   ᾖ    ᾗ    ᾘ   ᾙ   ᾚ   ᾛ   ᾜ   ᾝ   ᾞ  ᾟ \\
  ᾠ   ᾡ   ᾢ   ᾣ   ᾤ   ᾦ   ᾧ    ᾥ    ᾨ   ᾩ   ᾪ   ᾫ   ᾬ   ᾭ   ᾮ  ᾯ \\
  ᾰ   ᾱ   ᾲ   ᾳ   ᾴ \ \   ᾶ    ᾷ    Ᾰ   Ᾱ   Ὰ   Ά   ᾼ   ᾽   ι  ᾿ \\
  ῀   ῁   ῂ   ῃ   ῄ \ \   ῆ    ῇ    Ὲ   Έ   Ὴ   Ή   ῌ   ῍      ῏ \\
  ῐ   ῑ   ῒ   ΐ \ \ \ \   ῖ    ῗ    Ῐ   Ῑ   Ὶ   Ί \ \   ῝      ῟ \\
  ῠ   ῡ   ῢ   ΰ \ \ \ \   ῤ    ῥ    ῦ   ῧ   Ὺ   Ύ   Ῥ   ῭      ` \\
 \ \ \ \  ῲ   ῳ   ῴ \ \   ῶ    ῷ    Ὸ   Ό   Ὼ   Ώ   ῼ   ´        \\
}

\begin{quote}
  \ifdefined\extrasgreek
    \selectlanguage{greek}
  \fi
  \greekscript
  \GreekExtended
\end{quote}
%
MakeUppercase:
\begin{quote}
  \ifdefined\extrasgreek
    \selectlanguage{greek}
  \fi
  \greekscript
  \MakeUppercase{\GreekExtended}
\end{quote}

% MakeLowercase:
% \begin{quote}
%   % \selectlanguage{greek}
%   \greekscript
%   \MakeLowercase{\GreekExtended}
% \end{quote}

With TeXLive 2020 (Debian/stable), all Greek accents except dialytika and
prosgegrammeni are dropped in UPPERCASE and kept in lowercase. No errors.

With current (2023/01/28) TeXLive:

Upcasing leads to ``Unicode errors'' (``combining characters not set not set
up for use with LaTeX'') although no combining characters are used in the
source.

Accents are not dropped (with some exceptions).

The sub-iota became a capital iota (solved by an update to MakeUppercase).

\end{document}
