Unexpected results from .pcf font for chars >128 #505

wiredfool opened this Issue Jan 28, 2014 · 1 comment


None yet

1 participant


This is likely a unicode issue somewhere.

In Py2.x, results are as expected. In Py3.x, the high ascii characters are not printed as expected.

excerpted and modified from test_font_pcf.py

fontname = "Tests/fonts/7x13-ISO8859-5.pcf"
tempname = tempfile("temp.pil", "temp.pbm")

def test_draw():

    message = str("".join([chr(i+1) for i in range(223)]))

    font = ImageFont.load(tempname)
    image = Image.new("L", font.getsize(message), "white")
    draw = ImageDraw.Draw(image)
    draw.text((0, 0), message, font=font)


The generated temp fonts are the same, It appears to be an issue in the rendering.

This was reported in IRC by AleXoundOS, hoisted here to document.


The essential problem here is that a unicode string (in python 3) is interpreted as a string that is a series of bytes (in the c-api). I believe that the solution, especially for the old, 256 character non-unicode aware fonts, is to convert the incoming string into a latin-1 encoded bytes object, which should be easily used as a uchar *.

@aclark4life aclark4life closed this in #517 Mar 17, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment