# Would it be possible to port the fontawesome package to pdflatex?

I really like the `fontawesome` package and it has almost every fancy symbol I need for my documents.

Now I'm working with a third party document which must use pdflatex, and I really miss the fontawesome symbols.

What would it take to port the existing package to pdflatex? Is it a trivial task or does it require some major rewriting?

• It's probably easier to migrate the mentioned document to XeLaTeX or LuaLaTeX. Feb 4 '14 at 18:30
• possible but non trivial pdftex can handle at most 256 characters per font and can't read opentype fonts so you'd need to split the font into some custom encoded 256 character fonts, derive the font metric tfm files (from somewhere) and then the relatively easier part of writing the tex code to map the input character commands to whatever positions in the custom font encodings you defined. It would be easier (much) for a single document just to make a scalable image of each of the characters you need and include it as an image. Feb 4 '14 at 18:33
• @DavidCarlisle: pdftex can read opentype fonts (but can't subembed them). And with the LCDF-tools it is rather easy to create pfb-fonts and the tfm from the otf (with otfinfo you can get the glyph list and write the necessary .enc files). Feb 4 '14 at 19:21
• @UlrikeFischer (ah things move on since I last checked the details last century:-) Feb 4 '14 at 20:08
• It’s possible, if one uses images instead of characters: One could extract the glyphs, e.g from `fonts/fontawesome-webfont.svg` (note) and include the resulting SVG or PDF files with `\includegraphic` (or `\includesvg` from the `svg package). You’ll probably lose some of the combining options. I agree, though, that it’s probably easier to just use XeTeX or LuaTeX, except if you want to make a package for the remaining pdfTeX users out there. Feb 5 '14 at 13:00

As some commenters have pointed out, it is not trivial, but not that complicated either thanks to `lcdf-tools`.

It was actually done for `fontawesome` as of version 4.3.0, and here is a synthesis of how it was done:

• Identify the glyphs in the original font. For an OpenType font, `otfinfo -g` will give you the internal name of every glyph present in the font;
• Generate an encoding (`.enc`) file for the font, listing every glyph by its internal name;
• Convert the original font to Type1 (Printer Font Binary, `.pfb`) + TeX Font Metric (`.tfm`). For an OpenType font, `otftotfm` combined with the encoding file you generated will do the job automatically;
• Add mapping information lines to your doc / style / class to tell `dvips`, `pdftex` and `dvipdfm` how to use your converted font:

``````\pdfmapline{+FontAwesome--fontawesome FontAwesome "fontawesome ReEncodeFont" <[fontawesome.enc <FontAwesome.pfb}
\font\FA=FontAwesome--fontawesome.enc
``````

where `FontAwesome--fontawesome(.tfm)` is the filename of the TeX Font Metric file, `FontAwesome(.pfb)` the filename of the Type1 conversion and `fontawesome(.enc)` the filename of the encoding file. The second line creates a font shortcut (`\FA`); and

• Optionally, create specific commands to access your glyphs, if you don't want to access to access them by their glyph rank in your encoding file (e.g., `\symbol{13}`).

If your symbol font has more than 256 glyphs, you will need to repeat this process (and create multiple TeX fonts), as each encoding file can only reference 256 glyphs.

If you want to know the details, the python code used for `fontawesome` is available on github.

• Unfortunately, the package does not set the fonts up correctly for use in (pdf)LaTeX. In particular, the declarations `\font...` are wrong. Among other things, they result in non-scalable characters which are entirely unresponsive to resizing commands.
– cfr
Aug 9 '15 at 0:22
• To be clear: `\font\FA=FontAwesome--fontawesome.enc` is wrong.
– cfr
Aug 9 '15 at 0:24

As explained in this question and the answers to it, the package already supports pdfTeX but the fonts are not correctly configured for LaTeX. Add the following (or the equivalent code from another answer there) to your preamble to correct the issue:

``````\usepackage{fontawesome}
\DeclareFontFamily{U}{FontAwesomeOne}{}
\DeclareFontShape{U}{FontAwesomeOne}{m}{n}{<-> FontAwesome--fontawesomeone}{}
\DeclareRobustCommand\FAone{\fontencoding{U}\fontfamily{FontAwesomeOne}\fontseries{m}\fontshape{n}\selectfont}
\DeclareFontFamily{U}{FontAwesomeTwo}{}
\DeclareFontShape{U}{FontAwesomeTwo}{m}{n}{<-> FontAwesome--fontawesometwo}{}
\DeclareRobustCommand\FAtwo{\fontencoding{U}\fontfamily{FontAwesomeTwo}\fontseries{m}\fontshape{n}\selectfont}
\DeclareFontFamily{U}{FontAwesomeThree}{}
\DeclareFontShape{U}{FontAwesomeThree}{m}{n}{<-> FontAwesome--fontawesomethree}{}
\DeclareRobustCommand\FAthree{\fontencoding{U}\fontfamily{FontAwesomeThree}\fontseries{m}\fontshape{n}\selectfont}
``````

Then all should work well....