5

A while ago I found Type-1 font and wanted to use it in LaTeX. I posted the problem and community helped me to solve it - please take a look here.

So now I found a TTF font and my question is: "What is a procedure to make TTF font LaTeX-ready?"

I am on Linux, so I have lots of tools at my disposal. Using XeTeX or LuaTeX is not part of this topic and should be avoided because solution with using these engines was solved here.

6

Most of the procedure is identical to the one I outlined in my answer concerning type1 fonts. Here, I will focus only on the additional complications involved in dealing with TTF fonts. I will ignore some rarer complications which do not apply to most cases and focus on only the standard complications.

You have two choices.

Option 1

Convert the font to type1 format and then proceed as described in the other answer.

Advantages:

  • works with the traditional TeX engine;
  • fewer complications involved in preparing the support files: you deal with one complication (conversion) and you are done.

Disadvantages:

  • conversion inevitably involves some loss of quality, as I understand it, since the two font formats specify curves in different ways;
  • the font licence may not permit conversion.

Various tools are available to perform the conversion. FontForge is probably the most obvious example. If the font is suitable, you could alternatively use autoinst to convert it, prepare most of the required files and install it. I'm not very keen on autoinst and friends myself, but this method is probably more popular than the fontinst route because it is more automatic.

Option 2

Use the truetype font without converting to type1.

Advantages:

  • no loss of quality;
  • compatible with more font licences, although possibly not all.

Disadvantages:

  • cannot be used with traditional TeX, but requires pdfTeX;
  • somewhat more complex because adjustments are needed at various points in the installation process.

To use this method, I would normally begin by doing the following:

  • rename the files appropriately;
  • use ttf2afm to produce an AFM file for each TTF.

Normally, this is straightforward. Very occasionally, there are complications. ttf2afm might complain, for example, that it cannot accommodate all kerning pairs. There isn't much you can do about this and I'd just carry on. If you get more serious problems, you can try using FontForge to produce AFMs, but more serious errors usually means that the TTF is so poorly designed that the font is hopeless and it is better to quit before sinking more time into it.

Then proceed with the fontinst process as before with the following changes:

  • XYZ-map.tex should be adjusted as follows:

    \input finstmsc.sty
    \resetstr{PSfontsuffix}{.ttf}
    \adddriver{dvips}{XYZ.map}
    \adddriver{pltotf}{XYZ-pltotf.sh}
    \input XYZ-rec.tex
    \donedrivers
    \bye
    

    where XYZ is the prefix you're using (e.g. sckin the linked example).

  • XYZ.styshould be adjusted as follows:

    \NeedsTeXFormat{LaTeX2e}
    \ProvidesPackage{XYZ}[2016/06/21 v1.0 XYZ]
    
    %%We don't want to add the map file through updmap because only pdftex can use truetype fonts.
    \pdfmapfile{+XYZ.map}
    
    \DeclareOption{default}{%
            \renewcommand{\sfdefault}{XYZ}}
    \ProcessOptions
    \DeclareRobustCommand{\XYZfamily}{%
            \fontseries{m}%
            \fontshape{n}%
            \fontfamily{XYZ}%
            \selectfont}
    \DeclareTextFontCommand{\XYZ}{\XYZfamily}
    \endinput
    

Proceed to test the font, deleting \pdfmapfile{+XYZ.map} from the test document since it is included in the package file.

If all is well, install the font as for type1 with the following changes:

  • replace

    mkdir -p <TEXMFLOCAL>/fonts/type1/public/XYZ
    

    with

    mkdir -p <TEXMFLOCAL>/fonts/truetype/public/XYZ
    

    and

    mv *.pfb *.pfm <TEXMFLOCAL>/fonts/type1/public/XYZ/
    

    with

    mv *.ttf <TEXMFLOCAL>/fonts/truetype/public/XYZ/
    
  • do NOT run updmap-sys !!

Retest.


The idea here is to avoid including the font in the mappings used by TeX because the font will not work with the traditional engine. Instead, the mappings are added when the package is loaded in a way which is specific to pdfTeX. If the traditional engine is used, this will generate an error complaining of an undefined control sequence including the string pdf which should make it easy to diagnose the problem.

| improve this answer | |
  • Thank you very much again for your answer. It will take me some time to try this out and I will respond here when I succeed or if more questions arise. – 71GA Jun 21 '16 at 6:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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