Description
Bug report
Bug summary
The PDF backend does not properly add Unicode glyphs above code point 255 to the PDF, when a system font (or a custom user font) is accessed via a symbolic link (i.e. font_manger.findfont()
returns a symbolic link) and the link has a different name as the target (e.g. arial.ttf
links to Arial.ttf
).
This happens, for example, with Unicode minus signs \u2212
when using the Arial font from the msttcorefonts
package under Ubuntu 16 or 18. There, font_manager.findfont()
returns the path to arial.ttf
which is a link to Arial.ttf
.
Code for reproduction
import numpy as np
from matplotlib import rcParams
import matplotlib.pyplot as plt
# The example assumes the following link
# /usr/share/fonts/truetype/opensans/opensans.ttf -> /some/other/place/OpenSans.ttf
rcParams['font.family'] = "Open Sans"
x = np.linspace(-1, 1, 200)
plt.plot(x, x**3)
plt.savefig("example.pdf")
Since this example requires some preparation, I've created a repo which runs the example in the CI within a Dockerimage (gitlab.sauerburger.com:5049/frank/matplotlib_xobject_names).
Actual outcome
The axes do not show minus signs (which are Unicode minus signs by default). All other characters are ok.
Opening the PDF file with mupdf gives the following error messages
$ mupdf example.pdf
error: cannot find XObject resource 'opensans-minus'
error: cannot find XObject resource 'opensans-minus'
error: cannot find XObject resource 'opensans-minus'
error: cannot find XObject resource 'opensans-minus'
error: cannot find XObject resource 'opensans-minus'
error: cannot find XObject resource 'opensans-minus'
error: cannot find XObject resource 'opensans-minus'
error: cannot find XObject resource 'opensans-minus'
mupdf: warning: Errors found on page
Expected outcome
It is expected that Unicode minus signs are correctly embedded in the PDF.
Matplotlib version
- Operating system: Running in Docker image based on python:3.7 (Host CentOS 7)
- Matplotlib version: 3.1.1
- Matplotlib backend: pdf
- Python version: 3.7.3
Matplotlib was installed via pip.