Skip to content

Don't require the pdf-fontsdir attribute in order to use custom fonts #2349

Open
@mojavelinux

Description

When a theme uses custom fonts, it's mandatory to set the the pdf-fontsdir attribute. Otherwise, the converter will not be able to locate the font files. This requirement makes it slightly more difficult to create a custom theme. The converter should instead provide a reasonable fallback if this attribute is not set.

There are several ways which this could be done.

First, the theme could expand the token THEMES_DIR at the beginning of the font path in the theme, much like it does for the GEM_FONTS_DIR token. The THEMES_DIR token would resolve to the value of the pdf-themesdir attribute (which defaults to the directory of the main theme file that was loaded).

font:
  catalog:
    Lato: THEMES_DIR/Lato-Regular.ttf

Second, the default pdf-fontsdir could be changed from GEM_FONTS_DIR to {pdf-themesdir};GEM_FONTS_DIR, where {pdf-themesdir} represents the value of the pdf-themesdir attribute. When this default is used, relative font paths in the theme are resolved from the themes dir (the directory of the theme file) first before being resolved from the installed gem. The user will still be able to override this default by setting the pdf-fontsdir attribute. And this won't affect built-in themes, which use the GEM_FONTS_DIR token explicitly to refer to paths inside the gem.

For completeness, we could also consider allowing the attribute reference {pdf-themesdir} to be used in the value of pdf-fontsdir when set from the CLI or API (e.g., -a pdf-fontsdir={pdf-themesdir}/fonts). Though that's not really addressing the original issue.

Metadata

Assignees

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions