greek-fontenc: Greek text font encoding setup

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.

Identification
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{greek-fontenc}
[2013/09/10 v0.1 Greek text font encoding setup]

Abstract

This package sets up a suitable font encoding and Greek LICR definitions depending on the used TeX engine.

Motivation

With 8-bit TeX, you usually pass the font encoding name(s) as option to fontenc which then loads the corresponding *.def file(s). The last option indicates the document’s default font encoding. (See [fntguide] for details and lgrenc-test.tex for an example.)

However, with XeTeX or LuaTeX, there is one common input and font encoding – Unicode. 8-bit TeX font encodings should generally not be used. For compatibility with the LaTeX font selection system, the package euenc defines the (pseudo) font encodings EU1 and EU2 for XeTeX and LuaTeX respectively, however euenc does not (yet) define LICR macros. The package xunicode defines LICR macros for use with XeTeX but does not support Greek.

To allow documents using Greek LICR macros without worrying about the TeX engine used to compile them, this package does a simple test (based on the \ifdefined command provided by the e-TeX extension) and does “the right thing” to set up Greek text font support for the detected engine.

XeTeX

\ifdefined\XeTeXrevision
  \usepackage[EU1]{fontenc}
  \renewcommand{\LastDeclaredEncoding}{EU1}
  \input{greek-euenc.def}

LuaTeX

Similar actions to XeTeX, but use the font encoding EU2. (The two different (pseudo) encodings allow different font setups for XeTeX vs. LuaTeX using differently named *.fd files (see euenc for details).

\else\ifdefined\luatexversion
  \usepackage[EU2]{fontenc}
  \renewcommand{\LastDeclaredEncoding}{EU1}
  \input{greek-euenc.def}

8-bit TeX

Wit 8-bit TeX (TeX, PDFTeX), we do not know the documents main font encoding, so we cannot use \usepackage[LGR]{inputenc}. However, the file lgrenc.def contains code to prevent re-definition if it is already loaded, so we can simply input:

\else
  \input{lgrenc.def}
\fi\fi

References

[fntguide]

LaTeX3 Project Team, LaTeX 2ε font selection, 2005. http://mirror.ctan.org/macros/latex/doc/fntguide.pdf