3 # Copyright (C) 1998, 2013 Roman Czyborra, Paul Hardy
7 # This program is free software: you can redistribute it and/or modify
8 # it under the terms of the GNU General Public License as published by
9 # the Free Software Foundation, either version 2 of the License, or
10 # (at your option) any later version.
12 # This program is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 # GNU General Public License for more details.
17 # You should have received a copy of the GNU General Public License
18 # along with this program. If not, see <http://www.gnu.org/licenses/>.
20 # First, parse command-line options. Two are available:
22 # - Font name (-f name or --font name)
23 # - Lines per glyph (-lnn or --lines nn, where nn is a decimal number)
27 $result = GetOptions (
28 "copyright|c=s" => \$copyright, # Copyright string
29 "font|f=s" => \$font_name, # XLFD FAMILY_NAME
30 "rows|r=i" => \$vpixels, # XLFD PIXEL_SIZE; vertical pixels
31 "version|v=s" => \$version # Version of this font
35 $font_name = "Unifont";
44 $point_size = $vpixels;
45 $point_size10 = 10 * $point_size;
47 while (<>) { chomp; $glyph{$1} = $2 if /(....):(.+)/; }
48 @chars = sort keys %glyph;
49 $nchars = $#chars + 1;
53 FONT -gnu-${font_name}-Medium-R-Normal-Sans-${vpixels}-${point_size10}-75-75-c-80-iso10646-1
54 SIZE $point_size 75 75
55 FONTBOUNDINGBOX $vpixels $vpixels 0 -2
57 COPYRIGHT \"${copyright}\"
58 FONT_VERSION \"${version}\"
61 FAMILY_NAME \"${font_name}\"
62 WEIGHT_NAME \"Medium\"
64 SETWIDTH_NAME \"Normal\"
65 ADD_STYLE_NAME \"Sans Serif\"
67 POINT_SIZE ${point_size10}
72 CHARSET_REGISTRY \"ISO10646\"
73 CHARSET_ENCODING \"1\"
84 # TODO: $swidth needs to be modified to accomodate different widths better
85 # for glyphs with height different than 16 pixels.
87 foreach $character (@chars)
89 $encoding = hex($character); $glyph = $glyph{$character};
90 $width = length ($glyph) / $vpixels; # hex digits per row
91 $dwidth = $width * 4; # device width, in pixels; 1 digit = 4 px
92 # scalable width, units of 1/1000th full-width glyph
93 $swidth = (1000 * $width) / ($vpixels / 4);
94 $glyph =~ s/((.){$width})/\n$1/g;
95 $character = "$character $charname"
96 if $charname = $charname{pack("n",hex($character))};
98 print "STARTCHAR U+$character
102 BBX $dwidth $vpixels 0 -2