forked from MasayukiFukada/CodeMFont
-
Notifications
You must be signed in to change notification settings - Fork 0
/
generate_CodeM.pe
executable file
·279 lines (266 loc) · 8.97 KB
/
generate_CodeM.pe
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
#!/usr/local/bin/fontforge
# vim:ts=2:sw=2:tw=0
width=1200
Print('--------------------------------------------------')
# --------------------------------------------------
# Source Code Pro
# 750 x 250 = 1000(Em)
# Win(Ascent, Descent)=(-16, -127)
# hhea(height, width)=(-16, 127)
# --------------------------------------------------
# SourceCodePro Regular 書体の変更
Print('Source Code Pro Regular の編集')
Open('SourceCodePro-Regular.ttf')
# 0x20(半角スペース)〜0x007e(チルダ)以外を削除
Select(0x3000,0x9fff)
Clear()
# ----------
SelectNone()
SelectAll()
ClearInstrs()
#ClearHints()
UnlinkReference()
ScaleToEm(750,250)
CenterInWidth()
Generate('tmp_scp_reg.ttf')
Close()
# --------------------------------------------------
# SourceCodePro Bold 書体の変更
Print('Source Code Pro Bold の編集')
Open('SourceCodePro-Bold.ttf')
# 0x20(半角スペース)〜0x007e(チルダ)以外を削除
Select(0x3000,0x9fff)
Clear()
# ----------
SelectNone()
SelectAll()
ClearInstrs()
#ClearHints()
UnlinkReference()
ScaleToEm(750,250)
CenterInWidth()
Generate('tmp_scp_bold.ttf')
Close()
# --------------------------------------------------
# Migu 1M
# 750 x 140 = 1000(Em)
# Win(Ascent, Descent)=(-195, -90)
# hhea(height, width)=(-195, 90)
# --------------------------------------------------
# Migu-1m Regular 書体の変更
Print('Migu 1M Regular の編集')
Open('migu-1m-regular.ttf')
# 0x20(半角スペース)〜0x007e(チルダ)を削除
Select(0x0000,0x2fff)
Clear()
Select(0xa000,0xffff)
Clear()
# ----------
SelectNone()
SelectAll()
ClearInstrs()
#ClearHints()
UnlinkReference()
ScaleToEm(750,250)
Select(0x3000,0x9fff)
SetWidth(width)
CenterInWidth()
Generate('tmp_mig_1m_r.ttf')
Close()
# --------------------------------------------------
# Migu-1m Bold 書体の変更
Print('Migu 1M Bold の編集')
Open('migu-1m-bold.ttf')
# 0x20(半角スペース)〜0x007e(チルダ)を削除
Select(0x0000,0x2fff)
Clear()
Select(0xa000,0xffff)
Clear()
# ----------
SelectNone()
SelectAll()
ClearInstrs()
#ClearHints()
UnlinkReference()
ScaleToEm(750,250)
Select(0x3000,0x9fff)
SetWidth(width)
CenterInWidth()
Generate('tmp_mig_1m_b.ttf')
Close()
# --------------------------------------------------
# CodeM
# 750 x 250 = 1110(Em)
# Win(Ascent, Descent)=(-195, -90)
# hhea(height, width)=(-195, 90)
# --------------------------------------------------
# CodeM Regular の生成
Open('tmp_mig_1m_r.ttf')
MergeFonts('tmp_scp_reg.ttf')
copyright = 'CodeM Generator Author: Masayuki Fukada\n' \
+ 'Copyright (c) 2013 '
version = '1.0.0'
# Regular
Print('CodeM-Regular の生成')
SetFontNames('CodeM-Regular', 'CodeM', 'CodeM Regular', 'Regular', copyright, version)
SetTTFName(0x411, 1, 'CodeM')
SetUniqueID(0)
SetOS2Value('VendorID', 'MfFt')
SetOS2Value('TypoLineGap', 0)
# ------------------------------
# フォント改造
Select(0u0021); # !
ExpandStroke(20,0,0,0,1);
Select(0u002c); # ,
ExpandStroke(20,0,0,0,1);
Select(0u002d); Move(0,-80); # -
Select(0u002e); # .
ExpandStroke(20,0,0,0,1);
Select(0u003a); # :
ExpandStroke(20,0,0,0,1);
Select(0u003b); # ;
ExpandStroke(20,0,0,0,1);
Select(0u003c); Move(0,-80); # <
Select(0u003d); Move(0,-80); # =
Select(0u003e); Move(0,-80); # >
Select(0u0040); Move(0, 80); # @
Select(0u005b); Move(0, 40); # [
Select(0u005d); Move(0, 40); # ]
Select(0u005e); Move(0,180); # ^
Select(0u005f); Move(0,-60); # _
ExpandStroke(40,0,0,0,1);
Select(0u007b); Move(0, 40); # {
Select(0u007c); Move(0, 70); # |
Select(0u002d); Copy(); Select(0u009c); Paste();
Rotate(90); Move(0,340); Copy(); Select(0u007c); Paste();
Select(0u002d); Copy(); Select(0u009c); Paste();
Rotate(90); Move(0,-140); Copy(); Select(0u007c); PasteInto();
Select(0u007d); Move(0, 40); # }
Select(0u007e); Move(0,260); # ~
#句読点の位置調整
Select(0u3001); Move(-140,0); # 、(読点)
SetWidth(140,1);
Select(0u3002); Move(-140,0); # 。(句点)
SetWidth(140,1);
#全角空白
Select(0u2610); Copy(); Select(0u3000); Paste()
Select(0u271a); Copy(); Select(0u3000); PasteInto()
OverlapIntersect()
# ------------------------------
defAscent = GetOS2Value('WinAscent')
defDescent = GetOS2Value('WinDescent')
addAscent = defAscent + 64
addDescent = defDescent + 16
SetOS2Value('WinAscent', addAscent)
SetOS2Value('WinDescent', addDescent)
SetOS2Value('HHeadAscent', addAscent)
SetOS2Value('HHeadDescent', -addDescent)
Generate('CodeM-Regular.ttf')
# Wide
Print('CodeM-Regular-Wide の生成')
SetFontNames('CodeMWide-Regular', 'CodeM Wide', 'CodeM Wide Regular', 'Wide', copyright, version)
SetTTFName(0x411, 1, 'CodeM Wide')
addAscent = defAscent + 128
addDescent = defDescent + 32
SetOS2Value('WinAscent', addAscent)
SetOS2Value('WinDescent', addDescent)
SetOS2Value('HHeadAscent', addAscent)
SetOS2Value('HHeadDescent', -addDescent)
Generate('CodeM-Regular-Wide.ttf')
# Expanded
Print('CodeM-Regular-Expanded の生成')
SetFontNames('CodeMExpanded-Regular', 'CodeM Expanded', 'CodeM Expanded Regular', 'Expanded', copyright, version)
SetTTFName(0x411, 1, 'CodeM Expanded')
addAscent = defAscent + 192
addDescent = defDescent + 48
SetOS2Value('WinAscent', addAscent)
SetOS2Value('WinDescent', addDescent)
SetOS2Value('HHeadAscent', addAscent)
SetOS2Value('HHeadDescent', -addDescent)
Generate('CodeM-Regular-Expanded.ttf')
Close()
# CodeM Bold の生成
Open('tmp_mig_1m_b.ttf')
MergeFonts('tmp_scp_bold.ttf')
copyright = 'CodeM Generator Author: Masayuki Fukada\n' \
+ 'Copyright (c) 2013 '
version = '1.0.0'
# Bold
Print('CodeM-Bold の生成')
SetFontNames('CodeM-Bold', 'CodeM', 'CodeM Bold', 'Bold', copyright, version)
SetTTFName(0x411, 1, 'CodeM')
SetUniqueID(0)
SetOS2Value('VendorID', 'MfFt')
SetOS2Value('TypoLineGap', 0)
# ------------------------------
# フォント改造
Select(0u0021); # !
ExpandStroke(20,0,0,0,1);
Select(0u002c); # ,
ExpandStroke(20,0,0,0,1);
Select(0u002d); Move(0,-80); # -
Select(0u002e); # .
ExpandStroke(20,0,0,0,1);
Select(0u003a); # :
ExpandStroke(20,0,0,0,1);
Select(0u003b); # ;
ExpandStroke(20,0,0,0,1);
Select(0u003c); Move(0,-80); # <
Select(0u003d); Move(0,-80); # =
Select(0u003e); Move(0,-80); # >
Select(0u0040); Move(0, 80); # @
Select(0u005b); Move(0, 40); # [
Select(0u005d); Move(0, 40); # ]
Select(0u005e); Move(0,180); # ^
Select(0u005f); Move(0,-60); # _
ExpandStroke(40,0,0,0,1);
Select(0u007b); Move(0, 40); # {
Select(0u007c); Move(0, 70); # |
Select(0u002d); Copy(); Select(0u009c); Paste();
Rotate(90); Move(0,340); Copy(); Select(0u007c); Paste();
Select(0u002d); Copy(); Select(0u009c); Paste();
Rotate(90); Move(0,-140); Copy(); Select(0u007c); PasteInto();
Select(0u007d); Move(0, 40); # }
Select(0u007e); Move(0,260); # ~
#句読点の位置調整
Select(0u3001); Move(-140,0); # 、(読点)
SetWidth(140,1);
Select(0u3002); Move(-140,0); # 。(句点)
SetWidth(140,1);
#全角空白
Select(0u2610); Copy(); Select(0u3000); Paste()
Select(0u271a); Copy(); Select(0u3000); PasteInto()
OverlapIntersect()
# ------------------------------
defAscent = GetOS2Value('WinAscent')
defDescent = GetOS2Value('WinDescent')
addAscent = defAscent + 64
addDescent = defDescent + 16
SetOS2Value('WinAscent', addAscent)
SetOS2Value('WinDescent', addDescent)
SetOS2Value('HHeadAscent', addAscent)
SetOS2Value('HHeadDescent', -addDescent)
Generate('CodeM-Bold.ttf')
# Wide
Print('CodeM-Bold-Wide の生成')
SetFontNames('CodeMWide-Bold', 'CodeM Wide', 'CodeM Wide Bold', 'Wide', copyright, version)
SetTTFName(0x411, 1, 'CodeM Wide')
addAscent = defAscent + 128
addDescent = defDescent + 32
SetOS2Value('WinAscent', addAscent)
SetOS2Value('WinDescent', addDescent)
SetOS2Value('HHeadAscent', addAscent)
SetOS2Value('HHeadDescent', -addDescent)
Generate('CodeM-Bold-Wide.ttf')
# Expanded
Print('CodeM-Bold-Expanded の生成')
SetFontNames('CodeMExpanded-Bold', 'CodeM Expanded', 'CodeM Expanded Bold', 'Expanded', copyright, version)
SetTTFName(0x411, 1, 'CodeM Expanded')
addAscent = defAscent + 192
addDescent = defDescent + 48
SetOS2Value('WinAscent', addAscent)
SetOS2Value('WinDescent', addDescent)
SetOS2Value('HHeadAscent', addAscent)
SetOS2Value('HHeadDescent', -addDescent)
Generate('CodeM-Bold-Expanded.ttf')
Close()