mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-07-30 09:59:50 +03:00
Fixed draw_text/draw_text.py on Ubuntu
This commit is contained in:
parent
acdda34589
commit
065f59f04d
|
@ -1,21 +1,20 @@
|
|||
#!/usr/bin/env python
|
||||
#-*- coding:utf-8 -*-
|
||||
import os
|
||||
import sys
|
||||
|
||||
from PIL import Image, ImageDraw, ImageFont
|
||||
from PIL import Image
|
||||
from PIL import ImageDraw
|
||||
from PIL import ImageFont
|
||||
|
||||
|
||||
PWD = os.path.dirname(os.path.realpath(__file__))
|
||||
parent_path = os.path.dirname(PWD)
|
||||
|
||||
BLACK = "#ffffff"
|
||||
WHITE = "#000000"
|
||||
BLACK = "#000000"
|
||||
WHITE = "#ffffff"
|
||||
|
||||
fg_color = WHITE
|
||||
bg_color = BLACK
|
||||
|
||||
|
||||
canvas_w, canvas_h = 180, 50
|
||||
canvas_w, canvas_h = 250, 50
|
||||
im = Image.new(mode="RGB", size=(canvas_w, canvas_h), color=WHITE)
|
||||
|
||||
draw = ImageDraw.Draw(im=im)
|
||||
|
@ -23,15 +22,19 @@ draw = ImageDraw.Draw(im=im)
|
|||
left_top_x, left_top_y = 10, 10
|
||||
begin = left_top_x, left_top_y
|
||||
|
||||
text = "hello world"
|
||||
text = u"hello world 中文"
|
||||
|
||||
if sys.platform == "darwin":
|
||||
filename = "/Library/Fonts/Microsoft/Times New Roman Bold.ttf"
|
||||
elif sys.platform == "win32":
|
||||
#filename = "C:/Windows/Fonts/timesbd.ttf"
|
||||
filename = "timesbd.ttf"
|
||||
elif sys.platform == "linux2":
|
||||
# this script required wqy truetype font,
|
||||
# install it on Debian/Ubuntu: apt-get install ttf-wqy-microhei
|
||||
filename = "/usr/share/fonts/truetype/wqy/wqy-microhei.ttc"
|
||||
else:
|
||||
raise Exception
|
||||
raise NotImplementedError
|
||||
|
||||
font_size = 26
|
||||
font = ImageFont.truetype(filename=filename, size=font_size)
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user