forked from yuru7/HackGen
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhackgen_generator.sh
executable file
·1619 lines (1359 loc) · 51 KB
/
hackgen_generator.sh
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
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#!/bin/sh
base_dir=$(cd $(dirname $0); pwd)
# HackGen Generator
hackgen_version="1.4.1"
# Set familyname
familyname_preffix="$1"
hackgen_familyname=${familyname_preffix}"HackGen"
hackgen_familyname_suffix=""
hackgen35_familyname=${hackgen_familyname}"35"
hackgen35_familyname_suffix=""
hackgen_console_suffix="Console"
hackgen_box_drawing_lights_suffix="BoxDrawingLights"
# Set ascent and descent (line width parameters)
hackgen_ascent=901
hackgen_descent=243
hackgen35_ascent=951
hackgen35_descent=243
em_ascent=881
em_descent=143
em=$(($em_ascent + $em_descent))
typo_line_gap=80
hack_width=616
genjyuu_width=1024
hackgen_half_width=540
hackgen_full_width=$((${hackgen_half_width} * 2))
hack_shrink_x=88
hack_shrink_y=93
hackgen35_half_width=618
hackgen35_full_width=$((${hackgen35_half_width} * 5 / 3))
# Set path to fontforge command
fontforge_command="fontforge"
ttfautohint_command="ttfautohint"
powerline_patch_path="${base_dir}/fontpatcher-develop/scripts/powerline-fontpatcher"
# Set redirection of stderr
redirection_stderr="/dev/null"
# Set fonts directories used in auto flag
fonts_directories="${base_dir}/source/"
# Set zenkaku space glyph
zenkaku_space_glyph=""
# Set flags
leaving_tmp_flag="false"
fullwidth_ambiguous_flag="true"
scaling_down_flag="true"
# Set non-Discorded characters
non_discorded_characters=""
# Set filenames
modified_hack_material_generator="modified_hack_material_generator.pe"
modified_hack_material_regular="Modified-Hack-Material-Regular.sfd"
modified_hack_material_bold="Modified-Hack-Material-Bold.sfd"
modified_hack_box_drawing_lights_generator="modified_hack_box_drawing_lights_generator.pe"
modified_hack_box_drawing_lights_regular="Modified-Hack-Box-Drawing-Lights-Regular.sfd"
modified_hack_box_drawing_lights_bold="Modified-Hack-Box-Drawing-Lights-Bold.sfd"
modified_hack_console_generator="modified_hack_console_generator.pe"
modified_hack_console_regular="Modified-Hack-Console-Regular.sfd"
modified_hack_console_bold="Modified-Hack-Console-Bold.sfd"
modified_hack35_console_generator="modified_hack35_console_generator.pe"
modified_hack35_console_regular="Modified-Hack35-Console-Regular.sfd"
modified_hack35_console_bold="Modified-Hack35-Console-Bold.sfd"
modified_hack_generator="modified_hack_generator.pe"
modified_hack_regular="Modified-Hack-Regular.sfd"
modified_hack_bold="Modified-Hack-Bold.sfd"
modified_hack35_generator="modified_hack35_generator.pe"
modified_hack35_regular="Modified-Hack35-Regular.sfd"
modified_hack35_bold="Modified-Hack35-Bold.sfd"
modified_genjyuu_generator="modified_genjyuu_generator.pe"
modified_genjyuu_regular="Modified-GenJyuuGothicL-Monospace-regular.sfd"
modified_genjyuu_bold="Modified-GenJyuuGothicL-Monospace-bold.sfd"
modified_genjyuu35_generator="modified_genjyuu35_generator.pe"
modified_genjyuu35_regular="Modified-GenJyuuGothicL35-Monospace-regular.sfd"
modified_genjyuu35_bold="Modified-GenJyuuGothicL35-Monospace-bold.sfd"
modified_genjyuu_console_generator="modified_genjyuu_console_generator.pe"
modified_genjyuu_console_regular="Modified-GenJyuuGothicL-Monospace-regular_console.sfd"
modified_genjyuu_console_bold="Modified-GenJyuuGothicL-Monospace-bold_console.sfd"
modified_genjyuu35_console_generator="modified_genjyuu35_console_generator.pe"
modified_genjyuu35_console_regular="Modified-GenJyuuGothicL35-Monospace-regular_console.sfd"
modified_genjyuu35_console_bold="Modified-GenJyuuGothicL35-Monospace-bold_console.sfd"
hackgen_generator="hackgen_generator.pe"
hackgen_console_generator="hackgen_console_generator.pe"
hackgen_box_drawing_lights_generator="hackgen_box_drawing_lights_generator.pe"
hackgen35_generator="hackgen35_generator.pe"
hackgen35_console_generator="hackgen35_console_generator.pe"
# hackgen_discord_generator="hackgen_discord_generator.pe"
regular2oblique_converter="regular2oblique_converter.sh"
# Get input fonts
tmp=""
for i in $fonts_directories
do
[ -d "${i}" ] && tmp="${tmp} ${i}"
done
fonts_directories="${tmp}"
# Search Hack
input_hack_regular=`find $fonts_directories -follow -name Hack-Regular.ttf | head -n 1`
input_hack_bold=`find $fonts_directories -follow -name Hack-Bold.ttf | head -n 1`
if [ -z "${input_hack_regular}" -o -z "${input_hack_bold}" ]
then
echo "Error: Hack-Regular.ttf and/or Hack-Bold.ttf not found" >&2
exit 1
fi
# Search GenJyuuGothicL
input_genjyuu_regular=`find $fonts_directories -follow -iname GenJyuuGothicL-Monospace-Regular.ttf | head -n 1`
input_genjyuu_bold=`find $fonts_directories -follow -iname GenJyuuGothicL-Monospace-Bold.ttf | head -n 1`
if [ -z "${input_genjyuu_regular}" -o -z "${input_genjyuu_bold}" ]
then
echo "Error: GenJyuuGothicL-Monospace-regular.ttf and/or GenJyuuGothicL-Monospace-bold.ttf not found" >&2
exit 1
fi
input_papipupepo_regular=`find $fonts_directories -follow -iname papipupepo-Regular.sfd | head -n 1`
input_papipupepo_bold=`find $fonts_directories -follow -iname papipupepo-Bold.sfd | head -n 1`
input_chouon_ichi_regular=`find $fonts_directories -follow -iname chouon-ichi-Regular.sfd | head -n 1`
input_chouon_ichi_bold=`find $fonts_directories -follow -iname chouon-ichi-Bold.sfd | head -n 1`
# Check filename
[ "$(basename $input_hack_regular)" != "Hack-Regular.ttf" ] &&
echo "Warning: ${input_hack_regular} does not seem to be Hack Regular" >&2
[ "$(basename $input_hack_bold)" != "Hack-Bold.ttf" ] &&
echo "Warning: ${input_hack_regular} does not seem to be Hack Bold" >&2
[ "$(basename $input_genjyuu_regular)" != "GenJyuuGothicL-Monospace-regular.ttf" ] &&
echo "Warning: ${input_genjyuu_regular} does not seem to be GenJyuuGothicL Regular" >&2
[ "$(basename $input_genjyuu_bold)" != "GenJyuuGothicL-Monospace-bold.ttf" ] &&
echo "Warning: ${input_genjyuu_bold} does not seem to be GenJyuuGothicL Bold" >&2
# Check fontforge existance
if ! which $fontforge_command > /dev/null 2>&1
then
echo "Error: ${fontforge_command} command not found" >&2
exit 1
fi
# Make temporary directory
if [ -w "/tmp" -a "${leaving_tmp_flag}" = "false" ]
then
tmpdir=`mktemp -d /tmp/hackgen_generator_tmpdir.XXXXXX` || exit 2
else
tmpdir=`mktemp -d ./hackgen_generator_tmpdir.XXXXXX` || exit 2
fi
# Remove temporary directory by trapping
if [ "${leaving_tmp_flag}" = "false" ]
then
trap "if [ -d \"$tmpdir\" ]; then echo 'Remove temporary files'; rm -rf $tmpdir; echo 'Abnormally terminated'; fi; exit 3" HUP INT QUIT
trap "if [ -d \"$tmpdir\" ]; then echo 'Remove temporary files'; rm -rf $tmpdir; echo 'Abnormally terminated'; fi" EXIT
else
trap "echo 'Abnormally terminated'; exit 3" HUP INT QUIT
fi
########################################
# Generate script for modified Hack Material
########################################
cat > ${tmpdir}/${modified_hack_material_generator} << _EOT_
#!$fontforge_command -script
Print("Generate modified Hack Material")
# Set parameters
input_list = ["${input_hack_regular}", "${input_hack_bold}"]
output_list = ["${modified_hack_material_regular}", "${modified_hack_material_bold}"]
# Begin loop of regular and bold
i = 0
while (i < SizeOf(input_list))
# Open Hack
Print("Open " + input_list[i])
Open(input_list[i])
SelectWorthOutputting()
UnlinkReference()
ScaleToEm(${em_ascent}, ${em_descent})
# パイプの破断線化
Select(0u00a6); Copy()
Select(0u007c); Paste()
Scale(100, 114)
# 0 生成
Select(0u004f); Copy()
Select(0u0030); Paste(); Scale(99, 100)
Select(0u00b7); Copy()
Select(0ufff0); Paste(); Scale(75, 100); Copy()
Select(0u0030); PasteInto()
Select(0ufff0); Clear()
# クォーテーションの拡大
Select(0u0022)
SelectMore(0u0027)
SelectMore(0u0060)
Scale(109, 106)
# ; : , . の拡大
Select(0u003a)
SelectMore(0u003b)
SelectMore(0u002c)
SelectMore(0u002e)
Scale(108)
## 拡大後の位置合わせ
Select(0u003b); Move(0, 18) # ;
Select(0u002e); Move(0, 5) # .
Select(0u002c); Move(0, -8) # ,
# クォーテーションの拡大
Select(0u0027)
SelectMore(0u0022)
SelectMore(0u0060)
Scale(108, 104)
# Eclipse Pleiades 半角スペース記号 (U+1d1c) 対策
Select(0u054d); Copy()
Select(0u1d1c); Paste()
Scale(85, 60)
# パスの小数点以下を切り捨て
SelectWorthOutputting()
RoundToInt()
# Save modified Hack
Print("Save " + output_list[i])
Save("${tmpdir}/" + output_list[i])
i += 1
endloop
Quit()
_EOT_
select_box_drawing_lights='
Select(0u2500, 0u259f)
'
########################################
# Generate script for extracting Box Drawings Lights on Hack Console
########################################
cat > ${tmpdir}/${modified_hack_box_drawing_lights_generator} << _EOT_
#!$fontforge_command -script
Print("Generate Box Drawings Lights on Hack")
# Set parameters
input_list = ["${input_hack_regular}", "${input_hack_bold}"]
output_list = ["${modified_hack_box_drawing_lights_regular}", "${modified_hack_box_drawing_lights_bold}"]
# Begin loop of regular and bold
i = 0
while (i < SizeOf(input_list))
# Open Hack
Print("Open " + input_list[i])
Open(input_list[i])
SelectWorthOutputting()
UnlinkReference()
ScaleToEm(${em_ascent}, ${em_descent})
Scale(${hack_shrink_x}, ${hack_shrink_y}, 0, 0)
# 幅の変更 (Move で文字幅も変わることに注意)
move_pt = $(((${hackgen_half_width} - ${hack_width} * ${hack_shrink_x} / 100) / 2)) # -8
width_pt = ${hackgen_half_width}
Move(move_pt, 0)
SetWidth(width_pt, 0)
# 罫線記号のみを残し、残りを削除
${select_box_drawing_lights}
SelectInvert()
Clear()
# パスの小数点以下を切り捨て
SelectWorthOutputting()
RoundToInt()
# Save modified Hack
Print("Save " + output_list[i])
Save("${tmpdir}/" + output_list[i])
i += 1
endloop
Quit()
_EOT_
########################################
# Generate script for modified Hack console
########################################
cat > ${tmpdir}/${modified_hack_console_generator} << _EOT_
#!$fontforge_command -script
Print("Generate modified Hack Console")
# Set parameters
input_list = ["${tmpdir}/${modified_hack_material_regular}", "${tmpdir}/${modified_hack_material_bold}"]
output_list = ["${modified_hack_console_regular}", "${modified_hack_console_bold}"]
# Begin loop of regular and bold
i = 0
while (i < SizeOf(input_list))
# Open Hack
Print("Open " + input_list[i])
Open(input_list[i])
SelectWorthOutputting()
UnlinkReference()
Scale(${hack_shrink_x}, ${hack_shrink_y}, 0, 0)
# 幅の変更 (Move で文字幅も変わることに注意)
move_pt = $(((${hackgen_half_width} - ${hack_width} * ${hack_shrink_x} / 100) / 2)) # -8
width_pt = ${hackgen_half_width}
Move(move_pt, 0)
SetWidth(width_pt, 0)
# 罫線記号の削除
${select_box_drawing_lights}
Clear()
# パスの小数点以下を切り捨て
SelectWorthOutputting()
RoundToInt()
# Save modified Hack
Print("Save " + output_list[i])
Save("${tmpdir}/" + output_list[i])
i += 1
endloop
Quit()
_EOT_
########################################
# Generate script for modified Hack35 console
########################################
cat > ${tmpdir}/${modified_hack35_console_generator} << _EOT_
#!$fontforge_command -script
Print("Generate modified Hack35 Console")
# Set parameters
input_list = ["${tmpdir}/${modified_hack_material_regular}", "${tmpdir}/${modified_hack_material_bold}"]
output_list = ["${modified_hack35_console_regular}", "${modified_hack35_console_bold}"]
# Begin loop of regular and bold
i = 0
while (i < SizeOf(input_list))
# Open Hack
Print("Open " + input_list[i])
Open(input_list[i])
SelectWorthOutputting()
UnlinkReference()
# 幅の変更 (Move で文字幅も変わることに注意)
move_pt = $(((${hackgen35_half_width} - ${hack_width}) / 2)) # -8
width_pt = ${hackgen35_half_width}
Move(move_pt, 0)
SetWidth(width_pt, 0)
# パスの小数点以下を切り捨て
SelectWorthOutputting()
RoundToInt()
# Save modified Hack
Print("Save " + output_list[i])
Save("${tmpdir}/" + output_list[i])
i += 1
endloop
Quit()
_EOT_
########################################
# Generate script for modified Hack
########################################
cat > ${tmpdir}/${modified_hack_generator} << _EOT_
#!$fontforge_command -script
Print("Generate modified Hack")
# Set parameters
input_list = ["${tmpdir}/${modified_hack_console_regular}", "${tmpdir}/${modified_hack_console_bold}"]
output_list = ["${modified_hack_regular}", "${modified_hack_bold}"]
# Begin loop of regular and bold
i = 0
while (i < SizeOf(input_list))
# Open Hack
Print("Open " + input_list[i])
Open(input_list[i])
# Remove ambiguous glyphs
SelectNone()
## 記号
SelectMore(0u00bc, 0u0522)
SelectMore(0u0E3F)
SelectMore(0u2010, 0u2021)
SelectMore(0u2024, 0u2026)
SelectMore(0u202f, 0u204b)
SelectMore(0u2070, 0u208e)
SelectMore(0u20a0, 0u20b9)
SelectMore(0u2116, 0u215f)
SelectMore(0u2200, 0u2215)
SelectMore(0u221a, 0u222d)
## 矢印
SelectMore(0u2190, 0u2199)
SelectMore(0u21a8)
SelectMore(0u21b0, 0u21b5)
SelectMore(0u21b8, 0u21b9)
SelectMore(0u21c4, 0u21cc)
SelectMore(0u21d0, 0u21d9)
SelectMore(0u21e4, 0u21ed)
SelectMore(0u21f5)
SelectMore(0u27a1)
SelectMore(0u2b05, 0u2b07)
## ≒≠≡
SelectMore(0u2252)
SelectMore(0u2260)
SelectMore(0u2261)
## 罫線、図形
SelectMore(0u2500, 0u25af)
SelectMore(0u25b1, 0u25b3)
SelectMore(0u25b6, 0u25b7)
SelectMore(0u25ba, 0u25bd)
SelectMore(0u25c0, 0u25c1)
SelectMore(0u25c4, 0u25cc)
SelectMore(0u25ce, 0u25d3)
SelectMore(0u25d8, 0u25d9)
SelectMore(0u25e2, 0u25e5)
SelectMore(0u25af)
SelectMore(0u25e6)
SelectMore(0u25ef)
SelectMore(0u266a)
SelectMore(0u2756)
SelectMore(0u29fa, 0u29fb)
SelectMore(0u2A2F)
SelectMore(0u2b1a)
## 可視化文字対策
SelectFewer(0u2022)
SelectFewer(0u00b7)
SelectFewer(0u2024)
SelectFewer(0u2219)
SelectFewer(0u25d8)
SelectFewer(0u25e6)
## 結合分音記号は全て Hack ベースにする
SelectFewer(0u0300, 0u036f)
## 選択中の文字を削除
Clear()
# Save modified Hack
Print("Save " + output_list[i])
Save("${tmpdir}/" + output_list[i])
i += 1
endloop
Quit()
_EOT_
########################################
# Generate script for modified Hack35
########################################
cat > ${tmpdir}/${modified_hack35_generator} << _EOT_
#!$fontforge_command -script
Print("Generate modified Hack")
# Set parameters
input_list = ["${tmpdir}/${modified_hack35_console_regular}", "${tmpdir}/${modified_hack35_console_bold}"]
output_list = ["${modified_hack35_regular}", "${modified_hack35_bold}"]
# Begin loop of regular and bold
i = 0
while (i < SizeOf(input_list))
# Open Hack
Print("Open " + input_list[i])
Open(input_list[i])
# Remove ambiguous glyphs
SelectNone()
## 記号
SelectMore(0u00bc, 0u0522)
SelectMore(0u0E3F)
SelectMore(0u2010, 0u2021)
SelectMore(0u2024, 0u2026)
SelectMore(0u202f, 0u204b)
SelectMore(0u2070, 0u208e)
SelectMore(0u20a0, 0u20b9)
SelectMore(0u2116, 0u215f)
SelectMore(0u2200, 0u2215)
SelectMore(0u221a, 0u222d)
## 矢印
SelectMore(0u2190, 0u2199)
SelectMore(0u21a8)
SelectMore(0u21b0, 0u21b5)
SelectMore(0u21b8, 0u21b9)
SelectMore(0u21c4, 0u21cc)
SelectMore(0u21d0, 0u21d9)
SelectMore(0u21e4, 0u21ed)
SelectMore(0u21f5)
SelectMore(0u27a1)
SelectMore(0u2b05, 0u2b07)
## ≒≠≡
SelectMore(0u2252)
SelectMore(0u2260)
SelectMore(0u2261)
## 罫線、図形
SelectMore(0u2500, 0u25af)
SelectMore(0u25b1, 0u25b3)
SelectMore(0u25b6, 0u25b7)
SelectMore(0u25ba, 0u25bd)
SelectMore(0u25c0, 0u25c1)
SelectMore(0u25c4, 0u25cc)
SelectMore(0u25ce, 0u25d3)
SelectMore(0u25d8, 0u25d9)
SelectMore(0u25e2, 0u25e5)
SelectMore(0u25af)
SelectMore(0u25e6)
SelectMore(0u25ef)
SelectMore(0u266a)
SelectMore(0u2756)
SelectMore(0u29fa, 0u29fb)
SelectMore(0u2A2F)
SelectMore(0u2b1a)
## 可視化文字対策
SelectFewer(0u2022)
SelectFewer(0u00b7)
SelectFewer(0u2024)
SelectFewer(0u2219)
SelectFewer(0u25d8)
SelectFewer(0u25e6)
## 結合分音記号は全て Hack ベースにする
SelectFewer(0u0300, 0u036f)
## 選択中の文字を削除
Clear()
# Save modified Hack
Print("Save " + output_list[i])
Save("${tmpdir}/" + output_list[i])
i += 1
endloop
Quit()
_EOT_
########################################
# Generate script for modified GenJyuuGothicL
########################################
cat > ${tmpdir}/${modified_genjyuu_generator} << _EOT_
#!$fontforge_command -script
Print("Generate modified GenJyuuGothicL")
# Set parameters
hack = "${tmpdir}/${modified_hack_regular}"
input_list = ["${input_genjyuu_regular}", "${input_genjyuu_bold}"]
papipupepo_list = ["${input_papipupepo_regular}", "${input_papipupepo_bold}"]
chouon_ichi_list = ["${input_chouon_ichi_regular}", "${input_chouon_ichi_bold}"]
output_list = ["${modified_genjyuu_regular}", "${modified_genjyuu_bold}"]
fontstyle_list = ["Regular", "Bold"]
fontweight_list = [400, 700]
panoseweight_list = [5, 8]
Print("Get trim target glyph from Hack")
Open(hack)
i = 0
end_hack = 65535
hack_exist_glyph_array = Array(end_hack)
while (i < end_hack)
if (i % 5000 == 0)
Print("Processing progress: " + i)
endif
if (WorthOutputting(i))
hack_exist_glyph_array[i] = 1
else
hack_exist_glyph_array[i] = 0
endif
i++
endloop
Close()
# Begin loop of regular and bold
i = 0
while (i < SizeOf(input_list))
# Open GenJyuuGothicL
Print("Open " + input_list[i])
Open(papipupepo_list[i])
MergeFonts(chouon_ichi_list[i])
MergeFonts(input_list[i])
SelectWorthOutputting()
UnlinkReference()
ScaleToEm(${em_ascent}, ${em_descent})
ii = 0
end_genjyuu = end_hack
halfwidth_array = Array(end_genjyuu)
i_halfwidth = 0
Print("Half width check loop start")
while ( ii < end_genjyuu )
if ( ii % 5000 == 0 )
Print("Processing progress: " + ii)
endif
if (WorthOutputting(ii))
Select(ii)
if (hack_exist_glyph_array[ii] == 1)
Clear()
elseif (GlyphInfo("Width")<768)
halfwidth_array[i_halfwidth] = ii
i_halfwidth = i_halfwidth + 1
endif
endif
ii = ii + 1
endloop
Print("Half width check loop end")
Print("Full SetWidth start")
move_pt = $(((${hackgen_full_width} - ${genjyuu_width}) / 2)) # 26
width_pt = ${hackgen_full_width} # 1076
SelectWorthOutputting()
ii=0
while (ii < i_halfwidth)
SelectFewer(halfwidth_array[ii])
ii = ii + 1
endloop
Move(move_pt, 0)
SetWidth(width_pt)
Print("Full SetWidth end")
SelectNone()
Print("Half SetWidth start")
move_pt = $(((${hackgen_half_width} - ${genjyuu_width} / 2) / 2)) # 13
width_pt = ${hackgen_half_width} # 358
ii=0
while (ii < i_halfwidth)
SelectMore(halfwidth_array[ii])
ii = ii + 1
endloop
Move(move_pt, 0)
SetWidth(width_pt)
Print("Half SetWidth end")
# Edit zenkaku space (from ballot box and heavy greek cross)
if ("${zenkaku_space_glyph}" != "0u3000")
Print("Edit zenkaku space")
if ("${zenkaku_space_glyph}" == "")
Select(0u2610); Copy(); Select(0u3000); Paste()
Select(0u271a); Copy(); Select(0u3000); PasteInto()
OverlapIntersect()
else
Select(${zenkaku_space_glyph}); Copy(); Select(0u3000); Paste()
endif
endif
# 結合分音記号は全て Hack ベースにする
Select(0u0300, 0u036f); Clear()
# Edit zenkaku brackets
Print("Edit zenkaku brackets")
bracket_move = $((${hackgen_half_width} / 2 + ${hackgen_half_width} / 30))
Select(0uff08); Move(-bracket_move, 0); SetWidth(${hackgen_full_width}) # (
Select(0uff09); Move( bracket_move, 0); SetWidth(${hackgen_full_width}) # )
Select(0uff3b); Move(-bracket_move, 0); SetWidth(${hackgen_full_width}) # [
Select(0uff3d); Move( bracket_move, 0); SetWidth(${hackgen_full_width}) # ]
Select(0uff5b); Move(-bracket_move, 0); SetWidth(${hackgen_full_width}) # {
Select(0uff5d); Move( bracket_move, 0); SetWidth(${hackgen_full_width}) # }
# Save modified GenJyuuGothicL
Print("Save " + output_list[i])
Save("${tmpdir}/" + output_list[i])
Close()
# Open new file
Print("Generate Genjyuu ttf")
New()
# Set encoding to Unicode-bmp
Reencode("unicode")
# Set configuration
SetFontNames("modified-genjyuu" + fontstyle_list[i])
ScaleToEm(${em_ascent}, ${em_descent})
SetOS2Value("Weight", fontweight_list[i]) # Book or Bold
SetOS2Value("Width", 5) # Medium
SetOS2Value("FSType", 0)
SetOS2Value("VendorID", "PfEd")
SetOS2Value("IBMFamily", 2057) # SS Typewriter Gothic
SetOS2Value("WinAscentIsOffset", 0)
SetOS2Value("WinDescentIsOffset", 0)
SetOS2Value("TypoAscentIsOffset", 0)
SetOS2Value("TypoDescentIsOffset", 0)
SetOS2Value("HHeadAscentIsOffset", 0)
SetOS2Value("HHeadDescentIsOffset", 0)
SetOS2Value("WinAscent", ${hackgen_ascent})
SetOS2Value("WinDescent", ${hackgen_descent})
SetOS2Value("TypoAscent", ${em_ascent})
SetOS2Value("TypoDescent", -${em_descent})
SetOS2Value("TypoLineGap", ${typo_line_gap})
SetOS2Value("HHeadAscent", ${hackgen_ascent})
SetOS2Value("HHeadDescent", -${hackgen_descent})
SetOS2Value("HHeadLineGap", 0)
SetPanose([2, 11, panoseweight_list[i], 9, 2, 2, 3, 2, 2, 7])
MergeFonts("${tmpdir}/" + output_list[i])
Generate("${tmpdir}/" + output_list[i] + ".ttf", "")
Close()
i += 1
endloop
Quit()
_EOT_
########################################
# Generate script for modified GenJyuuGothicL for HackGen35
########################################
cat > ${tmpdir}/${modified_genjyuu35_generator} << _EOT_
#!$fontforge_command -script
Print("Generate modified GenJyuuGothicL - 35")
# Set parameters
hack = "${tmpdir}/${modified_hack35_regular}"
input_list = ["${input_genjyuu_regular}", "${input_genjyuu_bold}"]
papipupepo_list = ["${input_papipupepo_regular}", "${input_papipupepo_bold}"]
chouon_ichi_list = ["${input_chouon_ichi_regular}", "${input_chouon_ichi_bold}"]
output_list = ["${modified_genjyuu35_regular}", "${modified_genjyuu35_bold}"]
fontstyle_list = ["Regular", "Bold"]
fontweight_list = [400, 700]
panoseweight_list = [5, 8]
Print("Get trim target glyph from Hack")
Open(hack)
i = 0
end_hack = 65535
hack_exist_glyph_array = Array(end_hack)
while (i < end_hack)
if (i % 5000 == 0)
Print("Processing progress: " + i)
endif
if (WorthOutputting(i))
hack_exist_glyph_array[i] = 1
else
hack_exist_glyph_array[i] = 0
endif
i++
endloop
Close()
# Begin loop of regular and bold
i = 0
while (i < SizeOf(input_list))
# Open GenJyuuGothicL
Print("Open " + input_list[i])
Open(papipupepo_list[i])
MergeFonts(chouon_ichi_list[i])
MergeFonts(input_list[i])
SelectWorthOutputting()
UnlinkReference()
ScaleToEm(${em_ascent}, ${em_descent})
ii = 0
end_genjyuu = end_hack
halfwidth_array = Array(end_genjyuu)
i_halfwidth = 0
Print("Half width check loop start")
while ( ii < end_genjyuu )
if ( ii % 5000 == 0 )
Print("Processing progress: " + ii)
endif
if (WorthOutputting(ii))
Select(ii)
if (hack_exist_glyph_array[ii] == 1)
Clear()
elseif (GlyphInfo("Width")<768)
halfwidth_array[i_halfwidth] = ii
i_halfwidth = i_halfwidth + 1
endif
endif
ii = ii + 1
endloop
Print("Half width check loop end")
Print("Full SetWidth start")
move_pt = $(((${hackgen35_full_width} - ${genjyuu_width}) / 2)) # 3
width_pt = ${hackgen35_full_width} # 1030
SelectWorthOutputting()
ii=0
while (ii < i_halfwidth)
SelectFewer(halfwidth_array[ii])
ii = ii + 1
endloop
Move(move_pt, 0)
SetWidth(width_pt)
Print("Full SetWidth end")
SelectNone()
Print("Half SetWidth start")
move_pt = $(((${hackgen35_half_width} - ${genjyuu_width} / 2) / 2)) # 35
width_pt = ${hackgen35_half_width} # 618
ii=0
while (ii < i_halfwidth)
SelectMore(halfwidth_array[ii])
ii = ii + 1
endloop
Move(move_pt, 0)
SetWidth(width_pt)
Print("Half SetWidth end")
# Edit zenkaku space (from ballot box and heavy greek cross)
if ("${zenkaku_space_glyph}" != "0u3000")
Print("Edit zenkaku space")
if ("${zenkaku_space_glyph}" == "")
Select(0u2610); Copy(); Select(0u3000); Paste()
Select(0u271a); Copy(); Select(0u3000); PasteInto()
OverlapIntersect()
else
Select(${zenkaku_space_glyph}); Copy(); Select(0u3000); Paste()
endif
endif
# 結合分音記号は全て Hack ベースにする
Select(0u0300, 0u036f); Clear()
# Edit zenkaku brackets
Print("Edit zenkaku brackets")
bracket_move = $((${hackgen35_half_width} / 2 + ${hackgen35_half_width} / 30))
Select(0uff08); Move(-bracket_move, 0); SetWidth(${hackgen35_full_width}) # (
Select(0uff09); Move( bracket_move, 0); SetWidth(${hackgen35_full_width}) # )
Select(0uff3b); Move(-bracket_move, 0); SetWidth(${hackgen35_full_width}) # [
Select(0uff3d); Move( bracket_move, 0); SetWidth(${hackgen35_full_width}) # ]
Select(0uff5b); Move(-bracket_move, 0); SetWidth(${hackgen35_full_width}) # {
Select(0uff5d); Move( bracket_move, 0); SetWidth(${hackgen35_full_width}) # }
# Save modified GenJyuuGothicL
Print("Save " + output_list[i])
Save("${tmpdir}/" + output_list[i])
Close()
# Open new file
Print("Generate Genjyuu ttf")
New()
# Set encoding to Unicode-bmp
Reencode("unicode")
# Set configuration
SetFontNames("modified-genjyuu" + fontstyle_list[i])
ScaleToEm(${em_ascent}, ${em_descent})
SetOS2Value("Weight", fontweight_list[i]) # Book or Bold
SetOS2Value("Width", 5) # Medium
SetOS2Value("FSType", 0)
SetOS2Value("VendorID", "PfEd")
SetOS2Value("IBMFamily", 2057) # SS Typewriter Gothic
SetOS2Value("WinAscentIsOffset", 0)
SetOS2Value("WinDescentIsOffset", 0)
SetOS2Value("TypoAscentIsOffset", 0)
SetOS2Value("TypoDescentIsOffset", 0)
SetOS2Value("HHeadAscentIsOffset", 0)
SetOS2Value("HHeadDescentIsOffset", 0)
SetOS2Value("WinAscent", ${hackgen35_ascent})
SetOS2Value("WinDescent", ${hackgen35_descent})
SetOS2Value("TypoAscent", ${em_ascent})
SetOS2Value("TypoDescent", -${em_descent})
SetOS2Value("TypoLineGap", ${typo_line_gap})
SetOS2Value("HHeadAscent", ${hackgen35_ascent})
SetOS2Value("HHeadDescent", -${hackgen35_descent})
SetOS2Value("HHeadLineGap", 0)
SetPanose([2, 11, panoseweight_list[i], 9, 2, 2, 3, 2, 2, 7])
MergeFonts("${tmpdir}/" + output_list[i])
Generate("${tmpdir}/" + output_list[i] + ".ttf", "")
Close()
i += 1
endloop
Quit()
_EOT_
########################################
# Generate script for modified GenJyuuGothicL Console
########################################
cat > ${tmpdir}/${modified_genjyuu_console_generator} << _EOT_
#!$fontforge_command -script
Print("Generate modified GenJyuuGothicL Console")
# Set parameters
hack = "${tmpdir}/${modified_hack_material_regular}"
input_list = ["${tmpdir}/${modified_genjyuu_regular}.ttf", "${tmpdir}/${modified_genjyuu_bold}.ttf"]
output_list = ["${modified_genjyuu_console_regular}", "${modified_genjyuu_console_bold}"]
Print("Get trim target glyph from Hack")
Open(hack)
i = 0
end_hack = 65535
hack_exist_glyph_array = Array(end_hack)
while (i < end_hack)
if (i % 5000 == 0)
Print("Processing progress: " + i)
endif
if (WorthOutputting(i))
hack_exist_glyph_array[i] = 1
else
hack_exist_glyph_array[i] = 0
endif
i++
endloop
Close()
# Begin loop of regular and bold
i = 0
while (i < SizeOf(input_list))
# Open GenJyuuGothicL
Print("Open " + input_list[i])
Open(input_list[i])
ii = 0
end_genjyuu = end_hack
Print("Begin delete the glyphs contained in Hack")
while ( ii < end_genjyuu )
if ( ii % 5000 == 0 )
Print("Processing progress: " + ii)
endif
if (WorthOutputting(ii) && hack_exist_glyph_array[ii] == 1)
Select(ii)
Clear()
endif
ii = ii + 1
endloop
Print("End delete the glyphs contained in Hack")
# Save modified GenJyuuGothicL
Print("Generate " + output_list[i])
Generate("${tmpdir}/" + output_list[i] + ".ttf", "")
Close()
i += 1
endloop
Quit()
_EOT_
########################################
# Generate script for modified GenJyuuGothicL Console for HackGen35
########################################
cat > ${tmpdir}/${modified_genjyuu35_console_generator} << _EOT_
#!$fontforge_command -script
Print("Generate modified GenJyuuGothicL Console - 35")