I’m trying to convert an NFO file with some crazy high ASCII arts using a Python script and PIL. Everything is nice when the NFO contains just simple characters, but with the “full rectangles” arts all i get is a lot of “ùùùù”.
nfoFont = ImageFont.truetype('cour.ttf', size=12, encoding='unic')
#[...other code...]
nfoImage = Image.new("RGB", nfoSize, 'black')
draw = ImageDraw.Draw(nfoImage)
currentLineHeight = 0;
for line in nfoText:
draw.text((0, currentLineHeight), line, font=nfoFont, fill='gray')
currentLineHeight += nfoFontHeight
I think i’m probably using the wrong font, and the wrong encoding. I know this kind of NFOs were created with CP437 encoding, but i can’t see a way to obtain this.
Any help is appreciated!!
How do you get the contents of the nfoText variable? Is it a unicode or byte string?
Without knowing how PIL handles encodings, I’m assuming it works correctly with Unicode strings, then just read the nfo file with:
I can’t check right now if Python supports the cp437 encoding, and I don’t have an nfo file available (I’ve only seen them used in pirated software, but or course I assume that you have a legitimate reason to handle them). Hope this helps anyway.