Skip to content

New (since 10.1.0) font display is worse than "better than nothing font" for small sizes #8084

@dhylands

Description

@dhylands

I'm using a small (128x32) OLED display, which is setup as 4 lines of text on a Raspberry Pi 5 running Ubuntu Server 24.04 LTS.

What did you do?

Upgraded my version of pillow (to any version from 10.1.0 or later)

What did you expect to happen?

My display to be readable.

What actually happened?

Some text is unreadable. In particular, the 6's look almost the same as 8's

What are your OS, Python and Pillow versions?

  • OS: Ubuntu 22.04 and 24.04
  • Python: 3.9.19, 3.10.12, 3.12.3
  • Pillow: 10.3.0
Pillow 10.3.0
Python 3.12.3 (main, Apr 10 2024, 05:33:47) [GCC 13.2.0]
--------------------------------------------------------------------
Python executable is /home/dhylands/adafruit-oled-ssd1306/.direnv/python-3.12.3/bin/python3
Environment Python files loaded from /home/dhylands/adafruit-oled-ssd1306/.direnv/python-3.12.3
System Python files loaded from /usr
--------------------------------------------------------------------
Python Pillow modules loaded from /home/dhylands/adafruit-oled-ssd1306/.direnv/python-3.12.3/lib/python3.12/site-packages/PIL
Binary Pillow modules loaded from /home/dhylands/adafruit-oled-ssd1306/.direnv/python-3.12.3/lib/python3.12/site-packages/PIL
--------------------------------------------------------------------
--- PIL CORE support ok, compiled for 10.3.0
*** TKINTER support not installed
--- FREETYPE2 support ok, loaded 2.13.2
--- LITTLECMS2 support ok, loaded 2.16
--- WEBP support ok, loaded 1.3.2
--- WEBP Transparency support ok
--- WEBPMUX support ok
--- WEBP Animation support ok
--- JPEG support ok, compiled for libjpeg-turbo 3.0.2
--- OPENJPEG (JPEG2000) support ok, loaded 2.5.2
--- ZLIB (PNG/ZIP) support ok, loaded 1.3
--- LIBTIFF support ok, loaded 4.6.0
--- RAQM (Bidirectional Text) support ok, loaded 0.10.1, fribidi 1.0.13, harfbuzz 8.4.0
*** LIBIMAGEQUANT (Quantization method) support not installed
--- XCB (X protocol) support ok
--------------------------------------------------------------------
from PIL import Image, ImageFont, ImageDraw

font = ImageFont.load_default(size=10)

line1 = "IP: 192.168.1.4"
line2 = "CPU load: 0.15"
line3 = "Mem: 341/7942 MB  4.29%"
line4 = "Disk: 2/58 GB  5%"

top = -2

image = Image.new("1", (128, 32))
draw = ImageDraw.Draw(image)
draw.rectangle((0, 0, 128, 32), outline=0, fill=0)
draw.text((0, top + 0), line1, font=font, fill=255)
draw.text((0, top + 8), line2, font=font, fill=255)
draw.text((0, top + 16), line3, font=font, fill=255)
draw.text((0, top + 25), line4, font=font, fill=255)

image.save("display.png")

Image from version 10.0.1 using ImageFont.load_default()
display-better-than-nothing

Image from version 10.3.0 using ImageFont.load_default() (same results seen using 10.1.0 or later)
display-default

Image from 10.3.0 using ImageFont.load_default(size=8)
display-8

Image from 10.3.0 using ImageFont.load_default(size=9)
display-9

Image from 10.3.0 using ImageFont.load_default(size=10)
display-10

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions