Discussion of the VIRTIO specification
 help / color / mirror / Atom feed
* [PATCH] Avoid repeatedly checking for font availability
@ 2026-04-28  5:56 Demi Marie Obenour
  0 siblings, 0 replies; only message in thread
From: Demi Marie Obenour @ 2026-04-28  5:56 UTC (permalink / raw)
  To: virtio-comment

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 <demiobenour@gmail.com>
---
 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


^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2026-05-07  3:41 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-04-28  5:56 [PATCH] Avoid repeatedly checking for font availability Demi Marie Obenour

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox