Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
mojavelinux opened this issue Sep 29, 2022 · 4 comments
Open
Assignees
Milestone

Comments

@mojavelinux
Copy link
Member

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.

@mojavelinux mojavelinux self-assigned this Sep 29, 2022
@mojavelinux mojavelinux added this to the v3.0.x milestone Sep 29, 2022
@mojavelinux
Copy link
Member Author

I'm also thinking that the pdf-fontsdir should expand to the current directory if the value is empty. Right now, this value is interpreted as GEM_FONTS_DIR. However, that's not very logical.

@AndrewBloom
Copy link

AndrewBloom commented Aug 25, 2024

Hi, I think this may be related.
I have a mac, asciidoctor installed via HomeBrew. if I try to modify the size of fonts for the outputted pdf through the yaml file nothing really happens. If I try to change fonts (I thought that maybe the fonts didn't support the sizes), I get the error: "No such file or directory - Geneva.ttf not found in GEM_FONTS_DIR". I have no idea which directory that is, if it's a shell variable or something related to Ruby or gem (which i don't have really a clear idea of what they are). So I tried to set pdf-fontsdir with -a pdf-fontsdir="/System/Library/Fonts/,GEM_FONTS_DIR" to use the system fonts and this way doesn't give any errors (but still the size of the fonts don't change).

Would be cool if pdf-fontsdir is set at least to use the fonts that are installed on the computer by default.

@mojavelinux
Copy link
Member Author

If you need help using Asciidoctor PDF, please direct your question to https://chat.asciidoctor.org. The only comments here should be how to design and implement a solution to the specified request.

@AndrewBloom
Copy link

@life888888 Yes I tried both ; and , with " and without. I actually tried many other things too without luck.
@mojavelinux Yes, I wanted to give some context. Thanks for the link with the chat.

  • I think it could make sense to have a default that for fontsdir that allows to use the broader set available on the user system.
  • I think the documentation could be improved regarding GEM_FONTS_DIR, how it's set and what actually is.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants