Repository: matplotlib/matplotlib

Issue #12308: #12253 FIX: Handle utf-8 output by kpathsea on Windows -- possibly causing issues
Created: 2018-09-27T15:37:54Z
Bug report
I like to test my code against the bleeding edge version of matplotlib (by installing it in a conda virtual environment) on my work machine (Windows PC). Since I do not have admin rights to install the necessary tools to build from source, I download the wheels from appveyor and use pip install.
The following code snippet (representing a part of my working code) started giving an error after I installed "matplotlib-3.0.0rc1+424.g19420b97.dirty-cp36-cp36m-win_amd64.whl" (which corresponds to Merge pull request #12253 from anntzer/kpathsea-encoding FIX: Handle utf-8 output by kpathsea on Windows). The wheel which was built for the commit before that, matplotlib-3.0.0rc1+420.gb2c89917.dirty-cp36-cp36m-win_amd64.whl works fine (I reinstalled it and the code snippet works).
I am not sure if this is the right way to test the bleeding edge code (when you do not have admin rights to install the tools necessary to build from source). If the procedure I am following is not correct, please feel free to close the issue.

Code for reproduction
import matplotlib.pyplot as plt
import numpy as np
from matplotlib import rc
rc('text', usetex=True)
rc('text.latex', preamble=r'\usepackage{fourier}, \usepackage[T1]{fontenc}')
fig, ax = plt.subplots()
ax.plot(np.arange(10))
fig.savefig('test.pdf')

Actual outcome

OSError: [Errno 22] Invalid argument: 'C:/Program Files/MiKTeX 2.9/fonts/tfm/jknappen/ec/ecss1000.tfm
\r'

Expected outcome


Matplotlib version



Operating system: Windows 10


Matplotlib version: 3.0.0rc1+424.g19420b97.dirty


Matplotlib backend (print(matplotlib.get_backend())): Qt5Agg


Python version:


Jupyter version (if applicable):


Other libraries:

Duplicate issue #12352: TeX rendering broken on master with windows
Created: 2018-09-30T21:31:31Z
Bug report
Bug summary
Using tex (rcParams["text.usetex"] = True) results in an error because of a font name not being valid in current master. Works fine with matplotlib 2.2.3.
Code for reproduction

import matplotlib.pyplot as plt
plt.rcParams["text.usetex"] = True

plt.plot([1,2,3])
plt.show()

Actual outcome

  File "d:\***\matplotlib\lib\matplotlib\dviread.py", line 736, in __init__
    with open(filename, 'rb') as file:
OSError: [Errno 22] Invalid argument: 'D:/Programme/Office/MiKTeX/fonts/tfm/public/cm/cmr10.tfm\r'

I would suspect the \r simply does not belong at the end of the string.

 Complete Traceback
Traceback (most recent call last):
  File "d:\***\matplotlib\lib\matplotlib\backends\backend_qt5.py", line 519, in _draw_idle
    self.draw()
  File "d:\***\matplotlib\lib\matplotlib\backends\backend_agg.py", line 399, in draw
    self.figure.draw(self.renderer)
  File "d:\***\matplotlib\lib\matplotlib\artist.py", line 34, in draw_wrapper
    return draw(artist, renderer, *args, **kwargs)
  File "d:\***\matplotlib\lib\matplotlib\figure.py", line 1649, in draw
    renderer, self, artists, self.suppressComposite)
  File "d:\***\matplotlib\lib\matplotlib\image.py", line 137, in _draw_list_compositing_images
    a.draw(renderer)
  File "d:\***\matplotlib\lib\matplotlib\artist.py", line 34, in draw_wrapper
    return draw(artist, renderer, *args, **kwargs)
  File "d:\***\matplotlib\lib\matplotlib\axes\_base.py", line 2623, in draw
    mimage._draw_list_compositing_images(renderer, self, artists)
  File "d:\***\matplotlib\lib\matplotlib\image.py", line 137, in _draw_list_compositing_images
    a.draw(renderer)
  File "d:\***\matplotlib\lib\matplotlib\artist.py", line 34, in draw_wrapper
    return draw(artist, renderer, *args, **kwargs)
  File "d:\***\matplotlib\lib\matplotlib\axis.py", line 1186, in draw
    renderer)
  File "d:\***\matplotlib\lib\matplotlib\axis.py", line 1124, in _get_tick_bboxes
    extent = tick.label1.get_window_extent(renderer)
  File "d:\***\matplotlib\lib\matplotlib\text.py", line 902, in get_window_extent
    bbox, info, descent = self._get_layout(self._renderer)
  File "d:\***\matplotlib\lib\matplotlib\text.py", line 312, in _get_layout
    ismath=ismath)
  File "d:\***\matplotlib\lib\matplotlib\backends\backend_agg.py", line 206, in get_text_width_height_descent
    s, fontsize, renderer=self)
  File "d:\***\matplotlib\lib\matplotlib\texmanager.py", line 466, in get_text_width_height_descent
    page = next(iter(dvi))
  File "d:\***\matplotlib\lib\matplotlib\dviread.py", line 244, in __iter__
    while self._read():
  File "d:\***\matplotlib\lib\matplotlib\dviread.py", line 302, in _read
    self._dtable[byte](self, byte)
  File "d:\***\matplotlib\lib\matplotlib\dviread.py", line 162, in wrapper
    return method(self, *[f(self, byte-min) for f in get_args])
  File "d:\***\matplotlib\lib\matplotlib\dviread.py", line 442, in _fnt_def
    self._fnt_def_real(k, c, s, d, a, l)
  File "d:\***\matplotlib\lib\matplotlib\dviread.py", line 447, in _fnt_def_real
    tfm = _tfmfile(fontname)
  File "d:\***\matplotlib\lib\matplotlib\dviread.py", line 1035, in _fontfile
    return cls(filename) if filename else None
  File "d:\***\matplotlib\lib\matplotlib\dviread.py", line 736, in __init__
    with open(filename, 'rb') as file:
OSError: [Errno 22] Invalid argument: 'D:/Programme/Office/MiKTeX/fonts/tfm/public/cm/cmr10.tfm\r'



Expected outcome
No Error.
Matplotlib version


Operating system: Windows 8.1
Matplotlib version: master
Matplotlib backend (print(matplotlib.get_backend())): Qt5Agg
Python version: 3.6

Closing comment (2018-10-01T09:43:04Z): I think that's a duplicate of #12308, I posted a proposed fix there, can you confirm it works?