Skip to content

Commit 060249a

Browse files
committed
new script Get all TTFs' Chinese Font Name in current folder.
1 parent 89bbc58 commit 060249a

File tree

2 files changed

+39
-6
lines changed

2 files changed

+39
-6
lines changed

README.md

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,10 @@ Python Script for Font Manipulation using FontForge Module
66

77
**Please install python-fontforge module first as well as PyQt5**
88

9-
# [minimizeFont.py](../../blob/master/minimizeFont.py)
109

11-
Python script that minimize ttf font by input word list
10+
# [checkMissingGlyph.py](../../blob/master/checkMissingGlyph.py)
1211

13-
Use [minifyGlyphs](../../blob/master/minifyGlyphs) as input word list
12+
Check Missing Glyph in word list [missingGlyphs](../../blob/master/missingGlyphs)
1413

1514
Word list format
1615
```
@@ -33,14 +32,25 @@ A B
3332
C D
3433
```
3534

36-
# [checkMissingGlyph.py](../../blob/master/checkMissingGlyph.py)
35+
# [getChineseFontName.py](../../blob/master/getChineseFontName.py)
3736

38-
Check Missing Glyph in word list [missingGlyphs](../../blob/master/missingGlyphs)
37+
Get all TTFs' Chinese Font Name in current folder.
38+
39+
Print out sample.
40+
```
41+
?.ttf as {chinese_name}_{english_name}
42+
```
43+
44+
# [minimizeFont.py](../../blob/master/minimizeFont.py)
45+
46+
Python script that minimize ttf font by input word list
47+
48+
Use [minifyGlyphs](../../blob/master/minifyGlyphs) as input word list
3949

4050
Word list format
4151
```
4252
## start with "##" line will be ignore to read
4353
A
4454
B
4555
C
46-
```
56+
```

getChineseFontName.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#!/usr/bin/env python
2+
# -*- coding: utf-8 -*-
3+
import fontforge
4+
import glob
5+
6+
fonts = glob.glob("*.ttf")
7+
8+
for f in fonts:
9+
ttfFile = fontforge.open(f, 5)
10+
chinesename = ""
11+
for item in ttfFile.sfnt_names:
12+
(a, b, c) = item
13+
if a == 'Chinese (PRC)' and b == 'Fullname':
14+
chinesename = c
15+
if a == 'Chinese (Taiwan)' and b == 'Fullname':
16+
chinesename = c
17+
if a == 'Chinese (Hong Kong)' and b == 'Fullname':
18+
chinesename = c
19+
20+
# print("cp shortname/" + f + " " + c+'_' +
21+
# (ttfFile.fullname).replace(' ', '') + ".ttf")
22+
print(f.replace(' ', '\\ ') + " as " + chinesename +
23+
"_" + ttfFile.fullname.replace(' ', '_'))

0 commit comments

Comments
 (0)