OpenTechStrategies / SimpleBook

A fork of the Collection Extension to print books from MediaWiki instances
1 stars 1 forks source link

Fonts don't load properly when called by python #24

Closed slifty closed 3 years ago

slifty commented 3 years ago

First things first: I don't love the way fonts are being used in this project to begin with here and it isn't clear to me we need them.

Anyway, right now the PdfGenerator has a generatePdfFromScaffold method where a bunch of fonts are registered in the PdfPrinter object. The problem is is that the font paths break depending on where the script has been initiated from.

To make matters worse, __dirname doesn't actually exist in our current setup (this may be fixed by #20). For now we need to do something like https://stackoverflow.com/a/32707530/159522 when defining the font paths in order to call the mw2pdf script from our flask app.

frankduncan commented 3 years ago

I think webfonts are probably the correct solution for this. Having the plugin declare the fonts used for rendering seems bad. Having it be checked in to the codebase seems worse. Maybe best way is to have a way for someone configuring the system to put the fonts they want in a deployed directory. That way they can worry about legality of their fonts and whether they own them and whatnot.

slifty commented 3 years ago

I do think it's important for the package to be fully functional without requiring the installation of non-packaged dependencies (this isn't opposed to what you're saying, this is just saying that I would want the font configuration / installation step to be optional rather than a required part of setup -- e.g. the user of the module can explicitly pass font configuration as part of the documented API of the module).

In the mean time the current system does use embedded FOSS fonts and the license is included so the ownership question is covered.

TL;DR -- I agree it would be good to remove the need for embedded fonts in the first place. For the scope of this issue I'd like to just fix the code that exists (since we already have the fonts checked in etc etc) but I will create a second issue for that goal.