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

Fix font paths #27

Merged
merged 1 commit into from
Apr 30, 2021
Merged

Fix font paths #27

merged 1 commit into from
Apr 30, 2021

Conversation

slifty
Copy link
Contributor

@slifty slifty commented Apr 30, 2021

This PR fixes the way fonts are loaded into the PDF generation script so that their paths are no longer relative to where the script is called from

Resolves #24

@slifty slifty requested a review from hawkinsw April 30, 2021 18:01
Copy link
Contributor

@hawkinsw hawkinsw left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a few optional items of feedback. If they are helpful, feel free to address them. If not, merge away! HTH.

services/api/mw2pdf/classes/PdfGenerator.js Show resolved Hide resolved
services/api/mw2pdf/classes/PdfGenerator.js Show resolved Hide resolved
Fonts were being loaded in a way that would only work if the script was
being called from the mw2pdf root (the folder containing the embedded
fonts).

This adds some (ugly) logic to identify the `__dirname` of the utility
script and access fonts relative to the utility itself as opposed to the
calling path.  This logic is necessary because unfortunately NodeJS
doesn't populate __dirname when module mode is enabled.

See: https://stackoverflow.com/questions/32705219/nodejs-accessing-file-with-relative-path/32707530#32707530

As discussed in #24 we will eventually want to remove fonts from the
project altogether, instead trying to have a generic default settings
and allowing font configuration to be configurable for anybody who would
like to override that generic option.

Issue #24
@slifty slifty merged commit 99bfcf6 into main Apr 30, 2021
@slifty slifty deleted the 24-fix-fonts branch April 30, 2021 20:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Fonts don't load properly when called by python
2 participants