jgm / pandoc

Universal markup converter
https://pandoc.org
Other
34.43k stars 3.37k forks source link

EPUB writer: search for fonts in User Directory #7043

Open shoesforindustry opened 3 years ago

shoesforindustry commented 3 years ago

See this issue on the Google groups https://groups.google.com/g/pandoc-discuss/c/U5G04HzRReI/m/bmtPPpWCDQAJ

When using a 'defaults' default.yaml file with a font command e.g.

epub-fonts:
 - Source-Serif-Pro-*.ttf

Pandoc cannot find the fonts unless you specify the full path. I was expecting user directory --data-dir to affect the search for fonts?

To which John replied: "Hm. Yes, it loooks like the code uses readFileLazy rather thanfetchItem (EPUB writer l. 517). This could perhaps be changed?..."

I do think it is a good idea to have the the search for fonts from a 'defaults' default.yaml to begin searching in the user directory (--data-dir) unless it will cause other problems? You can of course specify another location with paths, but it seems sensible to have a user directory default?

What do other people think?

jgm commented 3 years ago

Sorry, I was confusing myself. fetchItem doesn't look in the data directory either, but it does look in the resource path (unlike readFileLazy) and it will also allow URLs which it will fetch via HTTP. So using fetchItem would gain you the ability to set your resource-path to include the directory containing the fonts, but it wouldn't be quite what you're describing here, which (I assume) is to have something like a fonts/ subdirectory of the user data directory.

I think that being able to use --resource-path might be better overall, though; then you can just pass in the pass to your system font directory and you wouldn't need to duplicate this in the user data dir.

shoesforindustry commented 3 years ago

Thanks John, and maybe I'm missing something, but in the Pandoc help file --resource-path=.:test says to search the working directory and a sub directory of that working directory called test. But this is not my --data-dir where my fonts and templates are? I've tried adding the path to the --data-dir also to --resource-path but it cannot find the font files. It will only find the fonts if I do something like --resource-path=.:fonts and add a fonts sub folder to my working directory - which is expected from the help file.

Any ideas?

jgm commented 3 years ago

To clarify, neither --data-dir nor --resource-path will currently help. The proposed change would allow --resource-path to help.