Fontawesome 无法扩展

Fontawesome 无法扩展

编辑:@cfr 说,在新版本 4.4.0 中这个错误已经修复。

我已经编写了一个小样本来测试,如果fontawesome 脚本(v. 4.3.0-1)可以根据我的需要缩放字体大小,但是却不行 :(

\documentclass{article}
\usepackage{fontawesome}

\begin{document}

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

\end{document}

我已经用 pdflatex 渲染了 tex 文件。

渲染文本

我是否遗漏了什么?

答案1

该 sty 的作者没有编写代码以使字体可以缩放。您可以对其进行调整:

\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}

在此处输入图片描述

您必须为\FAtwo和写出类似的定义\FAthree

答案2

fontawesome.sty文件做了一件非常错误的事情。在它的结尾你会发现

%-------------------------------------------------------------------------------
%                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

众所周知,\font在 LaTeX 中使用总是错误的。

您可以通过正确定义来修复它\FAone\FAtwo\FAthree做正确的事情:

\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}

在此处输入图片描述

包中的正确代码应该是

%-------------------------------------------------------------------------------
%                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

答案3

软件包作者已更正软件包,以提供适合 LaTeX 的配置,并且软件包现在支持使用 (pdf)TeX 进行缩放。使用当前 CTAN 版本 (v4.4.0)(现在也包含在 TeX Live 中),OP 的 MWE:

\documentclass{article}
\usepackage{fontawesome}

\begin{document}

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

\end{document}

产生预期的输出:

预期输出

因此,如果您安装了该软件包的更新副本,则这里其他答案中讨论的手动更正就不再需要了;)。

答案4

作为Ulrike Fischer 表示,该软件包没有为 pdfLaTeX 正确设置字体。因此,无法使用普通的字体大小调整命令缩放它们。这是特定于 pdfLaTeX 的使用,并不影响 XeLaTeX/LuaLaTeX。

在我写答案的时候,Ulrike Fischer 发布了她的答案。由于我的答案包含更完整的配置,我希望她不会介意我发布它。

\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}

示范

还值得注意的是,除了软件包作者的决定之外,没有任何理由不能将这些字体用于常规 TeX 引擎。但是,据我所知,目前对 pdfLaTeX 的支持有限,对 LaTeX 的支持则完全没有。

相关内容