源码在下有需要的自便即可
import random import pygame from PIL import Image import os text = input('请输入要显示的文字:') font_size = 20 pygame.init() font = pygame.font.Font('MSYH.TTF', font_size) font_text = font.render(text, True, (0, 0, 0), (255, 255, 255)) print(font_text) height = font_text.get_height() width = font_text.get_width() print('height:', height, 'width:', width) # print(font_text.get_at((1, 1))[0]) image_row_list = [] for x in range(height): img_col_list = [] for y in range(width): if font_text.get_at((y, x))[0] != 255: img_col_list.append(1) else: img_col_list.append(0) image_row_list.append(img_col_list) width_len = len(image_row_list[0]) height_len = len(image_row_list) new_image = Image.new('RGB', (width_len*100, height_len*100), (248, 248, 255)) image_size = 100 print("正在绘图中。。。。。。。。") for row in range(he