19

I want to install some fonts that I have in OTF format for use in LaTeX.

I learned that I should use otfinst.py, but I have absolutely no idea how. The manual is by far the worst ever I've seen.

I have three files, that I'd like to convert: Crimson-Roman.otf, Crimson-Bold.otf, Crimson-Italic.otf, and Crimson-BoldItalic.otf.

The script asks for a "berryname" which I have no Idea where to set it, or what it should be. I want to use the old-style numerics in that font, how do I generate them, and how do I select them in LaTeX?

And what about all the other textual replacements in the OTF file, do those glyphs get converted, too?

And what's the deal with the font encoding? It uses Ly1, what is that? I need UTF-8 if that has anything to do with it.

2

2 Answers 2

14

Here is a good news for you: if you use XeTeX or LuaTeX, you don't have to convert OTF fonts, you can just use them directly by installing them in your system.

Here is an example on Ubuntu:

$ sudo cp EBGaramond.otf /usr/local/share/fonts
$ sudo fc-cache /usr/local/share/fonts
$ fc-list | grep Garamond
EB Garamond:style=Regular

and then you can use it in LaTeX:

\usepackage{fontspec}
\usepackage{xunicode}
\defaultfontfeatures{Mapping=tex-text}
\setmainfont{EB Garamond}

All OpenType features are available via fontspec. See for example this project which makes an heavy use of OpenType features with XeTeX.

So unless you heavily rely on specific PDFTex functionalities, I would really recommend you use XeTeX (or LuaTeX) if you want to use OTF fonts.

6
  • I'll take a look at it, I've installed xetex, and see if I can can switch from pdflatex. Is it possible to have local font directories? like ~./fonts (this is where I keep my locally installed fonts) or something?
    – polemon
    Aug 2, 2011 at 8:56
  • Using ~.fonts should be possible with fontconfig (fc-list, fc-cache and friends). fontspec also lets you use local files if you prefer, by giving the name of the font file instead of the name returned by fc-list.
    – raphink
    Aug 2, 2011 at 9:01
  • As a note, when switching to XeTeX, you have to get rid of the encoding lines such as \usepackage[utf8x]{inputenc} since XeTeX supports UTF-8 natively. Also get rid of \usepackage[T1]{fontenc} if you use it.
    – raphink
    Aug 2, 2011 at 9:02
  • Great, I'll check later today, and accept your answer when I'm happy with what I got.
    – polemon
    Aug 2, 2011 at 9:05
  • 2
    Please don't accept this answer without changing the question. It does not answer the question you asked.
    – frabjous
    Aug 2, 2011 at 13:18
16

I have successfully converted Adobe Garamond Pro some time ago. Proceed at own risk.

Start with creating a directory where you put the OTF files and the script otfinst.py. You need to configure the script to fit your requirements.

1. Set the encoding

For T1, the relevant part of the script should be edited as the following:

encoding = 'T1'
encodings = { 'T1':
              { 'berryencoding': '8t',
                'commandline': '-e fontools_t1',
                },
              }

2. Set where to put the fonts

Using kpsewhich, the script finds your TEXMFHOME directory automatically, but it needs to be told the location for fonts. I am not sure about other operating systems, but using MacTeX with Mac OS X, there are three possible directories:

  • /usr/local/texlive/2011 – requires root access; should not be modified by a user;
  • /usr/local/texlive/texmf-local – requires root access;
  • ~/Library/texmf – this is the TEXMFHOME that kpsewhich finds, so you need to specify the route from here.

The route in the script is already set correctly: localfontsdir = '/tex/latex/localfonts/'

3. Which OpenType options to support

As the script clearly explains, it picks one choice from each element and takes all permutations. Kerning and ligatures are always selected and one of the additional choices is support for old numerals (onum), so it should satisfy your needs.

4. Set the Berry name

The Berry names are used by LaTeX to identify the font family and corresponding fonts. There is also Berry encoding for options, such as lining numerals, old numerals, bold, semibold, etc. I am not an expert, but I think that by combining these two, LaTeX chooses the appropriate files (as I can do the same manually).

If your font family is not included in this document, you should run otfinfo --family to get its name and then make a custom Berry name. Therefore:

$otfinfo --family Crimson-Roman.otf

Suppose the output was Crimson. Think of an original 3-letter designation (not to interfere with existing fonts), e.g. c12 and edit the script accordingly:

berryname = { 'Minion Pro' : 'pmn',
                                            <missing part>
          'Hypatia Sans Pro' : 'phy',
          'Crimson' : 'c12',
          }

5. Save and run

Save and run the script. In Mac OS X, cd to the directory containing the fonts and the script and run:

$sudo python otfinst.py Crimson*

Enter the root/superuser password (because of texhash at the end) and you should see the activity. After the script ends, it runs the mentioned texhash, but I had to run it again myself later as I did not have nfssext-cfr.sty. Anyway, you should now explore the configured localfonts directory inside TEXMFHOME and there should be a file called crimson.sty. Open it to see the available commands e.g. to set old numerals. You may need to download the nfssext-cfr.sty in case you do not already have it (put it in the same directory and run $sudo texhash again).

6. Test

Create a test file with \usepackage{crimson} in the preamble and compile using pdfTeX. It should be working properly.

2
  • 2
    To clarify my intentions when writing this answer, I agree that if there is a possibility to use XeTeX/LuaTeX, it is better to do so rather than converting fonts, but since I have not found any clear explanation of the process, I decided to create a guide just after I succeeded. However, as it is not rocket science, putting it on CTAN is probably excessive, so tex.sx seemed to be ideal and this question was a perfect opportunity. I do not encourage the OP to prefer conversion to XeTeX/LuaTeX. Aug 2, 2011 at 14:52
  • absolutely, your how-to is much appreciated
    – polemon
    Aug 2, 2011 at 16:27

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .