Skip to content

Instantly share code, notes, and snippets.

@RamonYeung
Created June 5, 2019 07:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save RamonYeung/26c38ab201dcff312edff58c559bade3 to your computer and use it in GitHub Desktop.
Save RamonYeung/26c38ab201dcff312edff58c559bade3 to your computer and use it in GitHub Desktop.
# encoding: utf-8
import os
import pygame
font_file = '/System/Library/Fonts/PingFang.ttc'
chinese_dir = 'chinese'
if not os.path.exists(chinese_dir):
os.mkdir(chinese_dir)
pygame.init()
start,end = (0x4E00, 0x9FA5) # unicode range of Chinese Character
for codepoint in range(int(start), int(end)):
word = chr(codepoint)
font = pygame.font.Font(font_file, 64)
rtext = font.render(word, True, (0, 0, 0), (255, 255, 255))
pygame.image.save(rtext, os.path.join(chinese_dir, word + ".png"))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment