Exemplo n.º 1
0
def sendToPrinter(message):

   print 'Printing message:', message

   printer = Adafruit_Thermal("/dev/ttyAMA0", 19200, timeout=5)
   printer.wake()

   font = FontRenderer('font/inconsolata.png','font/inconsolata.json') 

   # print messsage character by character
   for character in list(message):

      symbol = font.getCharacterImage(character)
      symbol = symbol.rotate(270,0,True)
      symbol = font.makeBgWhite(symbol)

      # offset rotated character
      #img = Image.new("RGB", (PRINTER_WIDTH_PIXELS, symbol.size[0]), (255, 255, 255))
      #img.paste(symbol, box=(( PRINTER_WIDTH_PIXELS - font.fontSize() ) / 2, 0))

      printer.printImage(symbol)

   #printer.println(message)

   # give out some paper
   printer.feed(3)

   printer.sleep()

   print 'done.'
Exemplo n.º 2
0
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Author: Lutz Reiter, Design Research Lab, Universität der Künste Berlin
# @Date:   2016-01-25 16:17:08
# @Last Modified by:   lutz
# @Last Modified time: 2016-01-25 19:04:52

from lib.FontRenderer import *
from PIL import Image


font = FontRenderer("font/inconsolata.png", "font/inconsolata.json", (200,200) );

img = font.getCharacterImage('P')
#img = img.rotate(90,0,True)
img = font.makeBgWhite(img)

bg = Image.new("RGB", (img.size[0], 500), (255, 255, 255))
bg.paste(img, box=(0, (500 - font.fontSize()) /2))

bg.show();