10

Edit: @cfr said, that in the new version 4.4.0 the bug was fixed.

I have written a small sample to test, if the fontawesome script (v. 4.3.0-1) scales up with the font size which I want, but it doesn't :(

\documentclass{article}
\usepackage{fontawesome}

\begin{document}

{Normal \faAdjust}
{\Huge Huge \faAdjust}

\end{document}

I have rendered the tex file with pdflatex.

rendered tex

Do I miss something?

3
  • 2
    Welcome! Is XeLaTeX or LuaLaTeX an option? Because it works fine with those.
    – cfr
    Jul 28 '15 at 22:09
  • Well, I had have many renderer problems, with both of them in my TeXnicCenter / MiKTeX setup. So I looked for a way with pdflatex ;)
    – Nachtgold
    Jul 28 '15 at 22:41
  • 1
    I recommend reporting this as a bug to the package author. The package ought not define the fonts for LaTeX this way. It is just wrong.
    – cfr
    Jul 28 '15 at 22:49
9

The author of the sty didn't wrote the code so that the font scales. You can adapt it:

\documentclass{article}

\usepackage{fontawesome}
\DeclareFontFamily{U}{fontawesomeOne}{}
\DeclareFontShape{U}{fontawesomeOne}{m}{n}
  {<-> FontAwesome--fontawesomeone}{}
\DeclareRobustCommand\FAone{\fontencoding{U}\fontfamily{fontawesomeOne}\selectfont} 
\begin{document}

{Normal \faAdjust}
{\Huge Huge \faAdjust}

\end{document}

enter image description here

You will have to write similar definitions for \FAtwo and \FAthree.

2
  • (+1) If you object to my posting my answer, let me know and I'll happily delete it. You posted while I was writing and mine took a bit longer, perhaps. (I am also probably slower.) I would usually use \DeclareRobustCommand here rather than \renewcommand but I am not entirely sure whether I need to do so or not. Is it just unnecessary in general or unnecessary here? Or is there some positive reason to avoid it?
    – cfr
    Jul 28 '15 at 22:34
  • 2
    @cfr I never delete answers (unless they are really wrong) and I don't expect other to do it. We are not at a race here. The world is large enough for all of us and for more than one answer with similar content. And you are right about the \DeclareRobustCommand. It was a bit late yesterday. Jul 29 '15 at 6:50
10

The fontawesome.sty file does a very wrong thing. At its end you find

%-------------------------------------------------------------------------------
%                pdflatex implementation
%-------------------------------------------------------------------------------
\else
% definition of \FA... as a shortcut to load the Font Awesome font
\pdfmapline{+FontAwesome--fontawesomeone FontAwesome "fontawesomeone ReEncodeFont" <[fontawesomeone.enc <FontAwesome.pfb}
\font\FAone=FontAwesome--fontawesomeone.enc
\pdfmapline{+FontAwesome--fontawesometwo FontAwesome "fontawesometwo ReEncodeFont" <[fontawesometwo.enc <FontAwesome.pfb}
\font\FAtwo=FontAwesome--fontawesometwo.enc
\pdfmapline{+FontAwesome--fontawesomethree FontAwesome "fontawesomethree ReEncodeFont" <[fontawesomethree.enc <FontAwesome.pfb}
\font\FAthree=FontAwesome--fontawesomethree.enc

% icon-specific commands
\input{fontawesomesymbols-pdftex.tex}

\fi

and it's well known that using \font in LaTeX is always wrong.

You can fix it by properly defining \FAone, \FAtwo and \FAthree to do the right thing:

\documentclass{article}
\usepackage{fontawesome}

\DeclareFontFamily{U}{fontawesome1}{}
\DeclareFontShape{U}{fontawesome1}{m}{n}{<->FontAwesome--fontawesomeone}{}
\DeclareFontFamily{U}{fontawesome2}{}
\DeclareFontShape{U}{fontawesome2}{m}{n}{<->FontAwesome--fontawesometwo}{}
\DeclareFontFamily{U}{fontawesome3}{}
\DeclareFontShape{U}{fontawesome3}{m}{n}{<->FontAwesome--fontawesomethree}{}
\DeclareRobustCommand{\FAone}{\usefont{U}{fontawesome1}{m}{n}}
\DeclareRobustCommand{\FAtwo}{\usefont{U}{fontawesome2}{m}{n}}
\DeclareRobustCommand{\FAthree}{\usefont{U}{fontawesome3}{m}{n}}

\begin{document}

{Normal \faAdjust}
{\Huge Huge \faAdjust}

\end{document}

enter image description here

The correct code in the package should be

%-------------------------------------------------------------------------------
%                pdflatex implementation
%-------------------------------------------------------------------------------
\else
% definition of \FA... as a shortcut to load the Font Awesome font
\pdfmapline{+FontAwesome--fontawesomeone FontAwesome "fontawesomeone ReEncodeFont" <[fontawesomeone.enc <FontAwesome.pfb}
\pdfmapline{+FontAwesome--fontawesometwo FontAwesome "fontawesometwo ReEncodeFont" <[fontawesometwo.enc <FontAwesome.pfb}
\pdfmapline{+FontAwesome--fontawesomethree FontAwesome "fontawesomethree ReEncodeFont" <[fontawesomethree.enc <FontAwesome.pfb}

\DeclareFontFamily{U}{fontawesome1}{}
\DeclareFontShape{U}{fontawesome1}{m}{n}{<->FontAwesome--fontawesomeone}{}
\DeclareFontFamily{U}{fontawesome2}{}
\DeclareFontShape{U}{fontawesome2}{m}{n}{<->FontAwesome--fontawesometwo}{}
\DeclareFontFamily{U}{fontawesome3}{}
\DeclareFontShape{U}{fontawesome3}{m}{n}{<->FontAwesome--fontawesomethree}{}
\DeclareRobustCommand{\FAone}{\usefont{U}{fontawesome1}{m}{n}}
\DeclareRobustCommand{\FAtwo}{\usefont{U}{fontawesome2}{m}{n}}
\DeclareRobustCommand{\FAthree}{\usefont{U}{fontawesome3}{m}{n}}

% icon-specific commands
\input{fontawesomesymbols-pdftex.tex}

\fi
4
  • 1
    I hadn't seen it yesterday - it was a bit late - but now I wonder what the .enc is doing at the end of the fontname and why it works if one uses it (it works without it too, the font name in the pdfmapline command in the sty doesn't have it, and the tfm doesn't have the .enc in its name. ). Looks as if latex is removing the .enc silently. Jul 29 '15 at 6:55
  • 1
    @UlrikeFischer I trusted the package author. ;-)
    – egreg
    Jul 29 '15 at 7:23
  • 2
    @egreg - I notified the package author a week ago or so about this (incl. some suggestions to rectify it). The package should provide a separate fontawesome.map and some ufontawesome[one|two|three].fd. After that, the font can also be used with LaTeX/dvips and it goes the standard LaTeX way. The package respositoy is here. Jul 29 '15 at 7:45
  • @ArashEsbati It would be surely a good thing.
    – egreg
    Jul 29 '15 at 7:57
4

As Ulrike Fischer said, the package does not set the fonts up correctly for pdfLaTeX. As a result, they cannot be scaled using the ordinary font sizing commands. This is specific to the use of pdfLaTeX and does not affect XeLaTeX/LuaLaTeX.

Ulrike Fischer posted her answer while I was writing mine. Since mine includes a more complete configuration, I hope that she will not mind my posting it.

\documentclass{article}
\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}

\begin{document}

{Normal \faAdjust}
{\Huge Huge \faAdjust}

\end{document}

demonstration

It is also worth noting that there is no reason - besides the package author's decisions - that the fonts cannot be used with the regular TeX engine as well. However, as it is there is limited support for pdfLaTeX and none at all for LaTeX, so far as I can tell.

6
  • There's no need at all to define all shape/series combinations.
    – egreg
    Jul 28 '15 at 22:34
  • @egreg I prefer to define them and not get spurious warnings about missing fonts. I agree that it is not necessary in the sense that it will work without. But it clutters the console output and the log file with warnings I don't need to worry about which makes it harder to find the ones I should pay attention to.
    – cfr
    Jul 28 '15 at 22:38
  • 1
    I get no missing font warning with my code.
    – egreg
    Jul 28 '15 at 22:39
  • @egreg Thanks! You are right that in this case there is no reason not to stipulate the shape and series in the definition of the font command. In general, I specify additions because often there is a reason not to stipulate them in the definition of font commands, but I still prefer to avoid spurious console warnings. I've updated my answer. (Don't tell me I could use \usefont. I know but I don't like it. It makes it harder for me to understand what my code is doing. Harder for me, that is. I am not claiming it is a bad command in general.)
    – cfr
    Jul 28 '15 at 22:47
  • Look at line 2338 of latex.ltx. ;-)
    – egreg
    Jul 28 '15 at 22:49
4

The package author has corrected the package to provide an appropriate configuration for LaTeX and the package now supports scaling with (pdf)TeX. With the current CTAN version (v4.4.0), which is also now in TeX Live, the OP's MWE:

\documentclass{article}
\usepackage{fontawesome}

\begin{document}

{Normal \faAdjust}
{\Huge Huge \faAdjust}

\end{document}

produces the expected output:

expected output

Hence, if you have an updated copy of the package installed, the manual corrections discussed in the other answers here are no longer necessary ;).

0

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.