mirror of
https://github.com/python-pillow/Pillow.git
synced 2024-12-26 01:46:18 +03:00
Working in py3k, not in 2.x
This commit is contained in:
parent
cb309c9f59
commit
4d32136365
BIN
Tests/images/high_ascii_chars.png
Normal file
BIN
Tests/images/high_ascii_chars.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.4 KiB |
|
@ -22,10 +22,22 @@ def test_sanity():
|
|||
|
||||
font.save(tempname)
|
||||
|
||||
def test_draw():
|
||||
def xtest_draw():
|
||||
|
||||
font = ImageFont.load(tempname)
|
||||
image = Image.new("L", font.getsize(message), "white")
|
||||
draw = ImageDraw.Draw(image)
|
||||
draw.text((0, 0), message, font=font)
|
||||
# assert_signature(image, "7216c60f988dea43a46bb68321e3c1b03ec62aee")
|
||||
|
||||
def test_high_characters():
|
||||
|
||||
message = "".join([chr(i+1) for i in range(140,232)])
|
||||
font = ImageFont.load(tempname)
|
||||
image = Image.new("L", font.getsize(message), "white")
|
||||
draw = ImageDraw.Draw(image)
|
||||
draw.text((0, 0), message, font=font)
|
||||
|
||||
compare = Image.open('Tests/images/high_ascii_chars.png')
|
||||
|
||||
assert_image_equal(image, compare)
|
||||
|
|
23
_imaging.c
23
_imaging.c
|
@ -2245,24 +2245,28 @@ _font_getmask(ImagingFontObject* self, PyObject* args)
|
|||
Imaging im;
|
||||
Imaging bitmap;
|
||||
int x, b;
|
||||
int i=0;
|
||||
int status;
|
||||
Glyph* glyph;
|
||||
|
||||
unsigned char* text;
|
||||
char* mode = "";
|
||||
if (!PyArg_ParseTuple(args, "s|s:getmask", &text, &mode))
|
||||
if (!PyArg_ParseTuple(args, "es|s:getmask", "latin1", &text, &mode)){
|
||||
return NULL;
|
||||
}
|
||||
|
||||
im = ImagingNew(self->bitmap->mode, textwidth(self, text), self->ysize);
|
||||
if (!im)
|
||||
if (!im) {
|
||||
PyMem_Free(text);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
b = 0;
|
||||
(void) ImagingFill(im, &b);
|
||||
|
||||
b = self->baseline;
|
||||
for (x = 0; *text; text++) {
|
||||
glyph = &self->glyphs[*text];
|
||||
for (x = 0; text[i]; i++) {
|
||||
glyph = &self->glyphs[text[i]];
|
||||
bitmap = ImagingCrop(
|
||||
self->bitmap,
|
||||
glyph->sx0, glyph->sy0, glyph->sx1, glyph->sy1
|
||||
|
@ -2279,10 +2283,11 @@ _font_getmask(ImagingFontObject* self, PyObject* args)
|
|||
x = x + glyph->dx;
|
||||
b = b + glyph->dy;
|
||||
}
|
||||
|
||||
PyMem_Free(text);
|
||||
return PyImagingNew(im);
|
||||
|
||||
failed:
|
||||
PyMem_Free(text);
|
||||
ImagingDelete(im);
|
||||
return NULL;
|
||||
}
|
||||
|
@ -2291,10 +2296,14 @@ static PyObject*
|
|||
_font_getsize(ImagingFontObject* self, PyObject* args)
|
||||
{
|
||||
unsigned char* text;
|
||||
if (!PyArg_ParseTuple(args, "s:getsize", &text))
|
||||
PyObject* retval;
|
||||
if (!PyArg_ParseTuple(args, "es:getsize", "latin-1", &text))
|
||||
return NULL;
|
||||
|
||||
return Py_BuildValue("ii", textwidth(self, text), self->ysize);
|
||||
retval = Py_BuildValue("ii", textwidth(self, text), self->ysize);
|
||||
PyMem_Free(text);
|
||||
return retval;
|
||||
|
||||
}
|
||||
|
||||
static struct PyMethodDef _font_methods[] = {
|
||||
|
|
Loading…
Reference in New Issue
Block a user