GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — [Bug]: Math fonts (Type 3) incorrectly embedded in PDF? · Issue #21797 · matplotlib/matplotlib

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

New issue
Copy link
New issue
Copy link
Closed
#30512
Closed
[Bug]: Math fonts (Type 3) incorrectly embedded in PDF?#21797
#30512
Copy link
Assignees
QuLogic
Labels
backend: pdf
Milestone
v3.11.0

Description

@andreas-brugger
andreas-brugger
opened on Nov 29, 2021
Issue body actions

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

Activity

Next
  1. andreas-brugger commented on Nov 29, 2021

    @andreas-brugger
    andreas-brugger
    on Nov 29, 2021
    Author
    More actions

    Consider the file Test.pdf, which causes the aforementioned error message in Adobe Acrobat.

  2. dstansby
    added
    backend: pdf
    on Nov 29, 2021
  3. QuLogic commented on Nov 30, 2021

    @QuLogic
    QuLogic
    on Nov 30, 2021
    Member
    More actions

    Please try with 3.5.0

  4. QuLogic
    added
    status: needs clarificationIssues that need more information to resolve.Issues that need more information to resolve.
    on Nov 30, 2021
  5. jklymak commented on Nov 30, 2021

    @jklymak
    jklymak
    on Nov 30, 2021
    Member
    More actions

    I tested on 3.5.0 and the error message still exists. OTOH I'm not clear what it means, if anything..

  6. andreas-brugger commented on Nov 30, 2021

    @andreas-brugger
    andreas-brugger
    on Nov 30, 2021
    Author
    More actions

    I tried to get more details by using the Preflight tool from Adobe Acrobat, but unfortunately I could not get any. However, since the error message only arises for certain types of fonts, there seems to be an actual reason.

    The error message is significant insofar as it also arises if such a figure is embedded in a larger PDF (e.g. via LaTeX) and therefore presumably affects a whole lot of documents.

  7. jklymak commented on Nov 30, 2021

    @jklymak
    jklymak
    on Nov 30, 2021
    Member
    More actions

    .. but does it have a practical effect, in that the document looks bad? Are the fonts actually missing? I wouldn't rule out an Adobe bug here...

  8. andreas-brugger commented on Nov 30, 2021

    @andreas-brugger
    andreas-brugger
    on Nov 30, 2021
    Author
    More actions

    As far as I can tell, the figures look fine, but it is hard to tell since I usually use the font Stix 2 while Matplotlib uses the former version and they differ anyway.

    According to the document properties shown in Adobe Acrobat (prior to displaying the error message) the font is embedded. Similarly, pdffonts provided by poppler-utils states that the font is embedded:

    name                                 type              encoding         emb sub uni object ID
    ------------------------------------ ----------------- ---------------- --- --- --- ---------
    DejaVuSans-Oblique                   Type 3            Custom           yes no  no      15  0

    It could be a bug in Adobe Acrobat, or e.g., maybe something remotely similar to pull request #1808? Does anybody know a way to truly check the PDF, e.g. via the Preflight tool?

  9. aitikgupta commented on Dec 3, 2021

    @aitikgupta
    aitikgupta
    on Dec 3, 2021
    Contributor
    More actions

    Consider the file Test.pdf

    3.5 would instead produce a font subsetted file (with 6 characters in the beginning of font name)..
    Reproducing the snippet, the embedded fonts are:

    name                                 type              encoding         emb sub uni object ID
    ------------------------------------ ----------------- ---------------- --- --- --- ---------
    GCWXDV+DejaVuSans-Oblique            Type 3            Custom           yes yes no      15  0
    

    ^when pdf.fonttype is 3, and:

    name                                 type              encoding         emb sub uni object ID
    ------------------------------------ ----------------- ---------------- --- --- --- ---------
    GCWXDV+DejaVuSans-Oblique            CID TrueType      Identity-H       yes yes yes     15  0
    

    ^when pdf.fonttype is 42..

    Not sure about the actual bug here, but I'd first try to reproduce it with latest Matplotlib build.. also these PDFs do not really bug other native PDF viewers that I've tried them with, so the Adobe Acrobat bug seems possible.

  10. andreas-brugger commented on Dec 5, 2021

    @andreas-brugger
    andreas-brugger
    on Dec 5, 2021
    Author
    More actions

    3.5 would instead produce a font subsetted file (with 6 characters in the beginning of font name)..
    Reproducing the snippet, the embedded fonts are:

    Could you please add the two PDFs for Matplotlib 3.5 with font type 3 and TrueType, so I could check whether the error arises?

  11. aitikgupta commented on Dec 9, 2021

    @aitikgupta
    aitikgupta
    on Dec 9, 2021
    Contributor
    More actions

    @theBruegge here you go:
    fonttype3.pdf
    fonttype42.pdf

  12. andreas-brugger commented on Dec 21, 2021

    @andreas-brugger
    andreas-brugger
    on Dec 21, 2021
    Author
    More actions

    Thanks @aitikgupta!

    The issue is still the same: for font type 3 the aforementioned error message arises, which states that the embedded font cannot be extracted (the font now has the name GCWXDV+DejaVuSans-Oblique indicating the subset). No error is shown for TrueType.

    I already tried to get more details via the Preflight tool from Adobe Acrobat and from Adobe support, which unfortunately did not work out so far, but I'll try again ...

  13. andreas-brugger commented on Dec 22, 2021

    @andreas-brugger
    andreas-brugger
    on Dec 22, 2021
    Author
    More actions

    I think I got some more details via the Preflight tool from Adobe Acrobat Pro: according to Preflight the font is not embedded if Font Type 3 is used, while TrueType fonts are shown to be embedded. In the former case, Preflight therefore tries to embed the font. This procedure is shown to be successful, if the DejaVu Fonts were previously installed on the system.

    However, while this procedure truly works for non-math text in DejaVuSans (the font is denoted as Embedded Subset afterwards in the Document Properties), embedding apparently does not work for math text in DejaVuSans-Oblique and Preflight vectorizes the math text.

        

    Unfortunately, this does still not reveal any details. However, in my experience printing companies check PDFs in that respect for instance using Preflight – which renders this issue actually problematic, at least to some extent.

  14. jklymak commented on Jan 6, 2022

    @jklymak
    jklymak
    on Jan 6, 2022
    Member
    More actions

    @theBruegge Its not clear to me what action you are suggesting for Matplotlib.

  15. andreas-brugger commented on Jan 10, 2022

    @andreas-brugger
    andreas-brugger
    on Jan 10, 2022
    Author
    More actions

    @jklymak
    Well, there seems to be a broad hint for some issue, probably caused by Matplotlib's embedding of Type 3 fonts. Unfortunately, since I have no profound knowledge about font embedding or the internal structure of PDFs, I do not know how to further investigate or fix the issue – I can only point it out.

  16. 7 remaining items

  17. tacaswell commented on Apr 20, 2023

    @tacaswell
    tacaswell
    on Apr 20, 2023
    Member
    More actions

    Not emitting an empty font embedding makes sense, but I would push back on adobe and ask if that is actually out of spec or not. If the spec does not forbid it we have found a bug in their tool :)

  18. andreas-brugger commented on Apr 27, 2023

    @andreas-brugger
    andreas-brugger
    on Apr 27, 2023
    Author
    More actions

    Knowing what I know now, I would formulate my issue differently: it's actually not just about the error message in Adobe Acrobat (regardless of whether out of spec or not as mentioned by @tacaswell). The issue rather addresses the fact that characters with a code ≥ 256 are not embedded as text in the PDF but as a rendered path.
    This has many disadvantages: the file size increases (as mentioned by @jklymak), you can't search for these characters, you can't edit them later, etc. – but as far as I know (and as mentioned by @QuLogic), the standard would allow embedding such characters as text.

    Reacted by Michael Görner
  19. QuLogic
    added a commit that references this issue on Sep 4, 2025

    pdf: Improve text with characters outside embedded font limits

    This issue will close once commit b554075 is merged into the 'main' branch.
    b554075
  20. QuLogic
    self-assigned this
    on Sep 4, 2025
  21. QuLogic
    added 3 commits that reference this issue on Sep 16, 2025

    pdf: Improve text with characters outside embedded font limits

    This issue will close once commit 66c79b1 is merged into the 'main' branch.
    66c79b1

    pdf: Improve text with characters outside embedded font limits

    This issue will close once commit 770ab8e is merged into the 'main' branch.
    770ab8e

    pdf: Improve text with characters outside embedded font limits

    This issue will close once commit 8ad5db9 is merged into the 'main' branch.
    8ad5db9
  22. QuLogic
    added this to the v3.11.0 milestone on Sep 17, 2025
  23. QuLogic
    linked a pull request that will close this issuepdf: Improve text with characters outside embedded font limits #30512on Sep 17, 2025
  24. QuLogic
    added 4 commits that reference this issue on Sep 19, 2025

    pdf: Improve text with characters outside embedded font limits

    This issue will close once commit b4ca8b4 is merged into the 'main' branch.
    b4ca8b4

    pdf: Improve text with characters outside embedded font limits

    This issue will close once commit 761cbaf is merged into the 'main' branch.
    761cbaf

    pdf: Improve text with characters outside embedded font limits

    This issue will close once commit 2a71a26 is merged into the 'main' branch.
    2a71a26

    pdf: Improve text with characters outside embedded font limits

    This issue will close once commit b70fb88 is merged into the 'main' branch.
    b70fb88
  25. wavebyrd
    added a commit that references this issue on Mar 13, 2026

    pdf: Improve text with characters outside embedded font limits

    This issue will close once commit e1e6973 is merged into the 'main' branch.
    e1e6973
  26. QuLogic
    closed this as completedin b70fb88on Apr 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

  • @QuLogic
    QuLogic

Labels

backend: pdf

Type

No type

Projects

No projects

    Milestone

    • v3.11.0

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

    You are visitor 01402503 — GeezerVison does not store the pages you look up.
    Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.