Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit d730481

Browse files
jenshnielsenmdboom
authored andcommitted
Merge pull request #5306 from mdboom/local-freetype
Use a specific version of Freetype for testing
1 parent c22614e commit d730481

18 files changed

+190
-54
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ dist
3939
.eggs
4040
# tox testing tool
4141
.tox
42+
setup.cfg
4243

4344
# OS generated files #
4445
######################

.travis.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ install:
8282
# version since is it basically just a .ttf file
8383
# The current Travis Ubuntu image is to old to search .local/share/fonts so we store fonts in .fonts
8484

85-
# We install ipython to use the console highlighting. From IPython 3 this depends on jsonschema and misture.
85+
# We install ipython to use the console highlighting. From IPython 3 this depends on jsonschema and mistune.
8686
# Neihter is installed as a dependency of IPython since they are not used by the IPython console.
8787
- |
8888
if [[ $BUILD_DOCS == true ]]; then
@@ -96,7 +96,11 @@ install:
9696
cp tmp/usr/share/fonts/truetype/humor-sans/Humor-Sans.ttf ~/.fonts
9797
cp Felipa-Regular.ttf ~/.fonts
9898
fc-cache -f -v
99+
else
100+
# Use the special local version of freetype for testing
101+
cp .travis/setup.cfg .
99102
fi;
103+
100104
- python setup.py install
101105

102106
script:

.travis/setup.cfg

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
[test]
2+
local_freetype=True

INSTALL

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ libpng 1.2 (or later)
208208
`pytz`
209209
Used to manipulate time-zone aware datetimes.
210210

211-
:term:`freetype` 2.3 or later
211+
:term:`FreeType` 2.3 or later
212212
library for reading true type font files.
213213

214214
``cycler`` 0.9 or later

doc/devel/testing.rst

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,22 @@ Optionally you can install:
3333

3434
- `pep8 <http://pep8.readthedocs.org/en/latest>`_ to test coding standards
3535

36+
Building matplotlib for image comparison tests
37+
----------------------------------------------
38+
39+
matplotlib's test suite makes heavy use of image comparison tests,
40+
meaning the result of a plot is compared against a known good result.
41+
Unfortunately, different versions of FreeType produce differently
42+
formed characters, causing these image comparisons to fail. To make
43+
them reproducible, matplotlib can be built with a special local copy
44+
of FreeType. This is recommended for all matplotlib developers.
45+
46+
Add the following content to a ``setup.cfg`` file at the root of the
47+
matplotlib source directory::
48+
49+
[test]
50+
local_freetype = True
51+
3652
Running the tests
3753
-----------------
3854

@@ -185,17 +201,6 @@ decorator:
185201
If some variation is expected in the image between runs, this
186202
value may be adjusted.
187203

188-
Freetype version
189-
----------------
190-
191-
Due to subtle differences in the font rendering under different
192-
version of freetype some care must be taken when generating the
193-
baseline images. Currently (early 2015), almost all of the images
194-
were generated using ``freetype 2.5.3-21`` on Fedora 21 and only the
195-
fonts that ship with ``matplotlib`` (regenerated in PR #4031 / commit
196-
005cfde02751d274f2ab8016eddd61c3b3828446) and travis is using
197-
``freetype 2.4.8`` on ubuntu.
198-
199204
Known failing tests
200205
-------------------
201206

doc/glossary/index.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ Glossary
2222
EPS
2323
Encapsulated Postscript (`EPS <http://en.wikipedia.org/wiki/Encapsulated_PostScript>`_)
2424

25-
freetype
26-
`freetype <http://www.freetype.org/>`_ is a font rasterization
25+
FreeType
26+
`FreeType <http://www.freetype.org/>`_ is a font rasterization
2727
library used by matplotlib which supports TrueType, Type 1, and
2828
OpenType fonts.
2929

doc/users/screenshots.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,7 @@ Mathtext_examples
252252

253253
Below is a sampling of the many TeX expressions now supported by matplotlib's
254254
internal mathtext engine. The mathtext module provides TeX style mathematical
255-
expressions using `freetype2 <http://www.freetype.org/>`_
255+
expressions using `FreeType <http://www.freetype.org/>`_
256256
and the BaKoMa computer modern or `STIX <http://www.stixfonts.org>`_ fonts.
257257
See the :mod:`matplotlib.mathtext` module for additional details.
258258

doc/users/text_intro.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ expressions, truetype support for raster and vector outputs, newline
88
separated text with arbitrary rotations, and unicode support. Because
99
we embed the fonts directly in the output documents, e.g., for postscript
1010
or PDF, what you see on the screen is what you get in the hardcopy.
11-
`freetype2 <http://www.freetype.org/>`_ support
11+
`FreeType <http://www.freetype.org/>`_ support
1212
produces very nice, antialiased fonts, that look good even at small
1313
raster sizes. matplotlib includes its own
1414
:mod:`matplotlib.font_manager`, thanks to Paul Barrett, which

examples/pylab_examples/font_table_ttf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# -*- noplot -*-
22
"""
3-
matplotlib has support for freetype fonts. Here's a little example
3+
matplotlib has support for FreeType fonts. Here's a little example
44
using the 'table' command to build a font table that shows the glyphs
55
by character code.
66

lib/matplotlib/__init__.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1488,6 +1488,18 @@ def verify_test_dependencies():
14881488
if not os.path.isdir(os.path.join(os.path.dirname(__file__), 'tests')):
14891489
raise ImportError("matplotlib test data is not installed")
14901490

1491+
# The version of FreeType to install locally for running the
1492+
# tests. This must match the value in `setupext.py`
1493+
LOCAL_FREETYPE_VERSION = '2.6.1'
1494+
1495+
from matplotlib import ft2font
1496+
if (ft2font.__freetype_version__ != LOCAL_FREETYPE_VERSION or
1497+
ft2font.__freetype_build_type__ != 'local'):
1498+
warnings.warn(
1499+
"matplotlib is not built with the correct FreeType version to run "
1500+
"tests. Set local_freetype=True in setup.cfg and rebuild. "
1501+
"Expect many image comparison failures below.")
1502+
14911503
try:
14921504
import nose
14931505
try:

lib/matplotlib/mathtext.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ class MathtextBackend(object):
113113
- :meth:`render_rect_filled`
114114
- :meth:`get_results`
115115
116-
And optionally, if you need to use a Freetype hinting style:
116+
And optionally, if you need to use a FreeType hinting style:
117117
118118
- :meth:`get_hinting_type`
119119
"""
@@ -150,7 +150,7 @@ def get_results(self, box):
150150

151151
def get_hinting_type(self):
152152
"""
153-
Get the Freetype hinting type to use with this particular
153+
Get the FreeType hinting type to use with this particular
154154
backend.
155155
"""
156156
return LOAD_NO_HINTING

matplotlibrc.template

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -195,10 +195,10 @@ backend : %(backend)s
195195

196196
#text.hinting : auto # May be one of the following:
197197
# 'none': Perform no hinting
198-
# 'auto': Use freetype's autohinter
198+
# 'auto': Use FreeType's autohinter
199199
# 'native': Use the hinting information in the
200200
# font file, if available, and if your
201-
# freetype library supports it
201+
# FreeType library supports it
202202
# 'either': Use the native hinting information,
203203
# or the autohinter if none is available.
204204
# For backward compatibility, this value may also be
@@ -357,9 +357,9 @@ backend : %(backend)s
357357
#image.lut : 256 # the size of the colormap lookup table
358358
#image.origin : upper # lower | upper
359359
#image.resample : False
360-
#image.composite_image : True # When True, all the images on a set of axes are
361-
# combined into a single composite image before
362-
# saving a figure as a vector graphics file,
360+
#image.composite_image : True # When True, all the images on a set of axes are
361+
# combined into a single composite image before
362+
# saving a figure as a vector graphics file,
363363
# such as a PDF.
364364

365365
### CONTOUR PLOTS

setup.cfg.template

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,13 @@
88
# This can be a single directory or a comma-delimited list of directories.
99
#basedirlist = /usr
1010

11+
[test]
12+
# If you plan to develop matplotlib and run or add to the test suite,
13+
# set this to True. It will download and build a specific version of
14+
# FreeType, and then use that to build the ft2font extension. This
15+
# ensures that test images are exactly reproducible.
16+
#local_freetype = False
17+
1118
[status]
1219
# To suppress display of the dependencies and their versions
1320
# at the top of the build log, uncomment the following line:

setup.py

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
from distribute_setup import use_setuptools
1010
use_setuptools()
1111
from setuptools.command.test import test as TestCommand
12+
from setuptools.command.build_ext import build_ext as BuildExtCommand
1213

1314
import sys
1415

@@ -239,8 +240,19 @@ def run_tests(self):
239240
argv=['nosetests'] + self.test_args,
240241
exit=True)
241242

243+
244+
class BuildExtraLibraries(BuildExtCommand):
245+
def run(self):
246+
for package in good_packages:
247+
package.do_custom_build()
248+
249+
return BuildExtCommand.run(self)
250+
251+
242252
cmdclass = versioneer.get_cmdclass()
243253
cmdclass['test'] = NoseTestCommand
254+
cmdclass['build_ext'] = BuildExtraLibraries
255+
244256

245257
# One doesn't normally see `if __name__ == '__main__'` blocks in a setup.py,
246258
# however, this is needed on Windows to avoid creating infinite subprocesses
@@ -303,8 +315,6 @@ def run_tests(self):
303315
# Now collect all of the information we need to build all of the
304316
# packages.
305317
for package in good_packages:
306-
if isinstance(package, str):
307-
continue
308318
packages.extend(package.get_packages())
309319
namespace_packages.extend(package.get_namespace_packages())
310320
py_modules.extend(package.get_py_modules())

0 commit comments

Comments
 (0)