summaryrefslogtreecommitdiff
path: root/fonts/utilities/afmtopl/wolczko/mk-obl
blob: 56d73542230c7b5513b39067e0c859391a4afede (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
#! /bin/sh
# Make an oblique version of an AFM file
# usage: mk-obl newangle afm-file-name >new-afm-file-name
# 
# newangle should be an integer, in degrees of anti-clockwise skew
#
# bugs: doesn't set these fields properly:
#	FontBBox
#	UnderlinePosition
#	KPX
# the llx field of Character Metrics is unchanged.
# the urx field is guesstimated
#
# rounding is done with int(x+0.5) --- this is wrong for -ve values
awk 'BEGIN {'newangle=$1';
	tan[ 0]=0;        tan[ 1]=.017454;  tan[ 2]=.034919;  tan[ 3]=.052406;  
	tan[ 4]=.069926;  tan[ 5]=.087487;  tan[ 6]=.105102;  tan[ 7]=.122783;  
	tan[ 8]=.140539;  tan[ 9]=.158383;  tan[10]=.176325;  tan[11]=.194379;  
	tan[12]=.212555;  tan[13]=.230867;  tan[14]=.249325;  tan[15]=.267948;  
	tan[16]=.286744;  tan[17]=.305728;  tan[18]=.324918;  tan[19]=.344326;  
	tan[20]=.363969;  tan[21]=.383863;  tan[22]=.404025;  tan[23]=.424473;  
	tan[24]=.445227;  tan[25]=.466306;  tan[26]=.487731;  tan[27]=.509524;  
	tan[28]=.531707;  tan[29]=.554308;  tan[30]=.577349;  tan[31]=.600859;  
	tan[32]=.624867;  tan[33]=.649406;  tan[34]=.674507;  tan[35]=.700205;  
	tan[36]=.726540;  tan[37]=.753552;  tan[38]=.781283;  tan[39]=.809782;  
	tan[40]=.839099;  tan[41]=.869284;  tan[42]=.900401;  tan[43]=.932512;  
	tan[44]=.965686;  tan[45]=.999998;  tan[46]=1.035526; tan[47]=1.072368; 
	tan[48]=1.110610; tan[49]=1.150364; tan[50]=1.191750; tan[51]=1.234894; 
	tan[52]=1.279939; tan[53]=1.327040; tan[54]=1.376380; tan[55]=1.428144; 
	tan[56]=1.482555; tan[57]=1.539859; tan[58]=1.600330; tan[59]=1.664273; 
	tan[60]=1.732044; tan[61]=1.804039; tan[62]=1.880723; tan[63]=1.962604; 
	tan[64]=2.050297; tan[65]=2.144501; tan[66]=2.246033; tan[67]=2.355844; 
	tan[68]=2.475075; tan[69]=2.605080; tan[70]=2.747468; tan[71]=2.904201; 
	tan[72]=3.077671; tan[73]=3.270835; tan[74]=3.487391; tan[75]=3.732019; 
	tan[76]=4.010759; tan[77]=4.331452; tan[78]=4.704597; tan[79]=5.144493; 
	tan[80]=5.671250; tan[81]=6.313687; tan[82]=7.115264; tan[83]=8.144301; 
	tan[84]=9.514216; tan[85]=11.42988; tan[86]=14.30034; tan[87]=19.08075;
	tan[88]=28.63500; tan[89]=57.28469;

	if (newangle != int(newangle)) {
		print "Angle must be an integer" >"/dev/tty";
		exit 1;
	}  
	if (newangle < 0) {
		tannew = -tan[-newangle];
	} else if (newangle > 0) {
		tannew = tan[newangle];
	} else {
		tannew = 0;
	}
}

/^FontName/ {
	print $0 "-Oblique";
	next;
	}

/^FullName/ {
	print $0, "Oblique";
	next;
	}

/^ItalicAngle/	{
	if ($2 < 0) {
		origangle = int($2 - 0.5);
		tanorig = -tan[-origangle];
	} else if ($2 > 0) {
		origangle = int($2 + 0.5);
		tanorig = tan[origangle];
	} else {
		origangle = 0;
		tanorig = 0;
	}
	print "ItalicAngle " newangle ; next ;
}

/^C / {
	llx = $11;
	lly = $12;
	urx = $13;
	ury = $14;
	h = ury - lly;
	if (origangle < 0)
		urx = urx + h * tanorig;
	else if (origangle > 0)
		llx = llx + h * tanorig;

	# now llx and urx are correct for an upright font
	# so apply the desired slope
	if (newangle < 0)
		urx = urx - h * tannew;
	else if (newangle > 0)
		llx = llx - h * tannew;

	$11 = int(llx + 0.5);
	$13 = int(urx + 0.5);
	print $0; next;
}

{print}' $2