8000 Drop support for dvipng 1.5; drop dvipnghack. · matplotlib/matplotlib@8940c66 · GitHub
[go: up one dir, main page]

Skip to content

Commit 8940c66

Browse files
committed
Drop support for dvipng 1.5; drop dvipnghack.
dvipng 1.5 was released on 2005-02-04 and 1.6 on 2005-04-04 (http://git.savannah.nongnu.org/cgit/dvipng.git), so it isn't really worth carrying a hack just to support two more months.
1 parent 83db163 commit 8940c66

File tree

7 files changed

+7
-70
lines changed

7 files changed

+7
-70
lines changed

lib/matplotlib/__init__.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -496,7 +496,7 @@ def checkdep_usetex(s):
496496
return False
497497

498498
gs_req = '8.60'
499-
dvipng_req = '1.5'
499+
dvipng_req = '1.6'
500500
flag = True
501501

502502
if _backports.which("tex") is None:
@@ -508,8 +508,8 @@ def checkdep_usetex(s):
508508
if not compare_versions(dvipng_v, dvipng_req):
509509
flag = False
510510
warnings.warn('matplotlibrc text.usetex can not be used with *Agg '
511-
'backend unless dvipng-1.5 or later is installed on '
512-
'your system')
511+
'backend unless dvipng-%s or later is installed on '
512+
'your system' % dvipng_req)
513513

514514
gs_exec, gs_v = checkdep_ghostscript()
515515
if not compare_versions(gs_v, gs_req):
@@ -812,7 +812,7 @@ def gen_candidates():
812812

813813
_deprecated_ignore_map = {}
814814

815-
_obsolete_set = {'legend.isaxes'}
815+
_obsolete_set = {'text.dvipnghack', 'legend.isaxes'}
816816

817817
# The following may use a value of None to suppress the warning.
818818
_deprecated_set = {'axes.hold'} # do NOT include in _all_deprecated

lib/matplotlib/mpl-data/stylelib/_classic_test.mplstyle

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -124,13 +124,6 @@ text.latex.preamble : # IMPROPER USE OF THIS FEATURE WILL LEAD TO LATEX FAILURE
124124
# may also be loaded, depending on your font settings
125125
text.latex.preview : False
126126

127-
text.dvipnghack : None # some versions of dvipng don't handle alpha
128-
# channel properly. Use True to correct
129-
# and flush ~/.matplotlib/tex.cache
130-
# before testing and False to force
131-
# correction off. None will try and
132-
# guess based on your dvipng version
133-
134127
text.hinting : auto # May be one of the following:
135128
# 'none': Perform no hinting
136129
# 'auto': Use freetype's autohinter

lib/matplotlib/mpl-data/stylelib/classic.mplstyle

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -124,13 +124,6 @@ text.latex.preamble : # IMPROPER USE OF THIS FEATURE WILL LEAD TO LATEX FAILURE
124124
# may also be loaded, depending on your font settings
125125
text.latex.preview : False
126126

127-
text.dvipnghack : None # some versions of dvipng don't handle alpha
128-
# channel properly. Use True to correct
129-
# and flush ~/.matplotlib/tex.cache
130-
# before testing and False to force
131-
# correction off. None will try and
132-
# guess based on your dvipng version
133-
134127
text.hinting : auto # May be one of the following:
135128
# 'none': Perform no hinting
136129
# 'auto': Use freetype's autohinter

lib/matplotlib/tests/test_backend_pdf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
import pytest
1313

1414
import numpy as np
15-
from matplotlib import checkdep_tex, cm, rcParams
15+
from matplotlib import checkdep_usetex, cm, rcParams
1616
from matplotlib.backends.backend_pdf import PdfPages
1717
from matplotlib import pyplot as plt
1818
from matplotlib.testing.determinism import (_determinism_source_date_epoch,

lib/matplotlib/texmanager.py

Lines changed: 2 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@
6565
cmd_split = ';'
6666

6767

68+
@mpl.cbook.deprecated("2.1")
6869
def dvipng_hack_alpha():
6970
try:
7071
p = Popen([str('dvipng'), '-version'], stdin=PIPE, stdout=PIPE,
@@ -122,8 +123,6 @@ class TexManager(object):
122123
if texcache is not None:
123124
mkdirs(texcache)
124125

125-
_dvipng_hack_alpha = None
126-
#_dvipng_hack_alpha = dvipng_hack_alpha()
127126
# mappable cache of
128127
rgba_arrayd = {}
129128
grey_arrayd = {}
@@ -542,46 +541,10 @@ def get_grey(self, tex, fontsize=None, dpi=None):
542541
"""returns the alpha channel"""
543542
key = tex, self.get_font_config(), fontsize, dpi
544543
alpha = self.grey_arrayd.get(key)
545-
546544
if alpha is None:
547545
pngfile = self.make_png(tex, fontsize, dpi)
548546
X = read_png(os.path.join(self.texcache, pngfile))
549-
550-
if rcParams['text.dvipnghack'] is not None:
551-
hack = rcParams['text.dvipnghack']
552-
else:
553-
if TexManager._dvipng_hack_alpha is None:
554-
TexManager._dvipng_hack_alpha = dvipng_hack_alpha()
555-
hack = TexManager._dvipng_hack_alpha
556-
557-
if hack:
558-
# hack the alpha channel
559-
# dvipng assumed a constant background, whereas we want to
560-
# overlay these rasters with antialiasing over arbitrary
561-
# backgrounds that may have other figure elements under them.
562-
# When you set dvipng -bg Transparent, it actually makes the
563-
# alpha channel 1 and does the background compositing and
564-
# antialiasing itself and puts the blended data in the rgb
565-
# channels. So what we do is extract the alpha information
566-
# from the red channel, which is a blend of the default dvipng
567-
# background (white) and foreground (black). So the amount of
568-
# red (or green or blue for that matter since white and black
569-
# blend to a grayscale) is the alpha intensity. Once we
570-
# extract the correct alpha information, we assign it to the
571-
# alpha channel properly and let the users pick their rgb. In
572-
# this way, we can overlay tex strings on arbitrary
573-
# backgrounds with antialiasing
574-
#
575-
# red = alpha*red_foreground + (1-alpha)*red_background
576-
#
577-
# Since the foreground is black (0) and the background is
578-
# white (1) this reduces to red = 1-alpha or alpha = 1-red
579-
#alpha = npy.sqrt(1-X[:,:,0]) # should this be sqrt here?
580-
alpha = 1 - X[:, :, 0]
581-
else:
582-
alpha = X[:, :, -1]
583-
584-
self.grey_arrayd[key] = alpha
547+
self.grey_arrayd[key] = alpha = X[:, :, -1]
585548
return alpha
586549

587550
def get_rgba(self, tex, fontsize=None, dpi=None, rgb=(0, 0, 0)):

matplotlibrc.template

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -243,14 +243,6 @@ backend : $TEMPLATE_BACKEND
243243
# beware of package collisions: color, geometry, graphicx,
244244
# type1cm, textcomp. Adobe Postscript (PSSNFS) font packages
245245
# may also be loaded, depending on your font settings
246-
247-
#text.dvipnghack : None # some versions of dvipng don't handle alpha
248-
# channel properly. Use True to correct
249-
# and flush ~/.matplotlib/tex.cache
250-
# before testing and False to force
251-
# correction off. None will try and
252-
# guess based on your dvipng version
253-
254246
#text.hinting : auto # May be one of the following:
255247
# 'none': Perform no hinting
256248
# 'auto': Use FreeType's autohinter

tutorials/text/usetex.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -119,10 +119,6 @@
119119
* Using MiKTeX with Computer Modern fonts, if you get odd \*Agg and PNG
120120
results, go to MiKTeX/Options and update your format files
121121
122-
* The fonts look terrible on screen. You are probably running Mac OS, and there
123-
is some funny business with older versions of dvipng on the mac. Set
124-
``text.dvipnghack : True`` in your matplotlibrc file.
125-
126122
* On Ubuntu and Gentoo, the base texlive install does not ship with
127123
the type1cm package. You may need to install some of the extra
128124
packages to get all the goodies that come bundled with other latex

0 commit comments

Comments
 (0)
0