Avoid repeatedly checking for font availability
PATCH 1/1 Avoid repeatedly checking for font availability
Checking if a font is available is very expensive. Do it once and store the results in a macro.
This also provides an easy way to skip the check entirely.
No normative, informative, or even typesetting change.
Signed-off-by Demi Marie Obenour <[email protected]>
--- commands-pdf.tex | 12 ++++++------ virtio.tex | 26 +++++++++++++++++++++++--- 2 files changed, 29 insertions(+), 9 deletions(-)
commands-pdf.tex +6 -6
@@ -20,7 +20,7 @@ \newcommand{\oasistitle}[1] { \begin{spacing}{1.5} -\IfFontExistsTF{Arial}{\fontspec[Color=446CAA]{Arial}}{\fontspec[Color=446CAA]{Liberation Sans}} +\oasiscolor{} \fontsize{24}{24} \textbf{\noindent#1} \end{spacing}
@@ -29,7 +29,7 @@ \newcommand{\oasisstagelabel}[1] { \begin{spacing}{1.1} -\IfFontExistsTF{Arial}{\fontspec[Color=446CAA]{Arial}}{\fontspec[Color=446CAA]{Liberation Sans}} +\oasiscolor{} \fontsize{18}{18} \textbf{\noindent#1} \end{spacing}
@@ -38,7 +38,7 @@ \newcommand{\oasisdate}[1] { \begin{spacing}{1.1} -\IfFontExistsTF{Arial}{\fontspec[Color=446CAA]{Arial}}{\fontspec[Color=446CAA]{Liberation Sans}} +\oasiscolor{} \fontsize{18}{18} \textbf{\noindent#1} \end{spacing}
@@ -47,7 +47,7 @@ \newcommand{\oasisnoticelabel}[1] { \begin{spacing}{1.5} -\IfFontExistsTF{Arial}{\fontspec[Color=446CAA]{Arial}}{\fontspec[Color=446CAA]{Liberation Sans}} +\oasiscolor{} \fontsize{18}{18} \textbf{\noindent#1} \end{spacing}
@@ -56,7 +56,7 @@ \newcommand{\oasisspecificationuris}[1] { { -\IfFontExistsTF{Arial}{\fontspec[Color=446CAA]{Arial}}{\fontspec[Color=446CAA]{Liberation Sans}} +\oasiscolor{} \fontsize{12}{12} \textbf{\noindent#1} }
@@ -65,7 +65,7 @@ \newenvironment{oasistitlesection}[1] { \setlength{\tabcolsep}{0in}\begin{tabular}{p{0in}p{5.8in}} -\multicolumn{2}{l}{\IfFontExistsTF{Arial}{\fontspec[Color=446CAA]{Arial}}{\fontspec[Color=446CAA]{Liberation Sans}}\fontsize{10}{10}\textbf{#1:}}\\[-0.05in] +\multicolumn{2}{l}{\oasiscolor{}\fontsize{10}{10}\textbf{#1:}}\\[-0.05in] &\setlength{\topsep}{0in}\setlength{\parsep}{0in}\setlength{\partopsep}{0in} } { \end{tabular}
virtio.tex +23 -3
@@ -55,9 +55,29 @@ %\def_{\_} % Don't hyphenate acronyms %\uchyph=0 -\IfFontExistsTF{Arial}{\setmainfont[Mapping=tex-text]{Arial}}{\setmainfont[Mapping=tex-text]{Liberation Sans}} -%\setromanfont{Arial} -\IfFontExistsTF{Courier New}{\setmonofont{Courier New}}{\setmonofont{Liberation Mono}} + +\newif\iffontcheck +\fontchecktrue +% Disable checking for Arial and Courier New +%\fontcheckfalse +\newcommand{\oasiscolor}[0]{\fontspec[Color=446CAA]{Liberation Sans}} + +\iffontcheck + \IfFontExistsTF{Arial}{ + \setmainfont[Mapping=tex-text]{Arial} + \renewcommand{\oasiscolor}[0]{\fontspec[Color=446CAA]{Arial}} + }{ + \setmainfont[Mapping=tex-text]{Liberation Sans} + } + \IfFontExistsTF{Courier New}{ + \setmonofont{Courier New} + }{ + \setmonofont{Liberation Mono} + } +\else + \setmainfont[Mapping=tex-text]{Liberation Sans} + \setmonofont{Liberation Mono} +\fi \urlstyle{rm}
Signature · 1 line
2.54.0