html: Include generic font-family name "sans-serif" as a fallback.
authorBen Pfaff <blp@cs.stanford.edu>
Sat, 24 Jun 2023 17:04:48 +0000 (10:04 -0700)
committerBen Pfaff <blp@cs.stanford.edu>
Sat, 24 Jun 2023 17:06:36 +0000 (10:06 -0700)
https://developer.mozilla.org/en-US/docs/Web/CSS/font-family recommends
that a font-family specification should always include one of the generic
font-family names to serve as a fallback.  For PSPP, sans-serif is a
reasonable fixed fallback.

This addresses bug #63020, which asks for "Sans Serif" to mean sans-serif.
It obviously doesn't generalize to other font name translations, but it
does address the case that the bug filer complained about.  If we need a
more general mechanism, we can invent it later.

Thanks to Frans Houweling for reporting this issue.

src/output/html.c

index 5b798302d61badc54a2e5c2a70098f48ff2d0bb2..076a9589ae7a98fc4864ff91765218aade4dfd19 100644 (file)
@@ -542,7 +542,9 @@ html_put_table_cell (struct html_driver *html, const struct pivot_table *pt,
     {
       put_style (&style, "font-family", "\"");
       escape_string (html->file, fs->typeface, " ", "\n");
-      putc ('"', html->file);
+
+      /* Always include a generic font family name as a fallback. */
+      fputs ("\", sans-serif", html->file);
     }
   if (fs->bold)
     put_style (&style, "font-weight", "bold");