summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/source/fonts/japanese-otf/script/mkaltutfvf.pl
blob: 44e78e1fe395df4ff8f743ab784a16b255f021b3 (plain)
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
open(GLYPH, "<glyphdata")||open(GLYPH, "<script/glyphdata");
binmode(GLYPH);
@glyph_sub_table=();
opendir(OVP, "ovp") || mkdir("ovp",0755) || die "cannot mkdir ovp";
opendir(VF, "vf") || mkdir("vf",0755) || die "cannot mkdir vf";
closedir(OVP);
closedir(VF);

&make_glyph_substitute_array;
&make_uni_vf;

#
# dfn of sub rtns.
#
sub make_glyph_substitute_array {
	for ($j=0x0000; $j<=0xffff; $j=$j+2){
		read(GLYPH, $hex_data, 1);
		$hex_data= unpack("C", $hex_data);
		$high=$hex_data >> 4;
		$low=$hex_data-($high*16);
		&write_cjkt($high);
		&write_cjkt($low);
	}
}
sub make_uni_vf {
	for ($k=0; $k<=1; $k++){#face
		if ($k==0) {$face="mr";}elsif ($k==1){$face="gr";}elsif ($k==2){$face="mb";}
			elsif ($k==3){$face="gb";}elsif ($k==4){$face="mgr";}elsif ($k==5){$face="ml";}
			elsif ($k==6){$face="ge";}
		for ($i=0; $i<=1; $i++){#direction
			if ($i==0) {$dir="h";}elsif ($i==1){$dir="v";}
			for ($first_hex=0x0; $first_hex <= 0xf; $first_hex++){
				$filename="utf$face".sprintf("%x",$first_hex)."-$dir";
				open(OVP, ">ovp/$filename.ovp")||die "$!";
				&fonthead;
				for ($l=0; $l<=3; $l++){#language
					if ($l==0) {$lang="j";} elsif ($l==1) {$lang="k";} elsif ($l==2) {$lang="c";} elsif ($l==3){$lang="t";}
					print OVP "(MAPFONT D $l\n   (FONTNAME otf-u$lang$face-$dir)\n";
					&fontfoot;
				}
				&writechar;
				close(OVP);
				system("ovp2ovf ovp/$filename.ovp vf/$filename.vf vf/$filename.ofm");
				unlink "vf/$filename.ofm";
			}
		}
	}
}
sub fonthead {
print OVP <<END_OF_DATA;
(VTITLE JVF for UTF16)
(OFMLEVEL D 0)
(DESIGNSIZE R 10.000000)
(CHECKSUM O 0)
END_OF_DATA
}

sub fontfoot {
print OVP <<END_OF_DATA;
   (FONTCHECKSUM O 0)
   (FONTAT R 1.0)
   (FONTDSIZE R 10.000000)
   )
END_OF_DATA
}#2003/10/22 FONTAT 0.962216->1.0
sub writechar {
	for ($ku=1; $ku <= 79; $ku++){#2002/1/27 120->79
		for ($ten=1; $ten <= 94; $ten++){
			if ($ku>=16 && $ku<=79 && $ten>=16 && $ten<=79){
				&printchar($first_hex,$ku,$ten);
			} else {
				&printgeta($first_hex,$ku,$ten);
			}
		}
	}
}

sub printchar {
	$jiscode=($_[1]+0x20)*256+($_[2]+0x20);
	$unicode=$_[0]*4096+($_[1]-16)*64+($_[2]-16);
	printf OVP "(CHARACTER H %X\n", $jiscode;
	print OUT "   (CHARWD R 1.0)\n";#2003/10/22 CHARWD 0.962216->1.0
	print  OVP "   (MAP\n";
	&write_map_font;
	printf OVP "      (SETCHAR H %X)\n", $unicode;
	print  OVP "      )\n";
	print  OVP "   )\n";
}

sub printgeta {
	$jiscode=($_[1]+0x20)*256+($_[2]+0x20);
	printf OVP "(CHARACTER H %X\n", $jiscode;
	print OUT "   (CHARWD R 1.0)\n";#2003/10/22 CHARWD 0.962216->1.0
	print  OVP "   (MAP\n";
	print  OVP "      (SETCHAR H 3013)\n";
	print  OVP "      )\n";
	print  OVP "   )\n";
}
sub write_map_font{
	if ($glyph_sub_table[$unicode] eq "c"){
		print OVP "      (SELECTFONT D 2)\n";
	}elsif($glyph_sub_table[$unicode] eq "t"){
		print OVP "      (SELECTFONT D 3)\n";
	}elsif($glyph_sub_table[$unicode] eq "k"){
		print OVP "      (SELECTFONT D 1)\n";
	}
}
sub write_cjkt{
	if ($_[0]>=8 || $_[0]==0){
		push(@glyph_sub_table,"j");
	}elsif(4<=$_[0] && $_[0]<8){
		push(@glyph_sub_table,"c");
	}elsif(2<=$_[0] && $_[0]<4){
		push(@glyph_sub_table,"t");
	}elsif($_[0]==1){
		push(@glyph_sub_table,"k");
	}
}