[PATCH] Avoid repeatedly checking for font availability
Demi Marie Obenour <[email protected]> Tue, 28 Apr 2026 01:56:02 -0400
| Newsgroups | dev.linux.lists.virtio-comment |
|---|---|
| Message-ID | <[email protected]> |
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(-) diff --git a/commands-pdf.tex b/commands-pdf.tex index 23289d895429f4ef4b50fdefa3f7b6a8a5e9ebbc..b9e57347bba2a69ff51262dbb39cb147d1e70a2c 100644 --- a/commands-pdf.tex +++ b/commands-pdf.tex @@ -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} diff --git a/virtio.tex b/virtio.tex index e02b34101d1e3996cdf4d66cf1df398160a82c8a..9a725774f2d077ec74acc828d1db58192592eb8f 100644 --- a/virtio.tex +++ b/virtio.tex @@ -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} -- 2.54.0