Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[Bug]: Math fonts (Type 3) incorrectly embedded in PDF? #21797

@andreas-brugger

Description

@andreas-brugger

Bug summary

PDFs containing math fonts cause the following error message in Adobe Acrobat: Cannot extract the embedded font. Some characters may not display or print correctly.

Code for reproduction

import matplotlib.pyplot as plt

fig, ax = plt.subplots(1, 1, figsize=[2, 1])

# use TrueType
if False: plt.rcParams.update({'pdf.fonttype': 42})

ax.axis('Off')
ax.text(0.5, 0.5, '$\\alpha~\\beta~\\gamma$', ha='center')

fig.savefig('Test.pdf')

Actual outcome

Adobe Acrobat error message

Expected outcome

The font seems to be displayed correctly, but apparently it is not correctly embedded.

Additional information

To reproduce this issure, open the PDF created by Matplotlib in Adobe Acrobat, navigate to Document Properties > Fonts > OK. The error message is only displayed if one changes the zoom, switches pages, etc. The error message arises in recent versions of Adobe Acrobat on different operating systems.

The error message arises only for PDFs containing mathematical expressions, while PDFs with regular text cause no error message. However, the issue seems to arise independently of the actual font type and arises for the default font dejavusans and others such as stix.

The issue furthermore arises for the default value of pdf.fonttype being Type 3. When switching to TrueType (causing much larger file sizes), the error message no longer arises.

Operating system

No response

Matplotlib Version

3.4.3

Matplotlib Backend

No response

Python version

No response

Jupyter version

No response

Installation

conda

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions