From 81a660f7e4f0fd35d25afb52b2c40f0cb5f40bc3 Mon Sep 17 00:00:00 2001 From: Hsiaoming Yang Date: Tue, 2 Dec 2014 20:22:17 +0800 Subject: [PATCH] Add font_sizes for ImageCaptcha --- captcha/image.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/captcha/image.py b/captcha/image.py index 12d3670..1820883 100644 --- a/captcha/image.py +++ b/captcha/image.py @@ -97,11 +97,13 @@ class ImageCaptcha(_Captcha): :param width: The width of the CAPTCHA image. :param height: The height of the CAPTCHA image. :param fonts: Fonts to be used to generate CAPTCHA images. + :param font_sizes: Random choose a font size from this parameters. """ - def __init__(self, width=160, height=60, fonts=None): + def __init__(self, width=160, height=60, fonts=None, font_sizes=None): self._width = width self._height = height self._fonts = fonts or DEFAULT_FONTS + self._font_sizes = font_sizes or (46, 58, 68) self._truefonts = [] @property @@ -111,7 +113,7 @@ class ImageCaptcha(_Captcha): self._truefonts = tuple([ truetype(n, s) for n in self._fonts - for s in (46, 58, 68) + for s in self._font_sizes ]) return self._truefonts