Repository navigation
Description
Bug report
Some glyphs of Emoji fonts (Segoe UI Emoji, NoTO Color Emopji or TwitterColor Emoji) are not rendered in nbAgg, tkAgg and WebAgg backends (Jupyter notebook).
But those fonts are well rendered with display(HTML( some_text) ).
I've been looking for all the issues related to this rendering problem but no solution solves the problem.
Code for reproduction
First thing I do is here : the settings of rcParams (I believe it's redundant but I wanted to be sure that everything leads to Segoe UI Emoji) and the font cache reset :
import matplotlib.font_manager as fm
from matplotlib import rcParams
from matplotlib.font_manager import findfont, FontProperties
## not written here : I erase the font cache file obtained via matplotlib.get_cachedir()
path = 'C:\\Windows\\Fonts\\seguiemj.ttf'
prop = fm.FontProperties(fname=path)
## print(prop.get_name()) --> Segoe UI Emoji
## print(prop.get_family()) --> ['sans-serif']
rcParams['font.family'] = 'sans-serif'
for family in ['sans-serif', 'serif', 'cursive', 'fantasy', 'monospace']:
rcParams['font.' + family] = ['Segoe UI Emoji']
font = findfont(FontProperties(family=['sans-serif']))
font # output display : 'C:\\Windows\\Fonts\\seguiemj.ttf'
Once it's done I do my plot :
# -*- coding: utf-8 -*-
%matplotlib notebook
import matplotlib.pyplot as plt
import matplotlib
#matplotlib.use('WebAgg', force=True) ##also tested and gives the same error
#matplotlib.use('TkAgg', force=True) ##also tested and leads to a crash
fig = plt.figure(figsize=(3, 3))
ax = fig.gca()
t1 = ax.text(0.5, 1.5,'some_text_\U0001F600', fontproperties=prop)
t2 = ax.text(0.5, 0.5,'some_text_\u2639', fontproperties=prop)
plt.axis([0, 2, 0, 2])
plt.show()
this leads to the following Error message (when the font cache has been previously erased) :
- c:\users\surface\appdata\local\programs\python\python38\lib\site-packages\matplotlib\backends\backend_agg.py:214: RuntimeWarning: Glyph 55357 missing from current font.
- font.set_text(s, 0.0, flags=flags)
- c:\users\surface\appdata\local\programs\python\python38\lib\site-packages\matplotlib\backends\backend_agg.py:214: RuntimeWarning: Glyph 56832 missing from current font.
- font.set_text(s, 0.0, flags=flags)
- c:\users\surface\appdata\local\programs\python\python38\lib\site-packages\matplotlib\backends\backend_agg.py:183: RuntimeWarning: Glyph 55357 missing from current font.
- font.set_text(s, 0, flags=flags)
- c:\users\surface\appdata\local\programs\python\python38\lib\site-packages\matplotlib\backends\backend_agg.py:183: RuntimeWarning: Glyph 56832 missing from current font.
- font.set_text(s, 0, flags=flags)
However the font Segoe UI Emoji is the standard Windows Emoji Font (and I've also tried with Twitter Emoji font or NoTo Color Emoji) and it is usually compatible in Jupyter notebooks since the following code :
%%html
<style>
@font-face {
font-family: 'Segoe UI Emoji';
src: url(C:/Windows/Fonts/seguiemj.ttf) format("truetype");
}
.output{
font-family: 'Segoe UI Emoji';
}
</style>
followed by :
from IPython.display import display, HTML
display(HTML('some_text_\U0001F600'))
display(HTML('some_text_\u2639'))
Since I've tried to solve the problem for a couple of a couple of hours with no solution, I post this here.
I hope you understand the problem I describe? I've watched many solutions but no one seems to work (I want to be on a standard installation in a GUI since this would be for educational purposes and I can't modify students machine settings or students machine installation, for instance using Cairo would not be relevant for me).
Matplotlib version
- Operating system: Windows 10
- Matplotlib version: 3.2.1
- Matplotlib backend :
- nbAgg : glyphs are never displayed on the plot (blank boxes) and en error is written on output when the font cache has been flushed.
- WebAgg : glyphs are never displayed on the plot (blank boxes) and en error is written on output when the font cache has been flushed.
- tkAgg : crash (infinite loop) - Python version: 3.8.2
- Jupyter version (if applicable):
- jupyter core : 4.6.3
- jupyter-notebook : 6.0.3
- qtconsole : 4.7.3
- ipython : 7.13.0
- ipykernel : 5.2.1
- jupyter client : 6.1.3
- jupyter lab : not installed
- nbconvert : 5.6.1
- ipywidgets : 7.5.1
- nbformat : 5.0.6
- traitlets : 4.3.3
- matplotlib installed via pip, python via standrad installation


Activity
anntzer commentedon May 23, 2020
This actually works for me with (tk)agg (and Matplotlib master)... You get black and white emojis, but that's basically tracked at #12830.
(The fact that
display(HTML(...))works is basically irrelevant for Matplotlib as the text rendering sytsem is completely different.)python-villon commentedon May 23, 2020
Thanks for your reply.
I am not sure to understand : are you meaning that the only known solution is to use mplCairo ?
I had read #12830 and #4492 (that's why I mentionned Cairo in my last words) but I didn't want to use that solution.
If it's the only way I will try it and keep you informed about the issue (Altough it doesn't fit to my needs for my students).
anntzer commentedon May 23, 2020
No, my point is that things actually work for me (with b/w) with (tk)agg.
python-villon commentedon May 23, 2020
Ok, so I've re-tried with TkAgg and it fails as with nbAgg or WebAgg.
I also try to do it with mplcairo but ... at the moment it crashes ... I further investigate mplcairo actuallly ...
python-villon commentedon May 23, 2020
I wonder why one Unicode code point is considered as two glyphs : it seems like if 32-bits unicode code points were considered as two glyphs (I'm not a unicode encoding specialist ... ???)
python-villon commentedon May 23, 2020
If you tell me that the support is only for black and white unicode code points, you can close the issue (typically if we should not use +U0001FXXX codepoints that lead to color glyphs).
[I have done my best efforts to solve the issue]
github-actions commentedon Aug 4, 2023
This issue has been marked "inactive" because it has been 365 days since the last comment. If this issue is still present in recent Matplotlib releases, or the feature request is still wanted, please leave a comment and this label will be removed. If there are no updates in another 30 days, this issue will be automatically closed, but you are free to re-open or create a new issue if needed. We value issue reports, and this procedure is meant to help us resurface and prioritize issues that have not been addressed yet, not make them disappear. Thanks for your help!
tacaswell commentedon Aug 4, 2023
I am going to close this as: