Skip to content

Commit 6c0f5ed

Browse files
committed
mix bug
1 parent 424fd03 commit 6c0f5ed

File tree

1 file changed

+17
-6
lines changed

1 file changed

+17
-6
lines changed

chinesebert中的pinyin和glyph的处理/image_test.py

+17-6
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,25 @@
66
"""
77
import os
88
import pygame
9+
910
chinese_dir = 'chinese'
1011
if not os.path.exists(chinese_dir):
1112
os.mkdir(chinese_dir)
1213

1314
pygame.init()
14-
start, end = (0x4E00, 0x9FA5)#汉字编码范围
15-
for codepoint in range(int(start), int(end)):
16-
word = chr(codepoint)
17-
font = pygame.font.Font("MSYH.TTC", 22)#当前目录下要有微软雅黑的字体文件msyh.ttc,或者去c:\Windows\Fonts目录下找
18-
rtext = font.render(word, True, (0, 0, 0), (255, 255, 255))
19-
pygame.image.save(rtext, os.path.join(chinese_dir,word+".png"))
15+
16+
# 1. 写出所有的汉字
17+
# start, end = (0x4E00, 0x9FA5) # 汉字编码范围
18+
#
19+
# for codepoint in range(int(start), int(end)):
20+
# word = chr(codepoint)
21+
# font = pygame.font.Font("MSYH.TTC", 22) # 当前目录下要有微软雅黑的字体文件msyh.ttc,或者去c:\Windows\Fonts目录下找
22+
# rtext = font.render(word, True, (0, 0, 0), (255, 255, 255))
23+
# pygame.image.save(rtext, os.path.join(chinese_dir, word + ".png"))
24+
25+
# 2. 指定汉字 对于不同的字体 可以切换MSYH.TTC文件就行
26+
word = '新'
27+
font = pygame.font.Font("MSYH.TTC", 22) # 当前目录下要有微软雅黑的字体文件msyh.ttc,或者去c:\Windows\Fonts目录下找
28+
rtext = font.render(word, True, (0, 0, 0), (255, 255, 255))
29+
pygame.image.save(rtext, os.path.join(chinese_dir, word + ".png"))
30+

0 commit comments

Comments
 (0)