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

Magics does not plot all weekday names correctly for PNG/PDF output with LC_TIME=es_ES.UTF-8 #109

Open
pdando opened this issue Feb 26, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@pdando
Copy link

pdando commented Feb 26, 2024

What happened?

Magics does not plot all weekday names correctly for PNG/PDF output with LC_TIME=es_ES.UTF-8 (i.e., when CAIRO-PANGO is called).

What are the steps to reproduce the bug?

This is reproduced using the following Python script (based on Axis example 2):

#importing Magics module
from Magics.macro import *

ref = 'axis2'

#Setting of the output file name
output = output(
                output_formats = ['png','ps','eps','pdf'], 
                output_name_first_page_number = "off",
                output_name = ref
               )

#Setting the cartesian view
projection = mmap(
                  subpage_y_position= 2., 
                  subpage_map_projection = 'cartesian',
                  subpage_x_axis_type = 'date',
                  subpage_y_axis_type = 'regular',
                  subpage_x_date_min = "2012-04-10",
                  subpage_x_date_max = "2012-04-28",
                  subpage_y_min = -20.,
                  subpage_y_max = 20.
                 )

#Vertical axis
vertical = maxis(
                 axis_orientation = "vertical",
                 axis_grid =  "on",
                 axis_type =  "regular",
                 axis_grid_colour = "grey",
                 axis_grid_thickness = 1,
                 axis_grid_reference_level = 0.,
                 axis_grid_reference_line_style='solid',
                 axis_grid_reference_thickness=2,
                 axis_grid_line_style = "dot"
                )

#Horizontal axis
horizontal = maxis(
                   axis_orientation = "horizontal",
                   axis_type =  "date",
                   axis_grid =  "on",
                   axis_days_label_height =  0.4,
                   axis_months_label_height =  0.4,
                   axis_years_label_height =  0.4,
                   axis_grid_colour = "grey",
                   axis_grid_thickness = 1,
                   axis_grid_line_style = "dot"
                  )

lines =["Using time series...for units μm - should be  micrometres with a Greek letter mu"]

title = mtext({
               "text_lines" : lines,
               "text_html" : "true",
               "text_justification": "left",
               "text_font_size": 0.75,
               "text_colour" : "charcoal"
             })

#To the plot
plot(output, projection, vertical, horizontal, title)

Run as:

$ env LC_TIME=es_ES.UTF-8 python3 axis2.py 

Output shows error messages from CAIRO-PANGO:

b'Magics-warning: CAIRO-PANGO: Error on line 1 char 72: Invalid UTF-8 encoded text in name - not valid \'mi\xc311\'\n  for text: <span color="#000000" font_family="sansserif" size="7168">mi\xc311</span>\n'
b'Magics-warning: CAIRO-PANGO: Error on line 1 char 72: Invalid UTF-8 encoded text in name - not valid \'mi\xc318\'\n  for text: <span color="#000000" font_family="sansserif" size="7168">mi\xc318</span>\n'  
b'Magics-warning: CAIRO-PANGO: Error on line 1 char 72: Invalid UTF-8 encoded text in name - not valid \'mi\xc325\'\n  for text: <span color="#000000" font_family="sansserif" size="7168">mi\xc325</span>\n'
b'Magics-warning: CAIRO-PANGO: Error on line 1 char 72: Invalid UTF-8 encoded text in name - not valid \'mi\xc311\'\n  for text: <span color="#000000" font_family="sansserif" size="7168">mi\xc311</span>\n' 
b'Magics-warning: CAIRO-PANGO: Error on line 1 char 72: Invalid UTF-8 encoded text in name - not valid \'mi\xc318\'\n  for text: <span color="#000000" font_family="sansserif" size="7168">mi\xc318</span>\n'
b'Magics-warning: CAIRO-PANGO: Error on line 1 char 72: Invalid UTF-8 encoded text in name - not valid \'mi\xc325\'\n  for text: <span color="#000000" font_family="sansserif" size="7168">mi\xc325</span>\n'

Plot shows the day of the week for Wednesday - (mi)ércoles - isn't plotted:

Compare with eps output which correctly shows "mi":

This also happens with other locales (LC_TIME settings) - not just es_ES.UTF-8.

See also plots attached to MAGP-1343 and SD-60066.

Version

4.14.1 and older

Platform (OS and architecture)

Linux ac6-200.bullx 4.18.0-372.52.1.el8_6.x86_64 #1 SMP Fri Mar 31 06:22:44 EDT 2023 x86_64 x86_64 x86_64 GNU/Linux

Relevant log output

No response

Accompanying data

No response

Organisation

ECMWF (reporting on behalf of AEMET)

@pdando pdando added the bug Something isn't working label Feb 26, 2024
@sylvielamythepaut
Copy link
Contributor

Hi Paul,
I will have a look to this one this week
Sylvie

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants