Commit Graph

28 Commits

Author SHA1 Message Date
hugovk
78003ca473 Update paths to Tests/images/ instead of Images/ 2014-06-23 09:19:29 +03:00
hugovk
92507e5d0a Fix issue #382: TypeError with TransposedFont's getsize()
When getting the size of text with a TransposedFont it was failing:

  File "/usr/local/lib/python2.7/site-packages/PIL/ImageDraw.py", line 281, in textsize
    return font.getsize(text)
  File "/usr/local/lib/python2.7/site-packages/PIL/ImageFont.py", line 189, in getsize
    w, h = self.font.getsize(text)[0]
TypeError: 'int' object is not iterable

This is because self.font.getsize(text) returns a (w, h) tuple. To fix, remove the [0].

Test cases have been created in test_imagefont.py: 
test_rotated_transposed_font()
test_unrotated_transposed_font()

Both fail before the fix, both pass with the fix. Furthermore, the code I'm using this from ( https://github.com/mattdeboard/word_cloud ) now works as expected and creates a word cloud similar to the ones that PIL created.
2013-10-17 19:00:42 +03:00
Stephen Johnson
bc0f53aceb Fully document PIL.ImageFont 2013-10-12 17:14:12 -07:00
paddywwoof
02855a86c0 hopefully this uses a reasonable y offset 2013-09-20 14:02:40 +01:00
Martijn Pieters
97f1cd55ee Fix for #304: test for str, not "utf-8".
The code wants to produce a `str` object for the given Python version (which is the right thing to do here).
2013-07-25 18:21:08 +01:00
lmollea
763be8614d Fixed windows fallback (wasn't using correct file in windows/fonts) 2013-07-22 14:44:40 +02:00
Alex Clark
fd29e707e9 Apply @Arfrever patch, fixes #258 2013-06-30 07:04:42 -04:00
wiredfool
310341cec7 merge from master 2013-05-13 09:17:52 -07:00
wiredfool
39c62f76ab Buffer lifetime needs to be the same as the font lifetime 2013-04-25 21:17:58 -07:00
Nicolas Pieuchot
028e63865e Changing bytes variable name not to squeeze bytes type 2013-04-25 23:03:37 +02:00
Nicolas Pieuchot
4d136d94ce Better unity with Image.py file (on string type testing and warnings) 2013-04-25 22:32:43 +02:00
Nicolas Pieuchot
282562ec19 Adding Python3 basestring compatibility without changing basestring 2013-04-25 22:03:37 +02:00
Nicolas Pieuchot
f1c245c9c5 Deprecation message correction 2013-04-25 21:10:42 +02:00
Nicolas Pieuchot
af72132349 Correction of the unbufferizing 2013-04-25 20:57:13 +02:00
Nicolas Pieuchot
450a068ccb Removing buffer from imagefont 2013-04-25 18:48:43 +02:00
Nicolas Pieuchot
ed9945c71f Allowing to pass font as file-like objects 2013-04-22 11:48:06 +02:00
wiredfool
c774f9ab4c merged pull request #88 to master, resolved conflicts 2013-04-08 20:31:28 -07:00
Christoph Gohlke
4985d96d03 Better import of _imagingft 2013-03-13 17:56:33 -07:00
Alex Clark
4546d26413 Revert "Better import for _imagingft"
This reverts commit 089a04bce1.
2013-03-08 18:41:19 -05:00
Alex Clark
fd81ee9336 Fix imports 2013-03-08 17:39:50 -05:00
Christoph Gohlke
089a04bce1 Better import for _imagingft 2013-03-08 13:36:32 -08:00
Alex Clark
3020c16eaa Fix imports 2013-03-07 11:20:28 -05:00
Brian Crowell
a7e3b2e47b py3k: The big push
There are two main issues fixed with this commit:

* bytes vs. str: All file, image, and palette data are now handled as
  bytes. A new _binary module consolidates the hacks needed to do this
  across Python versions. tostring/fromstring methods have been renamed to
  tobytes/frombytes, but the Python 2.6/2.7 versions alias them to the old
  names for compatibility. Users should move to tobytes/frombytes.

  One other potentially-breaking change is that text data in image files
  (such as tags, comments) are now explicitly handled with a specific
  character encoding in mind. This works well with the Unicode str in
  Python 3, but may trip up old code expecting a straight byte-for-byte
  translation to a Python string. This also required a change to Gohlke's
  tags tests (in Tests/test_file_png.py) to expect Unicode strings from
  the code.

* True div vs. floor div: Many division operations used the "/" operator
  to do floor division, which is now the "//" operator in Python 3. These
  were fixed.

As of this commit, on the first pass, I have one failing test (improper
handling of a slice object in a C module, test_imagepath.py) in Python 3,
and three that that I haven't tried running yet (test_imagegl,
test_imagegrab, and test_imageqt). I also haven't tested anything on
Windows. All but the three skipped tests run flawlessly against Pythons
2.6 and 2.7.
2013-01-10 08:46:56 -06:00
Brian Crowell
260c1fad14 py3k: Convert StringIO.StringIO to io.BytesIO
io.BytesIO is already in 2.6. Some of the more obvious bytes literals are
marked in this commit.
2013-01-10 08:46:51 -06:00
Brian Crowell
83ff0b3b31 py3k: Use relative imports
In py3k, imports are absolute unless using the "from . import" syntax.

This commit also solves a recursive import between Image, ImageColor, and
ImagePalette by delay-importing ImagePalette in Image.

I'm not too keen on this commit because the syntax is ugly. I might go back
and prefer the prettier "from PIL import".
2013-01-10 08:46:48 -06:00
Brian Crowell
5076c35cc5 py3k: print is a function
Seriously, if you didn't know that, you've been in a freaking cave, man.
2013-01-10 08:46:46 -06:00
Brian Crowell
37f22ebfcd py3k: Use string methods instead of string module
First, we go for the obvious stuff. The string module methods are gone in
3.0, so we translate them to the appropriate methods on the string class.
2013-01-10 08:42:49 -06:00
Alex Clark
9a640e3157 Forking PIL 2010-07-30 22:52:47 -04:00