Removed ImageFont filename param, deprecated in 2.1

This commit is contained in:
Andrew Murray 2015-07-13 17:39:34 +10:00
parent 3e47ddbeeb
commit 3841a11fb5
2 changed files with 3 additions and 24 deletions

View File

@ -121,15 +121,8 @@ class ImageFont(object):
class FreeTypeFont(object): class FreeTypeFont(object):
"FreeType font wrapper (requires _imagingft service)" "FreeType font wrapper (requires _imagingft service)"
def __init__(self, font=None, size=10, index=0, encoding="", file=None): def __init__(self, font=None, size=10, index=0, encoding=""):
# FIXME: use service provider instead # FIXME: use service provider instead
if file:
if warnings:
warnings.warn(
'file parameter deprecated, '
'please use font parameter instead.',
DeprecationWarning)
font = file
self.path = font self.path = font
self.size = size self.size = size
@ -171,7 +164,7 @@ class FreeTypeFont(object):
using any specified arguments to override the settings. using any specified arguments to override the settings.
Parameters are identical to the parameters used to initialize this Parameters are identical to the parameters used to initialize this
object, minus the deprecated 'file' argument. object.
:return: A FreeTypeFont object. :return: A FreeTypeFont object.
""" """
@ -225,7 +218,7 @@ def load(filename):
return f return f
def truetype(font=None, size=10, index=0, encoding="", filename=None): def truetype(font=None, size=10, index=0, encoding=""):
""" """
Load a TrueType or OpenType font file, and create a font object. Load a TrueType or OpenType font file, and create a font object.
This function loads a font object from the given file, and creates This function loads a font object from the given file, and creates
@ -243,19 +236,10 @@ def truetype(font=None, size=10, index=0, encoding="", filename=None):
Symbol), "ADOB" (Adobe Standard), "ADBE" (Adobe Expert), Symbol), "ADOB" (Adobe Standard), "ADBE" (Adobe Expert),
and "armn" (Apple Roman). See the FreeType documentation and "armn" (Apple Roman). See the FreeType documentation
for more information. for more information.
:param filename: Deprecated. Please use font instead.
:return: A font object. :return: A font object.
:exception IOError: If the file could not be read. :exception IOError: If the file could not be read.
""" """
if filename:
if warnings:
warnings.warn(
'filename parameter deprecated, '
'please use font parameter instead.',
DeprecationWarning)
font = filename
try: try:
return FreeTypeFont(font, size, index, encoding) return FreeTypeFont(font, size, index, encoding)
except IOError: except IOError:

View File

@ -88,11 +88,6 @@ try:
self._render(f) self._render(f)
self._clean() self._clean()
def test_font_old_parameters(self):
self.assert_warning(
DeprecationWarning,
lambda: ImageFont.truetype(filename=FONT_PATH, size=FONT_SIZE))
def _render(self, font): def _render(self, font):
txt = "Hello World!" txt = "Hello World!"
ttf = ImageFont.truetype(font, FONT_SIZE) ttf = ImageFont.truetype(font, FONT_SIZE)