Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

Is there a way that text figures (old style numerals) can be set as default for text when loading the package tgpagella? I get them if I use the .otf files under XeLaTeX, but I'd like to get them when running pdfLaTeX.

share|improve this question
2  
I'm afraid this feature is not supported. –  egreg Aug 13 '12 at 20:01
1  
Related: tex.stackexchange.com/questions/2852/… –  lockstep Aug 13 '12 at 21:42
1  
Since you have some responses below that seem to answer your question, please consider marking one of them as ‘Accepted’ by clicking on the tickmark below their vote count (see How do you accept an answer?). This shows which answer helped you most, and it assigns reputation points to the author of the answer (and to you!). –  Martin Schröder Dec 1 '12 at 21:28
add comment

1 Answer

up vote 20 down vote accepted
+50

Old style numbers in TeX Gyre Pagella

The TeX Gyre fonts contain four sets of numbers. The names prefixed with / are the PostScript glyph names:

  • /zero, /one, /two, …
    The "normal" digits with equal widths, suitable for tabulars.

  • /zero.prop, /one.prop, /two.prop, …
    The "normal" digits with proportinal widths.

  • /zero.taboldstyle, /one.taboldstyle, /two.taboldstyle, …
    Old style digits with equal widths, suitable for tabulars.

  • /zero.oldstyle, /one.oldstyle, /two.oldstyle, …
    Old style digits with proportional widths.

The manual way

In the font setup for LaTeX only the digits with equal widths are available. The "default" are the "normal" digits with equal widths except for small caps. Manually you get old style numbers via package textcomp and \oldstylenums or via small caps:

\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage{textcomp}
\usepackage{tgpagella}

\begin{document}

0123456789\textdollar\textcent

\oldstylenums{0123456789}\textdollaroldstyle\textcentoldstyle

\textsc{0123456789\textdollar}

\end{document}

enter image description here

Patching the encoding

In the font map file qpl-ec.map, qpl.map or pdftex.map the font ec-qplr is used in the example above. The map line is:

TeXGyrePagella-Regular "encqec ReEncodeFont" <q-ec.enc <qplr.pfb

The encoding file q-ec.enc defines which glyphs are used for the slots of the font encoding:

% [some coment lines]
/encqenc [
/grave
/acute
...
/zero
/one
...
/nine
...
] def

There we could replace the glyph names for the digits. Let us copy the file to q-ec-taboldstyle.enc. There the digits are replaced by the variant with suffix .taboldstyle.

Now pdfTeX allows to replace the map line using \pdfmapline that should be used before the font is used. For example, this can be done right at the beginning of the TeX document:

\pdfmapline{=ec-qplr TeXGyrePagella-Regular "encqec ReEncodeFont" <q-ec-taboldstyle.enc <qplr.pfb}
\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage{tgpagella}
\begin{document}
0123456789
\end{document}

Then the numbes are set using /<num>.taboldstyle instead of /<num>:

0123456789

This trick does not change the font for LaTeX/TeX. The glyph metrics (TFM file) are not changed. Because we have used taboldstyle instead of oldstyle, the widths of the glyphs remain the same. However, some of the old style digits have a depth, that is not seen by LaTeX or TeX.

New TFM files

If the correct glyph metrics are needed, then we also need new TFM files. In our case we have ec-qplr.tfm (the base name is the first entry in the map line above). This can be converted to a more human readable form using tftopl:

tftopl ec-qplr.tfm ec-qplr.pl

The file ec-qplr.tfm needs the correct directory. The program kpsewhich can be used to look for the file. In Linux the can be combined to:

tftopl `kpsewhich ec-qplr.tfm` ec-qplr.pl

The character metrics for 0, 1, and 7 in ec-qplr.pl:

(CHARACTER C 0
   (CHARWD R 0.5)
   (CHARHT R 0.6775)
   )
(CHARACTER C 1
   (CHARWD R 0.5)
   (CHARHT R 0.6775)
   )
...
(CHARACTER C 7
   (CHARWD R 0.5)
   (CHARHT R 0.6775)
   (CHARIC R 0.025)
   )

CHARWD, CHARHT, CHARDP, and CHARIC specify the height, width, depth, and italic correction of the character.

Now these values need to be replaced by the values for our taboldstyle digits. Happily they are available in the TS1 encoding or file ts1-qplr.tfm. Alternatively the small caps font ec-qplr-sc.tfm can be used. Again we convert the .tfm file to the readable .pl format using tftopl. The result for 0, 1, 7:

(CHARACTER C 0
   (CHARWD R 0.5)
   (CHARHT R 0.464)
   (CHARDP R 0.0164995)
   (CHARIC R 0.003)
   )
(CHARACTER C 1
   (CHARWD R 0.5)
   (CHARHT R 0.4904995)
   (CHARDP R 0.0075)
   )
...
(CHARACTER C 7
   (CHARWD R 0.5)
   (CHARHT R 0.464)
   (CHARDP R 0.237999)
   (CHARIC R 0.025)
   )

This way we create a file ec-qplr-taboldstyle.pl with the changed metrics data for the old style digits. The .tfm file is generated by pltotf:

pltotf ec-qplr-taboldstyle.pl

Result: ec-qplr-taboldstyle.tfm.

Remark: TFM files are not available for the non-proportinal digits. Thus the metrics need to be guessed somehow. The AFM files contain the glyph bounding boxes that include side bearings and similar things that are not taken into account for the TeX metric data. But at least they can give a hint.

Now this font is added and does not replace the old entry for ec-qplr:

\pdfmapline{+ec-qplr-taboldstyle TeXGyrePagella-Regular "encqec ReEncodeFont" <q-ec-taboldstyle.enc <qplr.pfb}

In the next step we need a new font definition file for LaTeX and a new name for the font in LaTeX. Let us use qplrtosn. Then we copy the old .fd file to the new one, e.g. Linux:

 cp `kpsewhich t1qplr.fd` t1qplrtosn.fd

The new file needs some changes:

  • file name in \ProvidesFile,
  • font name in description text of \ProvidesFile,
  • date in \ProvidesFile,
  • font family name qplr is replaced by qplrtosn (second argument of \DeclareFont...),
  • TFM name ec-qplr is replaced by ec-qplr-taboldstyle,
  • then internal macro prefix \qpl@ by \qpltosn@ if we want to use both font families in the same document,

It makes sense to make new TFM files for the other fonts, too.

At last we need a new package file tgpagella-tosn.sty with changes from tgpagella.sty:

  • \ProvidesPackage,
  • internal prefix,
  • font family name,
share|improve this answer
    
I'm a bit overwhelmed by your answer. Thanks so much for that. I already have some problems at the patching stage, though. I have followed all the steps but when I try pdfLaTeXing your MWE I get the message !pdfTeX error: pdflatex.exe (file q-ec-taboldstyle.enc): cannot open encoding file for reading ==> Fatal error occurred, no output PDF file produced! I am using MikTeX 2.9 on Windows XP, and I have refreshed the FNDB, updated formats, and run initexmf -u as well as updmap. Any idea about what can be wrong? –  Marcos Aug 14 '12 at 7:34
    
Where have you put the file? –  Heiko Oberdiek Aug 14 '12 at 7:48
    
In the same folder as the original .enc file, namely, in the path of the main TEXMF root going as MikTeX 2.9\fonts\enc\dvips\tex-gyre. –  Marcos Aug 14 '12 at 8:11
    
For testing it is sufficient to put the file into the working directory. For serious installation the distribution tree is not the best place. MiKTeX makes it easy to add further "root" (texmf/TDS) trees. The important thing is to keep the directory layout, e.g. <texmf-root-dir>/fonts/enc/dvips/tex-gyre-oldstyle/q-ec-taboldstyle.enc. –  Heiko Oberdiek Aug 14 '12 at 8:24
2  
And all this because one doesn't want to use XeLaTeX or LuaLaTeX... –  Martin Schröder Aug 14 '12 at 18:59
show 1 more comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.