~unifont/unifont/trunk

« back to all changes in this revision

Viewing changes to src/hex2sfd

  • Committer: Samuel Bronson
  • Author(s): Paul Hardy
  • Date: 2009-08-10 21:54:24 UTC
  • Revision ID: naesten@gmail.com-20090810215424-acy265xnh51wzk8v
Import of http://www.unifoundry.com/pub/debian/unifont-5.1.20080914.tar.gz.

This update (7 September 2008) only changes the positioning of Unicode
combining diacritical marks in the TrueType version to better conform
to the standard. All glyph shapes otherwise are unchanged from the 20
August 2008 version.

[... but why don't the dates match? --Sam]

Show diffs side-by-side

added added

removed removed

Lines of Context:
2
2
#
3
3
# hex2sfd created in 2005 by Luis Gonzalez Miranda, http://www.lgm.cl
4
4
#
5
 
# %combining = ();
6
 
# open(A, "<combining.txt");
7
 
# while(<A>) {
8
 
#       chomp;
9
 
#       $combining{$A} = 1;
10
 
# }
11
 
# close(A);
12
 
#
13
5
# Modified by Paul Hardy, June 2008.
14
6
#
15
 
# The original code above didn't work properly.  The replacement code
 
7
# The original combining mark code didn't work properly.  The replacement code
16
8
# below wastes RAM, but it works as a quick fix.
17
9
#
18
10
@combining = ();
19
11
for ($i = 0; $i < 65536; $i++) {
20
12
   push(@combining, 0);
21
13
}
22
 
open(A, "<combining.txt");
 
14
open(A, "<combining.dat");
23
15
while (<A>) {
24
16
   chomp;
25
17
   $combining[ hex($_) ] = 1;
37
29
$pixel   = 64;
38
30
$descent = 2 * $pixel;
39
31
$ascent  = 16 * $pixel - $descent;
40
 
$bitmask = 25;  # round in x (doesn't really work), corner point selected
 
32
# $bitmask = 25;  # round in x (doesn't really work), corner point selected
41
33
 
42
34
print << "END";
43
35
SplineFontDB: 1.0
93
85
        ($c,$d)=split(/:/);
94
86
        $width=length($d)/4;
95
87
        $ptwidth=$pixel * $width;
 
88
        $xoffset = 0; # assume this isn't a combining mark
96
89
#       if($combining{$c}) {             # this was the original "if"
97
 
        if ($combining[ hex($c) ]) {
 
90
        if ($combining[ hex($c) ]) { # this code point is a combining mark
 
91
                $xoffset = -$ptwidth; # we'll go left by this amount
98
92
                $ptwidth = 0;
99
93
        }
100
94
        $cn=hex($c);
119
113
                                # point at i, width-1-j
120
114
                                if(!$prev) {
121
115
                                        $x1=$x * $pixel + $pixel;
 
116
                                        $x1 += $xoffset;
122
117
                                        $y1=$y * $pixel - $descent;
123
118
                                        $x2=$x1 + $pixel;
 
119
                                        $x2 += $xoffset;
124
120
                                        $y2=$y1 + $pixel;
125
121
                                }
126
122
                                $prev=1;
127
123
                        } else {
128
124
                                if($prev) {
129
125
                                        $x2=$x * $pixel + $pixel;
 
126
                                        $x2 += $xoffset;
130
127
                                        print << "END";
131
 
$x1 $y1 m $bitmask
132
 
 $x1 $y2 l $bitmask
133
 
 $x2 $y2 l $bitmask
134
 
 $x2 $y1 l $bitmask
135
 
 $x1 $y1 l $bitmask
 
128
$x1 $y1 m 29
 
129
 $x1 $y2 l 25
 
130
 $x2 $y2 l 25
 
131
 $x2 $y1 l 25
 
132
 $x1 $y1 l 29
136
133
END
137
134
                                }
138
135
                                $prev=0;
140
137
                        $num=int($num/2);
141
138
                }
142
139
                if($prev) {
143
 
                        $x2=0;
 
140
                        $x2 = $xoffset;
144
141
                        print << "END";
145
 
$x1 $y1 m $bitmask
146
 
 $x1 $y2 l $bitmask
147
 
 $x2 $y2 l $bitmask
148
 
 $x2 $y1 l $bitmask
149
 
 $x1 $y1 l $bitmask
 
142
$x1 $y1 m 29
 
143
 $x1 $y2 l 25
 
144
 $x2 $y2 l 25
 
145
 $x2 $y1 l 25
 
146
 $x1 $y1 l 29
150
147
END
151
148
                }
152
149
        }