python text to png to svg使用的是GitHub上开源的代码:GitHub我还在进行修改先将基础功能放出来text to pngfrom PIL import Image from PIL import ImageDraw from PIL import ImageFont import img_converter class TextToPng: def __init__(self, fontname, fontsize, text_color, background_color, image_border_size=4, text_border_size=3): self.fontname = fontname self.fontsize = fontsize self.text_color = text_color self.background_color = background_color self.image_border_size = image_borde
python 实现text to img# coding=utf-8 from PIL import Image, ImageDraw, ImageFont LINE_CHAR_COUNT = 50*2 # 每行字符数:30个中文字符(=60英文字符) CHAR_SIZE = 30 TABLE_WIDTH = 4 def line_break(line): ret = '' width = 0 for c in line: # print("c.encode('utf8')",c.encode('utf8'),"c",c) if len(c.encode('utf8')) == 3: # 中文 if LINE_CHAR_COUNT == width + 1: # 剩余位置不够一个汉字 width = 2 ret +=
一只胖橘