Skip to content

Instantly share code, notes, and snippets.

Created March 25, 2018 14:32
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
#! /usr/bin/env python
# coding: utf-8
# coding=utf-8
# -*- coding: utf-8 -*-
# vim: fileencoding=utf-8
import sys
from PIL import ImageFont
from PIL import Image
from PIL import ImageDraw
import io
import subprocess
buf = io.BytesIO()
fontFile = 'KouzanGyoushoOTF.otf'
font = ImageFont.truetype(fontFile, 64, encoding='utf-8')
text = '謹賀新年'
w, h = font.getsize(text)
img ='RGB', (w, h), (255,255,255))
draw = ImageDraw.Draw(img)
draw.text((0, 0), text, fill=(0,0,0), font=font), 'PNG')
# print out
p = subprocess.Popen('lpr', stdin=subprocess.PIPE)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment