Typesetting Greek with the psgreek package ^{∗}

Alexej Kryukov  Christian Justen

April 23, 2004

Abstract

The ‘psgreek’ font package provides L^{A}TEX support for some popular Type 1 Greek fonts using the WinGreek encoding.

1 Fonts included

The psgreek package includes the following Greek fonts:

• The original WinGreek font by P. Gentry and A. Fountain.

• The Greek Garamond font by Carmelo Lupini, which can be downloaded from http://www.geocities.com/SoHo/Workshop/3799/download.htm. I simply converted it to the Type 1 format and slightly modified the encoding.

• The Greek Oxonia font. I don’t know anything about its origin, however, I hope it can be freely distributed. I simply converted it to the Type 1 format.

The three fonts mentioned above don’t contain any kerning pairs.

• Two high-quality Type 1 fonts by Ralph Hancock: Greek Old Face and Milan Greek. These fonts are copyrighted. I included them to the psgreek package from the author’s permission, however, if you regularly use them, you have to pay registration fee to the author. For copyright notices and license agreement for these fonts see the ‘greekof.txt’ and ‘milan.txt’ files, included in this package.

2 Encoding

Although all fonts included in this package follow the same WinGreek encoding, I decided that this encoding is not suitable for TEX by itself, as well as any other font encoding designed for use with WYSIWYG applications. Probably you know that there are some specific features, common for all standard TEX-specific font encodings. For example, TEX has access to all 256 slots in the font, including first 32 positions. This means that we have additional place for some useful characters.

That’s why it could be good idea to use so-called virtual fonts, taking some glyphs from physical Type 1 fonts and rearranging their mapping according to an internal TEX encoding. Although there is no officially supported Greek font encoding for TEX, we should consider the Greek fonts designed by Claudio Beccari as a kind of standard, since Babel’s Greek language support is based on this package. So I had to reencode my WinGreek fonts to this encoding (so-called LGR), and prepared a set of virtual fonts performing this task. However, there are two significant differences between Greek font encodings used in the CB Greek fonts and in my psgreek package:

∗This file has version number 0.6, last revised on 16 Apr 2003.

• In the CB Greek font package Greek perispomeni is mapped to ASCII tilde (˜ ). I think, it is very inconvenient, since in normal L^{A}TEX (unless we loaded the babel package with the polutonikogreek option) this character is used for non-breaking space. In the psgreek fonts I moved perispomeni to another slot, corresponding to the ‘=’ sign, as in some older Greek packages. However, the ‘˜ ’ symbol still produces Greek perispomeni in combinations with vowels as well as the ‘=’ sign does.

• All Greek font packages for TEX traditionally included some ligatures for sigma, so that it is possible to type the same symbol ‘s’ each time we need this letter, and its final form will be produced automatically in certain conditions. I think, this approach is essentially incorrect, since in some situations using of the final sigma can’t be controlled by a rather simple algorithm. What’s why psgreek fonts don’t include any ligatures for final sigma; in order to produce this form you have to type it manually (this symbol corresponds to the Latin letter ‘c’ in the Babel’s transliteration).

3 Moving to Omega

Although the Babel system has rather good support for polytonic Greek, still there are some problems, which can’t be resolved on any 8-bit platform. Suppose, for example, that you have typed the pronoun A>ut'oc. Here the combination >u is a ligature, used to produce the symbol with the code 0xCE, which corresponds to upsilon with psili in the LGR encoding. However, using this ligature breaks kerning between capital Alpha and upsilon with psili. Of course, you can type the later symbol directly, for example: A^^cet'oc. In this case you will get a correct kerning, but your hyphenation will be broken, since Greek hyphenation patterns contain something like a>u1, but not a^^ce1. And even if you add such a pattern, the result will be rather unexpected, since you have to additionally set \catcode and \lccode for the 0xCE symbol, which will affect some other symbols in your multilingual texts.

With Omega we haven’t such problems. First, we needn’t any ligatures, since Omega either takes all Greek accented letters directly from a *.tex file using utf-8 or ucs-2 encoding, or produces them with its own translation processes. Second, we can use Unicode hyphenation patterns, and set \catcode and \lccode for our Greek letters as necessary. That’s why in this release of the psgreek package I included Unicode virtual fonts for Omega in the Omega’s ovf format. However, these fonts are not compatible with Yannis Haralambous’ default omlgc font, since they use more strict Unicode encoding. If you wish to use psgreek package with Omega, download my antomega package from /systems/omega/contrib and load it instead of the default omega.sty file.

4 Installation

Below, we assume that your TEX system is compliant to the TDS (TEX Directory Structure) standard. If it is not so, refer to documentation of your TEX system for the proper locations of files of various types.

To install the psgreek font package in teTeX, fpTeX, MikTeX or VTeX/Free systems:

1. Copy all *.pfb, *.afm, *.tfm, *.vf, *.ofm and *.ovf files to the appropriate subdirectories in your .../texmf/fonts directory.

2. Create a subdirectory called psgreek in your .../texmf/tex/latex directory and put all *.fd files and the psgreek.sty file here. Note that all *.fd files having the ‘ut1’ prefix in their names are needed only for Omega,

and so you can put them to ../texmf/omega/lambda/psgreek instead.
3. Put the dvips/config/psgreek.map file to your .../texmf/dvips/config

directory.

4. (for VTeX/Free) Copy the vtex/config/psgreek.ali file to your

.../texmf/vtex/config/ directory.

5. Instruct your TeX (pdftex, vtex, etc.) or drivers (dvips, dvipdfm, etc.) to use your new fonts. To accomplish this, do one of the following points which corresponds to your TeX system (if it is not listed here, please refer to the documentation).

(a) (on teTeX, fpTeX and MikTeX) Instruct dvips and pdftex to use these fonts:

i. edit the file .../texmf/web2c/updmap.cfg and add the following line:

          Map psgreek.map

ii. run the updmap script.

(b) If your TeX system does not have tools like updmap for maintaining global MAP files (e. g. older MikTeX versions), you can instead configure each program which uses the Type 1 fonts:

      i. Edit the file .../texmf/dvips/config/config.ps and add the

following line:

          p + psgreek.map

ii. If you use pdftex, edit the file .../texmf/pdftex/pdftex.cfg and add the following line:

          map +psgreek.map

(c) (for VTeX/Free only) Edit the files .../texmf/vtex/config/ps.fm and .../texmf/vtex/config/pdf.fm, and add the following line into the TYPE1 section:

      cm-super.ali

6. (not for VTeX/Free) Update the filename search database: run ”mktexlsr” on teTeX, TeX Live, or fpTeX; run ”initexmf.exe -u” on MikTeX (or do the same via a menu item).

5 Usage

The psgreek package requires babel to be loaded either with ‘greek’ or ‘polutonikogreek’ option. So, put in your preamble something like

 \usepackage[polutonikogreek,english]{babel}

After loading babel you can load psgreek, as most L^{A}TEX packages, with the

\usepackage command.

psgreek supports the following package options: regular, garamond, oxonia, oldface, milan, kerkis, cmr, cmss, and cmtt. These options correspond to the Greek fonts that are supported by psgreek by default; using these options will make psgreek use a certain Greek font as roman font family whenever Babel switches to Greek text.

In addition, it is now possible to use package options in keyval syntax. With these options it is possible to change the Greek sans serif or typewriter fonts. The keys used are rmfont (roman font), sffont (sans serif font) and ttfont (typewriter font). So the user can now say

something like \usepackage[sffont=oxonia,garamond]{psgreek} (or equally
\usepackage[sffont=oxonia,rmfont=garamond]{psgreek}). (These are just

examples, and are not meant serious!)

6 The psgreek.sty code^{1}

6.1 Beginning of the Package

 1 ⟨psgreek⟩\NeedsTeXFormat{LaTeX2e}
 2 \ProvidesPackage{psgreek}
 3  [2003/04/16 Babel support for Greek PostScript fonts]
 4 \RequirePackage{keyval}

First, we have to check if Babel was loaded either with ‘greek’ or ‘polutonikogreek’ option.

 5 \@ifundefined{greektext}{%
 6  \PackageError{psgreek.sty}%
 7  {Sorry, but probably you did not load^^J
 8  babel with greek option!}%
 9  {The psgreek package requires the
10  babel system to be loaded^^J%
11  either with `greek' or `polutonikogreek' option.}%
12  }{%

13 }

6.2 Greek font declarations

\DeclareGreekFont The psgreek user interface works with font name aliases rather than the font names themselves, so the user does not have to remember the sometimes rather cryptic font names. E. g., instead of fof or hml we use the aliases oxonia and milan. These aliases have to be declared before they can be used. This is done with the \DeclareGreekFont command, which takes two arguments: the alias

1The following code was written mainly by Christian Justen <christian@justen-mack.de>.

and the ‘real’ font name, e. g. \DeclareGreekFont{oxonia}{fof}. psgreek itself

uses this command to declare the aliases for the Greek fonts it supports by default.

If you want to use an additional Greek font, you have to make it known to psgreek in the same way. (This user defined font is, of course, only accessible via the \greekfont command, not via the package options!)

14 \newcommand{\DeclareGreekFont}[2]{%
15  \expandafter\def\csname greekfont@#1\endcsname{#2}%

16 }

\check@forgreekfont The \check@forgreekfont command tests whether a font alias has been declared with the \DeclareGreekFont command and sets either \@tempswatrue

or \@tempswafalse.
17 \newcommand{\check@forgreekfont}[1]{%
18  \@ifundefined{greekfont@#1}{%
19  \PackageError{psgreek.sty}%
20  {Greek font #1 not yet defined!}%
21  {In order to use a Greek font
22  (compatible to the babel system)^^J%
23  you have to declare it using the
24  \string\DeclareGreekFont\space command:^^J%
25  \string\DeclareGreekFont{#1}{nnn}^^J%
26  where nnn specifies the font family.}%
27  \@tempswafalse%
28  }{%
29  \@tempswatrue%
30  }%

31 }

We can now use \DeclareGreekFont to provide some meaningful names for the fonts which can be used with the psgreek package.

• Original WinGreek font, of course:

32  \DeclareGreekFont{regular}{wgr}

• Greek Garamond by Carmelo Lupini:

33  \DeclareGreekFont{garamond}{fgm}

• Greek Oxonia font:

34  \DeclareGreekFont{oxonia}{fof}

• Two fonts by Ralph Hancock:

35  \DeclareGreekFont{oldface}{hof}
36  \DeclareGreekFont{milan}{hml}

• Kerkis is a font family created by Antonis Tsolomitis. It comes with its own L^{A}TEX package, but, if you use kerkis only for your Greek text, you may want to load it using psgreek instead.

37  \DeclareGreekFont{kerkis}{mak}

• And finally the roman, sans serif and typewriter style families of the ‘original’ Computer Modern Greek fonts:

38  \DeclareGreekFont{cmr}{cmr}
39  \DeclareGreekFont{cmss}{cmss}
40  \DeclareGreekFont{cmtt}{cmtt}

6.3 Font selection commands

We need some variables which will be used to store the three Greek font families:

\greek@rmfamily the roman family,
41 \let\greek@rmfamily\relax

\greek@sffamily the sans serif family,

42 \let\greek@sffamily\relax

\greek@ttfamily and the typewriter family.

43 \let\greek@ttfamily\relax

Now we define a set of keys: rmfont, sffont and ttfont. They are used to set the font variables to their proper value following the keyval syntax. These keys can be used in the optional argument of the \greekfont command and in the package options.

44 \define@key{psgreek}{rmfont}{%
45  \check@forgreekfont{#1}%
46  \if@tempswa\def\greek@rmfamily{\csname greekfont@#1\endcsname}\fi%

47 }

48 \define@key{psgreek}{sffont}{%
49  \check@forgreekfont{#1}%
50  \if@tempswa\def\greek@sffamily{\csname greekfont@#1\endcsname}\fi%

51 }

52 \define@key{psgreek}{ttfont}{%
53  \check@forgreekfont{#1}%
54  \if@tempswa\def\greek@ttfamily{\csname greekfont@#1\endcsname}\fi%

55 }

\greekfont You can specify the Greek fonts to be used not only via the package options, but also within your document using the \greekfont command. \greekfont takes one argument (like \greekfont{garamond}) and changes the Greek roman font family accordingly. (This argument can be empty, though!)

Additionally, \greekfont can take an optional argument, containing an option list in keyval syntax. The keys are the same as for the package options. It is possible to say

 \greekfont[sffont=oxonia]{garamond}

or even

 \greekfont[rmfont=garamond,sffont=oxonia]{}

The \greekfont command simply passes its arguments to keyval’s \setkeys mechanism.

56 \newcommand{\greekfont}[2][]{%
57  \def\@temp{#2}%
58  \ifx\@temp\@empty\else\setkeys{psgreek}{rmfont=#2}\fi%
59  \setkeys{psgreek}{#1}%

60 }

6.4 Declaration of options and default values

We want a set of options with names corresponding to the aliases we have already defined. These options specify the roman family only!

61 \DeclareOption{regular}{\greekfont{regular}}
62 \DeclareOption{garamond}{\greekfont{garamond}}
63 \DeclareOption{oxonia}{\greekfont{oxonia}}
64 \DeclareOption{oldface}{\greekfont{oldface}}
65 \DeclareOption{milan}{\greekfont{milan}}
66 \DeclareOption{kerkis}{\greekfont{kerkis}}
67 \DeclareOption{cmr}{\greekfont{cmr}}
68 \DeclareOption{cmss}{\greekfont{cmss}}
69 \DeclareOption{cmtt}{\greekfont{cmtt}}

But we also want to have package options in keyval syntax that allow us to specify the sans serif and typewriter families easily. This is done by passing all unknown options as optional arguments to the \greekfont command.

70 \DeclareOption*{%
71  \edef\@temp{\noexpand\greekfont[\CurrentOption]{}}%
72  \@temp%

73 }

The original WinGreek font is the most commonly used, so we load it by default as roman font. Additionally we load cmss and cmtt as default sans serif and typewriter fonts. And of course we have to process the option list.

74 \greekfont[sffont=cmss,ttfont=cmtt]{regular}
75 \ProcessOptions*

6.5 Language switching commands

greek Using Babel’s standard language switching commands is sometimes a bit tiresome. \localgreek So we provide the greek environment and the \localgreek command to make

things a bit easier, especially since they are compatible with language support packages used with Omega.

76 \newenvironment{greek}{\begin{otherlanguage}{greek}}{\end{otherlanguage}}
77 \newcommand{\localgreek}[1]{\foreignlanguage{greek}{#1}}

6.6 Redefining some commands provided by Babel

First we need some variables to store the current font families (we need those again when we go back to ‘normal’ non-Greek text).

78 \let\old@rmdefault\relax
79 \let\old@sfdefault\relax

 80 \let\old@ttdefault\relax
 81 \let\old@font@family\relax

\greektext is executed by Babel every time we switch to Greek. We modify this command so that it tries to detect whether the current font family is a sans serif or typewriter family. If so, we use the appropriate Greek families, otherwise we use the Greek roman family.

 82 \DeclareRobustCommand{\greektext}{%
 83 \let\old@font@family\f@family%
 84 \let\old@rmdefault\rmdefault%
 85 \let\old@sfdefault\sfdefault%
 86 \let\old@ttdefault\ttdefault%
 87 \fontencoding{LGR}%
 88 \edef\@temp{\sfdefault}%
 89 \ifx\f@family\@temp%
 90  \fontfamily{\greek@sffamily}%
 91 \else%
 92  \edef\@temp{\ttdefault}%
 93  \ifx\f@family\@temp%
 94  \fontfamily{\greek@ttfamily}%
 95  \else%
 96  \fontfamily{\greek@rmfamily}%
 97  \fi%
 98 \fi%
 99 \selectfont%
100 \def\encodingdefault{LGR}%
101 \def\rmdefault{\greek@rmfamily}%
102 \def\sfdefault{\greek@sffamily}%
103 \def\ttdefault{\greek@ttfamily}%

104 }

\latintext is executed by Babel when we finish with the Greek text (and in fact some times more often). We simply have to restore the old font family values.

105 \DeclareRobustCommand{\latintext}{%
106 \fontencoding{\latinencoding}%
107 \ifx\old@font@family\relax\else\fontfamily{\old@font@family}\fi%
108 \selectfont%
109 \def\encodingdefault{\latinencoding}%
110 \ifx\old@rmdefault\relax\else\let\rmdefault\old@rmdefault\fi%
111 \ifx\old@sfdefault\relax\else\let\sfdefault\old@sfdefault\fi%
112 \ifx\old@ttdefault\relax\else\let\ttdefault\old@ttdefault\fi%

113 }

When we have done with the Greek text, it is better to ‘empty’ the font family variables, so no unwanted side effects can occur.

114 \addto\noextrasgreek{%
115  \let\old@font@family\relax%
116  \let\old@rmdefault\relax%
117  \let\old@sfdefault\relax%
118  \let\old@ttdefault\relax%

119 }

120 \let\noextraspolutonikogreek\noextrasgreek

Now, that’s it!

121 \endinput