luma.core.legacy

These methods were originally present in the old MAX7219 driver, and are preserved here only to aid migration away from that library. The functions are denoted ‘legacy’ to discourage use - you are encouraged to use the various drawing capabilities in the Pillow library instead.

luma.core.legacy.show_message(device, msg, y_offset=0, fill=None, font=None, scroll_delay=0.03)[source]

Scrolls a message right-to-left across the devices display.

Parameters:
  • device – The device to scroll across.
  • msg (str) – The text message to display (must be ASCII only).
  • y_offset (int) – The row to use to display the text.
  • fill – The fill color to use (standard Pillow color name or RGB tuple).
  • font – The font (from luma.core.legacy.font) to use.
  • scroll_delay (float) – The number of seconds to delay between scrolling.
luma.core.legacy.text(draw, xy, txt, fill=None, font=None)[source]

Draw a legacy font starting at x, y using the prescribed fill and font.

Parameters:
  • draw (PIL.ImageDraw) – A valid canvas to draw the text onto.
  • txt (str) – The text string to display (must be ASCII only).
  • xy (tuple) – An (x, y) tuple denoting the top-left corner to draw the text.
  • fill – The fill color to use (standard Pillow color name or RGB tuple).
  • font – The font (from luma.core.legacy.font) to use.
luma.core.legacy.textsize(txt, font=None)[source]

Calculates the bounding box of the text, as drawn in the specified font. This method is most useful for when the proportional wrapper is used.

Parameters:

luma.core.legacy.font

Fixed-width font definitions. The following fonts are available:

Font name Notes Source
CP437_FONT See https://en.wikipedia.org/wiki/Code_page_437 for further details. unascribed
LCD_FONT Only contains characters 0x20-0x7F inclusive and Cyrillic chars 0x80-0xBF (except ‘Ёё’); all others will appear as blanks. http://www.avrfreaks.net/forum/code-57-512-and-712-fonts?name=PNphpBB2&file=viewtopic&t=69880
SEG7_FONT Only contains characters 0x41-0x5A & 0x30-0x39 inclusive; all others will appear as blanks. https://www.dafont.com/digital-7.font
SINCLAIR_FONT Based on the character set from the Sinclair ZX Spectrum. Only contains characters 0x20-0x7E inclusive; all others will appear as blanks. http://www.henningkarlsen.com/electronics/r_fonts.php
TINY_FONT Only contains characters 0x20-0x7E inclusive; all others will appear as blanks. http://www.dafont.com/tiny.font
UKR_FONT Cyrillic Ukrainian font unascribed
class luma.core.legacy.font.proportional(font)[source]

Bases: object

Wraps an existing font array, and on on indexing, trims any leading or trailing zero column definitions. This works especially well with scrolling messages, as interspace columns are squeezed to a single pixel.

class luma.core.legacy.font.tolerant(font, missing='_')[source]

Bases: object

Wraps an existing font array, and on indexing, if the supplied ascii_code does not exist, will return the column definitions for the given missing parameter.

New in version 0.9.4.