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.
\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.
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.
Use the EU1 font encoding. This is the only font encoding used with XeTeX, so loading it with fontenc cannot mix up the default font encoding.
Ensure EU1 is the \LastDeclaredEncoding. As fontenc does not load font encoding definition files twice, it may happen that another font encoding is defined after EU1 – for example the xunicode package (also loaded by fontspec) leaves \LastDeclaredEncoding at T3 (tipa), because it inputs t3enc.def.
load the Greek LICR definitions for XeTeX/LuaTeX. In an ideal world, this should be done in the eu1enc.def file of the euenc package.
\ifdefined\XeTeXrevision \usepackage[EU1]{fontenc} \renewcommand{\LastDeclaredEncoding}{EU1} \input{greek-euenc.def}
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}
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
LaTeX3 Project Team, LaTeX 2ε font selection, 2005. http://mirror.ctan.org/macros/latex/doc/fntguide.pdf