SHARE
TWEET

Untitled

a guest Jun 16th, 2019 74 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. # encoding: utf-8
  2. import os
  3. import pygame
  4.  
  5. font_file = '/System/Library/Fonts/PingFang.ttc'
  6.  
  7. chinese_dir = 'chinese'
  8. if not os.path.exists(chinese_dir):
  9.     os.mkdir(chinese_dir)
  10.  
  11. pygame.init()
  12. start,end = (0x4E00, 0x9FA5)  # unicode range of Chinese Character
  13. for codepoint in range(int(start), int(end)):
  14.     word = chr(codepoint)
  15.     font = pygame.font.Font(font_file, 64)
  16.     rtext = font.render(word, True, (0, 0, 0), (255, 255, 255))
  17.     pygame.image.save(rtext, os.path.join(chinese_dir, word + ".png"))
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top