summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLawrence Chonavel <95857153+lawcho@users.noreply.github.com>2024-02-03 19:27:31 +0100
committerGitHub <noreply@github.com>2024-02-03 10:27:31 -0800
commit7164a238ddd2da25b302e1ff44970a8c43912911 (patch)
tree1a980af0dfc23eb96f16c7f41dbd54206428477b
parentcd4676e4985ee2781ebefbe7c11397232c5b01e7 (diff)
ConTeXt template: support font fallback (#9361)
This uses the same YAML options as the LaTeX template.
-rw-r--r--MANUAL.txt14
-rw-r--r--data/templates/default.context10
2 files changed, 21 insertions, 3 deletions
diff --git a/MANUAL.txt b/MANUAL.txt
index 7f33a8d41..ac2b31d3e 100644
--- a/MANUAL.txt
+++ b/MANUAL.txt
@@ -2940,14 +2940,22 @@ Pandoc uses these variables when [creating a PDF] with a LaTeX engine.
`mainfontfallback`, `sansfontfallback`, `monofontfallback`
: fonts to try if a glyph isn't found in `mainfont`, `sansfont`, or `monofont`
- respectively. These can be lists. The font name must be followed by a colon
- and optionally a set of options, for example:
+ respectively. These are lists. The syntax for the font names depends on the
+ PDF engine used, e.g. for `--pdf-engine=lualatex`:
+ ---
mainfontfallback:
- "FreeSans:"
- "NotoColorEmoji:mode=harf"
+ ...
+
+ Font fallbacks currently only work with `lualatex`[^lltx-ff-notes]
+ or `context`[^cntx-ff-notes]
+
+[^lltx-ff-notes]: Use `\fontspec`-compatible font name syntax, and also set `mainfont` YAML metadata.
- Font fallbacks currently only work with `--pdf-engine=lualatex`.
+[^cntx-ff-notes]: Use `\definefallbackfamily`-compatible font name syntax.
+ [Emoji fonts are unsupported.](https://github.com/jgm/pandoc/pull/9361#issuecomment-1910564364)
`babelfonts`
: a map of Babel language names (e.g. `chinese`) to the font
diff --git a/data/templates/default.context b/data/templates/default.context
index da66d599e..2e18f985e 100644
--- a/data/templates/default.context
+++ b/data/templates/default.context
@@ -59,6 +59,16 @@ $endif$
\setupbodyfontenvironment[default][em=italic] % use italic as em, not slanted
+$-- set up font fallbacks
+$for(mainfontfallback)$
+\definefallbackfamily[mainface][rm][$mainfontfallback$][range=0x0000-0xFFFF, check=yes, force=no]
+$endfor$
+$for(sansfontfallback)$
+\definefallbackfamily[mainface][ss][$sansfontfallback$][range=0x0000-0xFFFF, check=yes, force=no]
+$endfor$
+$for(monofontfallback)$
+\definefallbackfamily[mainface][tt][$monofontfallback$][range=0x0000-0xFFFF, check=yes, force=no]
+$endfor$
\definefallbackfamily[mainface][rm][CMU Serif][preset=range:greek, force=yes]
\definefontfamily[mainface][rm][$if(mainfont)$$mainfont$$else$Latin Modern Roman$endif$]
\definefontfamily[mainface][mm][$if(mathfont)$$mathfont$$else$Latin Modern Math$endif$]