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 --fonts CLI option #46

Merged
merged 1 commit into from
Dec 1, 2024
Merged

Fix --fonts CLI option #46

merged 1 commit into from
Dec 1, 2024

Conversation

Luflosi
Copy link
Contributor

@Luflosi Luflosi commented Dec 1, 2024

This option was introduced many years ago and has since bit-rotted.
I don't have fonts installed globally on my system, so I need to use the --fonts option.
But without this commit, I get the following error when trying to use the --fonts option:

Traceback (most recent call last):
  File "/path/to/nik4.py", line 677, in <module>
    run(options)
  File "/path/to/nik4.py", line 422, in run
    mapnik.load_map_from_string(m, style_xml.encode("utf-8"), False, style_path)
RuntimeError: no valid fonts could be loaded in FontSet 'fontset-0' in FontSet at line 15

To fix this, load the fonts earlier. The exact place where we load them is not important, as long as it is above all calls to mapnik functions, which require fonts to be loaded (mapnik.load_map_from_string() currently). To be on the safe side regarding future modifications, I moved the code snippet pretty much to the top of the function, which results in this option working again.

This option was introduced many years ago and has since bit-rotted.
I don't have fonts installed globally on my system, so I need to use the `--fonts` option.
But without this commit, I get the following error when trying to use the `--fonts` option:
```
Traceback (most recent call last):
  File "/path/to/nik4.py", line 677, in <module>
    run(options)
  File "/path/to/nik4.py", line 422, in run
    mapnik.load_map_from_string(m, style_xml.encode("utf-8"), False, style_path)
RuntimeError: no valid fonts could be loaded in FontSet 'fontset-0' in FontSet at line 15
```
To fix this, load the fonts earlier. The exact place where we load them is not important, as long as it is above all calls to mapnik functions, which require fonts to be loaded (`mapnik.load_map_from_string()` currently). To be on the safe side regarding future modifications, I moved the code snippet pretty much to the top of the function, which results in this option working again.
@Zverik Zverik merged commit a2a8878 into Zverik:master Dec 1, 2024
@Zverik
Copy link
Owner

Zverik commented Dec 1, 2024

Thank you! I've published it in 1.8.

@Luflosi Luflosi deleted the fix-fonts-option branch December 1, 2024 19:41
@Luflosi
Copy link
Contributor Author

Luflosi commented Dec 1, 2024

Awesome, thanks!

@Luflosi
Copy link
Contributor Author

Luflosi commented Dec 1, 2024

Could you please also create a Git tag and GitHub release?

@Zverik
Copy link
Owner

Zverik commented Dec 2, 2024

Yup, done.

@Luflosi
Copy link
Contributor Author

Luflosi commented Dec 2, 2024

Thank you!

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.

2 participants