fontspec.json

The global font definition file is called fontspec.json and resides in the application directory (/var/lib/amusewiki on Debian or wherever you installed it). This file can be overriden per site if fontspec.json is found in the repo’s site_files directory, for example /var/lib/amusewiki/repo/amw/site_files/fontspec.json.

The default file is generated by the script muse-create-font-file.pl which comes with the Text::Amuse::Compile module (amusewiki’s dependency). By default it prints the content to the standard output, or write it to a file if it’s passed as argument.

muse-create-font-file.pl fontspec.json

The content looks so:

[
   {
      "bold" : "/usr/share/fonts/truetype/cmu/cmunbx.ttf",
      "bolditalic" : "/usr/share/fonts/truetype/cmu/cmunbi.ttf",
      "desc" : "CMU Serif",
      "italic" : "/usr/share/fonts/truetype/cmu/cmunti.ttf",
      "name" : "CMU Serif",
      "regular" : "/usr/share/fonts/truetype/cmu/cmunrm.ttf",
      "type" : "serif"
   },
   # more entries
]

muse-create-font-file.pl uses a default list of font and search them using fc-list.

The mandatory parameters are:

name

The font name as seen by the fontconfig. You can get the list of installed fonts using fc-list. It’s very important that the name actually exists and fontconfig sees it, otherwise when trying to compile a PDF using this font, you will get a failure. Try e.g. fc-list "Linux Libertine O"

desc

This is the description you will see on the Book Builder (/bookbuilder) or in the Custom Formats interface (/settings/formats). It’s informative only, so it can be an arbitrary string.

type

Valid values are serif, sans, mono and should be clear what this means.

To embed the fonts in the EPUBs, you also need the file location, and for this there are the four parameters (all of them must be present):

regular

The regular font path

italic

The italic font path

bold

The bold font path

bolditalic

The bold italic font path

Custom files for chapter/section headings

In the bookbuilder and in the format definition, there is a checkbox: “Use sans fonts for section titles”. If you want to use a serif font for that as well, you can cheat, edit the fontspec.json file and change its type from serif to sans. Sans fonts are allowed as main font body.