Created
June 5, 2019 07:40
-
-
Save RamonYeung/26c38ab201dcff312edff58c559bade3 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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