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

Too many logs about glyphs when saving PDFs after changing fonts in matplotlib #3371

Open
earmingol opened this issue Dec 6, 2023 · 4 comments

Comments

@earmingol
Copy link

earmingol commented Dec 6, 2023

Hi!

I am getting the a bunch of log messages (shown at the end of this post) when changing fonts in matplotlib (v3.8.2) using

plt.rcParams.update({"pdf.fonttype": 42, "ps.fonttype": 42})

These messages are displayed when I am saving a plot as a pdf.

I am using the latest version of fonttools (v4.46) and python 3.11. I tried downgrading the version of fontools to v4.38 and/or downgrading matplotlib to different versions, but I still get the same issue.

I realized that I stop getting these messages when I reset the matplotlib params using:

from matplotlib import rcParams, rcParamsDefault
rcParams.update(rcParamsDefault)

I would use the default fonts, but I need to use another library that uses this font internally to save plots as PDFs (see: https://github.com/zqfang/GSEApy/blob/4d2540f22cfadc36607540a59b504a4c94dbe826/gseapy/plot.py#L274).

Any idea how to avoid getting these messages?

The message I get is:

cmap pruned
kern dropped
post pruned
FFTM dropped
GPOS pruned
GSUB pruned
glyf pruned
Added gid0 to subset
Added first four glyphs to subset
Closing glyph list over 'GSUB': 33 glyphs before
Glyph names: ['.notdef', '.null', 'A', 'C', 'D', 'E', 'G', 'I', 'K', 'L', 'M', 'N', 'O', 'R', 'S', 'T', 'U', 'X', 'Y', 'a', 'c', 'd', 'e', 'h', 'i', 'k', 'm', 'n', 'nonmarkingreturn', 'o', 'r', 'space', 't']
Glyph IDs:   [0, 1, 2, 3, 36, 38, 39, 40, 42, 44, 46, 47, 48, 49, 50, 53, 54, 55, 56, 59, 60, 68, 70, 71, 72, 75, 76, 78, 80, 81, 82, 85, 87]
Closed glyph list over 'GSUB': 33 glyphs after
Glyph names: ['.notdef', '.null', 'A', 'C', 'D', 'E', 'G', 'I', 'K', 'L', 'M', 'N', 'O', 'R', 'S', 'T', 'U', 'X', 'Y', 'a', 'c', 'd', 'e', 'h', 'i', 'k', 'm', 'n', 'nonmarkingreturn', 'o', 'r', 'space', 't']
Glyph IDs:   [0, 1, 2, 3, 36, 38, 39, 40, 42, 44, 46, 47, 48, 49, 50, 53, 54, 55, 56, 59, 60, 68, 70, 71, 72, 75, 76, 78, 80, 81, 82, 85, 87]
Closing glyph list over 'glyf': 33 glyphs before
Glyph names: ['.notdef', '.null', 'A', 'C', 'D', 'E', 'G', 'I', 'K', 'L', 'M', 'N', 'O', 'R', 'S', 'T', 'U', 'X', 'Y', 'a', 'c', 'd', 'e', 'h', 'i', 'k', 'm', 'n', 'nonmarkingreturn', 'o', 'r', 'space', 't']
Glyph IDs:   [0, 1, 2, 3, 36, 38, 39, 40, 42, 44, 46, 47, 48, 49, 50, 53, 54, 55, 56, 59, 60, 68, 70, 71, 72, 75, 76, 78, 80, 81, 82, 85, 87]
Closed glyph list over 'glyf': 33 glyphs after
Glyph names: ['.notdef', '.null', 'A', 'C', 'D', 'E', 'G', 'I', 'K', 'L', 'M', 'N', 'O', 'R', 'S', 'T', 'U', 'X', 'Y', 'a', 'c', 'd', 'e', 'h', 'i', 'k', 'm', 'n', 'nonmarkingreturn', 'o', 'r', 'space', 't']
Glyph IDs:   [0, 1, 2, 3, 36, 38, 39, 40, 42, 44, 46, 47, 48, 49, 50, 53, 54, 55, 56, 59, 60, 68, 70, 71, 72, 75, 76, 78, 80, 81, 82, 85, 87]
Retaining 33 glyphs
head subsetting not needed
hhea subsetting not needed
maxp subsetting not needed
OS/2 subsetting not needed
hmtx subsetted
cmap subsetted
fpgm subsetting not needed
prep subsetting not needed
cvt  subsetting not needed
loca subsetting not needed
post subsetted
gasp subsetting not needed
GDEF subsetted
GPOS subsetted
GSUB subsetted
name subsetting not needed
glyf subsetted
head pruned
OS/2 Unicode ranges pruned: [0]
OS/2 CodePage ranges pruned: [0]
glyf pruned
GDEF pruned
GPOS pruned
GSUB pruned
name pruned
maxp pruned
cmap pruned
kern dropped
post pruned
FFTM dropped
GPOS pruned
GSUB pruned
glyf pruned
Added gid0 to subset
Added first four glyphs to subset
Closing glyph list over 'GSUB': 34 glyphs before
Glyph names: ['.notdef', '.null', 'D', 'E', 'F', 'N', 'P', 'R', 'S', 'Z', 'a', 'c', 'colon', 'e', 'eight', 'five', 'four', 'g', 'hyphen', 'l', 'nonmarkingreturn', 'o', 'one', 'period', 'plus', 'r', 's', 'six', 'space', 't', 'three', 'two', 'v', 'zero']
Glyph IDs:   [0, 1, 2, 3, 14, 16, 17, 19, 20, 21, 22, 23, 24, 25, 27, 29, 39, 40, 41, 49, 51, 53, 54, 61, 68, 70, 72, 74, 79, 82, 85, 86, 87, 89]
Closed glyph list over 'GSUB': 34 glyphs after
Glyph names: ['.notdef', '.null', 'D', 'E', 'F', 'N', 'P', 'R', 'S', 'Z', 'a', 'c', 'colon', 'e', 'eight', 'five', 'four', 'g', 'hyphen', 'l', 'nonmarkingreturn', 'o', 'one', 'period', 'plus', 'r', 's', 'six', 'space', 't', 'three', 'two', 'v', 'zero']
Glyph IDs:   [0, 1, 2, 3, 14, 16, 17, 19, 20, 21, 22, 23, 24, 25, 27, 29, 39, 40, 41, 49, 51, 53, 54, 61, 68, 70, 72, 74, 79, 82, 85, 86, 87, 89]
Closing glyph list over 'MATH': 34 glyphs before
Glyph names: ['.notdef', '.null', 'D', 'E', 'F', 'N', 'P', 'R', 'S', 'Z', 'a', 'c', 'colon', 'e', 'eight', 'five', 'four', 'g', 'hyphen', 'l', 'nonmarkingreturn', 'o', 'one', 'period', 'plus', 'r', 's', 'six', 'space', 't', 'three', 'two', 'v', 'zero']
Glyph IDs:   [0, 1, 2, 3, 14, 16, 17, 19, 20, 21, 22, 23, 24, 25, 27, 29, 39, 40, 41, 49, 51, 53, 54, 61, 68, 70, 72, 74, 79, 82, 85, 86, 87, 89]
Closed glyph list over 'MATH': 34 glyphs after
Glyph names: ['.notdef', '.null', 'D', 'E', 'F', 'N', 'P', 'R', 'S', 'Z', 'a', 'c', 'colon', 'e', 'eight', 'five', 'four', 'g', 'hyphen', 'l', 'nonmarkingreturn', 'o', 'one', 'period', 'plus', 'r', 's', 'six', 'space', 't', 'three', 'two', 'v', 'zero']
Glyph IDs:   [0, 1, 2, 3, 14, 16, 17, 19, 20, 21, 22, 23, 24, 25, 27, 29, 39, 40, 41, 49, 51, 53, 54, 61, 68, 70, 72, 74, 79, 82, 85, 86, 87, 89]
Closing glyph list over 'glyf': 34 glyphs before
Glyph names: ['.notdef', '.null', 'D', 'E', 'F', 'N', 'P', 'R', 'S', 'Z', 'a', 'c', 'colon', 'e', 'eight', 'five', 'four', 'g', 'hyphen', 'l', 'nonmarkingreturn', 'o', 'one', 'period', 'plus', 'r', 's', 'six', 'space', 't', 'three', 'two', 'v', 'zero']
Glyph IDs:   [0, 1, 2, 3, 14, 16, 17, 19, 20, 21, 22, 23, 24, 25, 27, 29, 39, 40, 41, 49, 51, 53, 54, 61, 68, 70, 72, 74, 79, 82, 85, 86, 87, 89]
Closed glyph list over 'glyf': 34 glyphs after
Glyph names: ['.notdef', '.null', 'D', 'E', 'F', 'N', 'P', 'R', 'S', 'Z', 'a', 'c', 'colon', 'e', 'eight', 'five', 'four', 'g', 'hyphen', 'l', 'nonmarkingreturn', 'o', 'one', 'period', 'plus', 'r', 's', 'six', 'space', 't', 'three', 'two', 'v', 'zero']
Glyph IDs:   [0, 1, 2, 3, 14, 16, 17, 19, 20, 21, 22, 23, 24, 25, 27, 29, 39, 40, 41, 49, 51, 53, 54, 61, 68, 70, 72, 74, 79, 82, 85, 86, 87, 89]
Retaining 34 glyphs
head subsetting not needed
hhea subsetting not needed
maxp subsetting not needed
OS/2 subsetting not needed
hmtx subsetted
cmap subsetted
fpgm subsetting not needed
prep subsetting not needed
cvt  subsetting not needed
loca subsetting not needed
post subsetted
gasp subsetting not needed
MATH subsetted
GDEF subsetted
GPOS subsetted
GSUB subsetted
name subsetting not needed
glyf subsetted
head pruned
OS/2 Unicode ranges pruned: [0]
OS/2 CodePage ranges pruned: [0]
glyf pruned
GDEF pruned
GPOS pruned
GSUB pruned
name pruned
maxp pruned
cmap pruned
kern dropped
post pruned
FFTM dropped
GPOS pruned
GSUB pruned
glyf pruned
Added gid0 to subset
Added first four glyphs to subset
Closing glyph list over 'GSUB': 28 glyphs before
Glyph names: ['.notdef', '.null', 'A', 'C', 'D', 'E', 'G', 'I', 'N', 'O', 'P', 'R', 'S', 'T', 'a', 'c', 'd', 'e', 'h', 'i', 'k', 'm', 'n', 'nonmarkingreturn', 'o', 'r', 'space', 't']
Glyph IDs:   [0, 1, 2, 3, 36, 38, 39, 40, 42, 44, 49, 50, 51, 53, 54, 55, 68, 70, 71, 72, 75, 76, 78, 80, 81, 82, 85, 87]
Closed glyph list over 'GSUB': 28 glyphs after
Glyph names: ['.notdef', '.null', 'A', 'C', 'D', 'E', 'G', 'I', 'N', 'O', 'P', 'R', 'S', 'T', 'a', 'c', 'd', 'e', 'h', 'i', 'k', 'm', 'n', 'nonmarkingreturn', 'o', 'r', 'space', 't']
Glyph IDs:   [0, 1, 2, 3, 36, 38, 39, 40, 42, 44, 49, 50, 51, 53, 54, 55, 68, 70, 71, 72, 75, 76, 78, 80, 81, 82, 85, 87]
Closing glyph list over 'glyf': 28 glyphs before
Glyph names: ['.notdef', '.null', 'A', 'C', 'D', 'E', 'G', 'I', 'N', 'O', 'P', 'R', 'S', 'T', 'a', 'c', 'd', 'e', 'h', 'i', 'k', 'm', 'n', 'nonmarkingreturn', 'o', 'r', 'space', 't']
Glyph IDs:   [0, 1, 2, 3, 36, 38, 39, 40, 42, 44, 49, 50, 51, 53, 54, 55, 68, 70, 71, 72, 75, 76, 78, 80, 81, 82, 85, 87]
Closed glyph list over 'glyf': 28 glyphs after
Glyph names: ['.notdef', '.null', 'A', 'C', 'D', 'E', 'G', 'I', 'N', 'O', 'P', 'R', 'S', 'T', 'a', 'c', 'd', 'e', 'h', 'i', 'k', 'm', 'n', 'nonmarkingreturn', 'o', 'r', 'space', 't']
Glyph IDs:   [0, 1, 2, 3, 36, 38, 39, 40, 42, 44, 49, 50, 51, 53, 54, 55, 68, 70, 71, 72, 75, 76, 78, 80, 81, 82, 85, 87]
Retaining 28 glyphs
head subsetting not needed
hhea subsetting not needed
maxp subsetting not needed
OS/2 subsetting not needed
hmtx subsetted
cmap subsetted
fpgm subsetting not needed
prep subsetting not needed
cvt  subsetting not needed
loca subsetting not needed
post subsetted
gasp subsetting not needed
GDEF subsetted
GPOS subsetted
GSUB subsetted
name subsetting not needed
glyf subsetted
head pruned
OS/2 Unicode ranges pruned: [0]
OS/2 CodePage ranges pruned: [0]
glyf pruned
GDEF pruned
GPOS pruned
GSUB pruned
name pruned
maxp pruned
cmap pruned
kern dropped
post pruned
FFTM dropped
GPOS pruned
GSUB pruned
glyf pruned
Added gid0 to subset
Added first four glyphs to subset
Closing glyph list over 'GSUB': 35 glyphs before
Glyph names: ['.notdef', '.null', 'D', 'E', 'F', 'N', 'P', 'R', 'S', 'Z', 'a', 'c', 'colon', 'e', 'eight', 'five', 'four', 'g', 'hyphen', 'l', 'nine', 'nonmarkingreturn', 'o', 'one', 'period', 'plus', 'r', 's', 'six', 'space', 't', 'three', 'two', 'v', 'zero']
Glyph IDs:   [0, 1, 2, 3, 14, 16, 17, 19, 20, 21, 22, 23, 24, 25, 27, 28, 29, 39, 40, 41, 49, 51, 53, 54, 61, 68, 70, 72, 74, 79, 82, 85, 86, 87, 89]
Closed glyph list over 'GSUB': 35 glyphs after
Glyph names: ['.notdef', '.null', 'D', 'E', 'F', 'N', 'P', 'R', 'S', 'Z', 'a', 'c', 'colon', 'e', 'eight', 'five', 'four', 'g', 'hyphen', 'l', 'nine', 'nonmarkingreturn', 'o', 'one', 'period', 'plus', 'r', 's', 'six', 'space', 't', 'three', 'two', 'v', 'zero']
Glyph IDs:   [0, 1, 2, 3, 14, 16, 17, 19, 20, 21, 22, 23, 24, 25, 27, 28, 29, 39, 40, 41, 49, 51, 53, 54, 61, 68, 70, 72, 74, 79, 82, 85, 86, 87, 89]
Closing glyph list over 'MATH': 35 glyphs before
Glyph names: ['.notdef', '.null', 'D', 'E', 'F', 'N', 'P', 'R', 'S', 'Z', 'a', 'c', 'colon', 'e', 'eight', 'five', 'four', 'g', 'hyphen', 'l', 'nine', 'nonmarkingreturn', 'o', 'one', 'period', 'plus', 'r', 's', 'six', 'space', 't', 'three', 'two', 'v', 'zero']
Glyph IDs:   [0, 1, 2, 3, 14, 16, 17, 19, 20, 21, 22, 23, 24, 25, 27, 28, 29, 39, 40, 41, 49, 51, 53, 54, 61, 68, 70, 72, 74, 79, 82, 85, 86, 87, 89]
Closed glyph list over 'MATH': 35 glyphs after
Glyph names: ['.notdef', '.null', 'D', 'E', 'F', 'N', 'P', 'R', 'S', 'Z', 'a', 'c', 'colon', 'e', 'eight', 'five', 'four', 'g', 'hyphen', 'l', 'nine', 'nonmarkingreturn', 'o', 'one', 'period', 'plus', 'r', 's', 'six', 'space', 't', 'three', 'two', 'v', 'zero']
Glyph IDs:   [0, 1, 2, 3, 14, 16, 17, 19, 20, 21, 22, 23, 24, 25, 27, 28, 29, 39, 40, 41, 49, 51, 53, 54, 61, 68, 70, 72, 74, 79, 82, 85, 86, 87, 89]
Closing glyph list over 'glyf': 35 glyphs before
Glyph names: ['.notdef', '.null', 'D', 'E', 'F', 'N', 'P', 'R', 'S', 'Z', 'a', 'c', 'colon', 'e', 'eight', 'five', 'four', 'g', 'hyphen', 'l', 'nine', 'nonmarkingreturn', 'o', 'one', 'period', 'plus', 'r', 's', 'six', 'space', 't', 'three', 'two', 'v', 'zero']
Glyph IDs:   [0, 1, 2, 3, 14, 16, 17, 19, 20, 21, 22, 23, 24, 25, 27, 28, 29, 39, 40, 41, 49, 51, 53, 54, 61, 68, 70, 72, 74, 79, 82, 85, 86, 87, 89]
Closed glyph list over 'glyf': 35 glyphs after
Glyph names: ['.notdef', '.null', 'D', 'E', 'F', 'N', 'P', 'R', 'S', 'Z', 'a', 'c', 'colon', 'e', 'eight', 'five', 'four', 'g', 'hyphen', 'l', 'nine', 'nonmarkingreturn', 'o', 'one', 'period', 'plus', 'r', 's', 'six', 'space', 't', 'three', 'two', 'v', 'zero']
Glyph IDs:   [0, 1, 2, 3, 14, 16, 17, 19, 20, 21, 22, 23, 24, 25, 27, 28, 29, 39, 40, 41, 49, 51, 53, 54, 61, 68, 70, 72, 74, 79, 82, 85, 86, 87, 89]
Retaining 35 glyphs
head subsetting not needed
hhea subsetting not needed
maxp subsetting not needed
OS/2 subsetting not needed
hmtx subsetted
cmap subsetted
fpgm subsetting not needed
prep subsetting not needed
cvt  subsetting not needed
loca subsetting not needed
post subsetted
gasp subsetting not needed
MATH subsetted
GDEF subsetted
GPOS subsetted
GSUB subsetted
name subsetting not needed
glyf subsetted
head pruned
OS/2 Unicode ranges pruned: [0]
OS/2 CodePage ranges pruned: [0]
glyf pruned
GDEF pruned
GPOS pruned
GSUB pruned
name pruned
@earmingol earmingol changed the title Message flooding of glyphs when saving PDFs after changing font in matplotlib Message flooding about glyphs when saving PDFs after changing font in matplotlib Dec 6, 2023
@earmingol earmingol changed the title Message flooding about glyphs when saving PDFs after changing font in matplotlib Message flooding about glyphs when saving PDFs after changing fonts in matplotlib Dec 6, 2023
@earmingol earmingol changed the title Message flooding about glyphs when saving PDFs after changing fonts in matplotlib Too many logs about glyphs when saving PDFs after changing fonts in matplotlib Dec 13, 2023
@lldelisle
Copy link

This worked for me:

import logging
logging.getLogger("fontTools").setLevel(logging.WARNING)

@behdad
Copy link
Member

behdad commented May 1, 2024

I didn't know matplotlib uses fonttools to subset fonts for embedding in PDF. That's really cool!

@behdad
Copy link
Member

behdad commented May 1, 2024

import logging
logging.getLogger("fontTools").setLevel(logging.WARNING)

Then maybe report it to matplotlib to do that?

@lldelisle
Copy link

I put it there: matplotlib/matplotlib#24546

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants