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

[Bug] DejaVuSans.ttf default font for grass.jupyter not found on Windows #4375

Closed
echoix opened this issue Sep 24, 2024 · 0 comments · Fixed by #4378
Closed

[Bug] DejaVuSans.ttf default font for grass.jupyter not found on Windows #4375

echoix opened this issue Sep 24, 2024 · 0 comments · Fixed by #4378
Labels
bug Something isn't working notebook Python Related code is in Python
Milestone

Comments

@echoix
Copy link
Member

echoix commented Sep 24, 2024

Describe the bug

When enabling Pytest tests on Windows, I had to disable a test named "test_save", as the save() function in grass.jupyter.timeseriesmap has a default value for font, and it isn't found on Windows.

The current solution I had is to just let Pillow use its default value for the font if none is passed. I don't know know how to see the result with it.

    def save(
        self,
        filename,
        duration=500,
        label=True,
-       font="DejaVuSans.ttf",
+       font=None,
        text_size=12,
        text_color="gray",
    ):

And adding

        if font is None and not sys.platform.startswith("win"):
            font = "DejaVuSans.ttf"

The code in question is

def save(
self,
filename,
duration=500,
label=True,
font="DejaVuSans.ttf",
text_size=12,
text_color="gray",
):
"""
Creates a GIF animation of rendered layers.
Text color must be in a format accepted by PIL ImageColor module. For supported
formats, visit:
https://pillow.readthedocs.io/en/stable/reference/ImageColor.html#color-names
param str filename: name of output GIF file
param int duration: time to display each frame; milliseconds
param bool label: include date/time stamp on each frame
param str font: font file
param int text_size: size of date/time text
param str text_color: color to use for the text.
"""
# Render images if they have not been already
if not self._layers_rendered:
self.render()
input_files = []
for date in self._labels:
input_files.append(self._base_filename_dict[date])
save_gif(
input_files,
filename,
duration=duration,
label=label,
labels=self._labels,
font=font,
text_size=text_size,
text_color=text_color,
)
# Display the GIF
return filename

I'd like some help to know how to address it.

To reproduce

  1. Go to a OSGeo4w job log, in the pytest section.
  2. In the xfail verbose logs, look at test_save.
  3. See error. Between https://github.com/OSGeo/grass/actions/runs/10992700384/job/30517619655#step:12:978 and https://github.com/OSGeo/grass/actions/runs/10992700384/job/30517619655#step:12:1065

Expected behavior

Screenshots

image
image

System description

Additional context

@echoix echoix added bug Something isn't working Python Related code is in Python notebook labels Sep 24, 2024
@neteler neteler added this to the 8.5.0 milestone Sep 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working notebook Python Related code is in Python
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants