20

The following example must be compiled with XeLaTeX to reproduce the issue.

% arara: xelatex
\documentclass{article}
\usepackage{fontawesome}
\begin{document}
Text Text \faMobilePhone\ Text Text
\end{document}

Normally I am using TeXworks to compile and view the output. With the internal viewer I am getting the desired result. The following image demonstrates it:

enter image description here

However if I open the pdf with Preview (viewer of Mac) the scaling of the icon fails.

enter image description here

If I open the pdf file with Adobe Acrobat Reader the icon is still scaled correctly. If I print the page my printer is also not able to scale the icons correctly.

If I use LuaLaTeX everything seems to work correctly.

Can you reproduce the issue and do you know a solution?

Marco Daniel
  • 95,681
  • 3
    Confirmed; seems to be a problem with the PDF engine on Mac OS X. If opened with Adobe Reader the size is correct; both it and the internal viewer of TeXworks don't rely on the PDF toolkit of Mac OS X. – egreg Sep 19 '13 at 15:07
  • @egreg: Thanks for your replay. I couldn't find any related issue and I thought it was my flaw ;-). – Marco Daniel Sep 19 '13 at 15:16
  • Is it a CFF-flavoured OpenType font (usually with a .otf extension) with a non-1000 UPM? If yes, then it is a known bug. – خالد حسني Sep 19 '13 at 16:54
  • @KhaledHosny: Interesting. I am not enough familiar with fonts to know whether it's a non 1000 upm or not. But the bug seems to be similar. Thanks. – Marco Daniel Sep 19 '13 at 18:29
  • 2
    The .otf file available from http://fortawesome.github.io/Font-Awesome/, do indeed have a 1792 UPM size, so that is the bug. The only immediate solution is to convert the font to 1000 UPM units (using FontForge or similar). – خالد حسني Sep 19 '13 at 18:53
  • @KhaledHosny: Maybe you can write this as an answer. I think it's the best approach so far. – Marco Daniel Sep 19 '13 at 19:07
  • Under the Windows system and MiKTeX I have no problem. Alos, just in case: did you try with the latest version of the font? The package installs version 3.1.1 and latest is 4.2. – Bernard Sep 07 '14 at 20:39

2 Answers2

24

xdvipdfmx (XeTeX’s output driver) has a bug with handling CFF-flavoured OpenType fonts (fonts usually with a .otf extension) with non-1000 UPM. It is a known bug with no known fix, unfortunately.

The Font Awesome has a 1792 UPM, so it suffers from this bugs.

One possible work around is to change the font to use 1000 UPM. FontForge can do this easily, from the GUI Element → Font Info → General → Em Size and change the value to 1000 while keeping the [x] Scale Outlines selected, so that FontForge can do the necessary scaling to compensate for the UPM change. Then generate a new OTF file. Using FontForge’s Python scripting, this can be done as:

import fontforge
font = fontforge.open("FontAwesome.otf")
font.em = 1000
font.generate("FontAwesome-1000upm.otf")

Another solution is to just use the TTF version of the font, but I’m not sure how compatible is it with the OTF version encoding-wise.

Marco Daniel
  • 95,681
  • I'm facing the same trouble and, as I didn't succeed to generate the FontAwesome-1000upm.otf file, is it possible for you to make it available for download? BTW, what is then necessary (and sufficient)? Just to replace \newfontfamily{\FA}{FontAwesome} by \newfontfamily{\FA}{FontAwesome-1000upm} in the fontawesome.sty file? – Denis Bitouzé Jun 16 '14 at 16:20
7

Download https://fontawesome.com/v4.7.0/assets/font-awesome-4.7.0.zip

then under fonts, install ttf instead of otf and in your *.sty file replace

\newfontfamily{\FA}{FontAwesome} with \newfontfamily{\FA}{FontAwesome Regular}
Colin Dean
  • 103
  • 4
Omid
  • 71
  • 2
    While I don't doubt that this answer works, could you explain why it does? – ChrisS Aug 17 '14 at 10:33
  • thanks a lot! Just wanted to point out, that this solution also solved the "inverse problem" (wrong scaling in Adobe Reader; correct scaling in every other reader I tried) – JBantje Dec 01 '14 at 10:11