1#!/usr/local/bin/perl 2# Convert bdf fonts to bold style. 3# Copyright (C) 1994-95 Cronyx Ltd. 4# Author: Serge Vakulenko, <vak@cronyx.ru> 5# Changes Copyright (C) 1995 by Andrey A. Chernov, Moscow, Russia. 6# 7# This software may be used, modified, copied, distributed, and sold, 8# in both source and binary form provided that the above copyright 9# and these terms are retained. Under no circumstances is the author 10# responsible for the proper functioning of this software, nor does 11# the author assume any responsibility for damages incurred with its use. 12 13$pattern{"0"} = "0000"; 14$pattern{"1"} = "0001"; 15$pattern{"2"} = "0010"; 16$pattern{"3"} = "0011"; 17$pattern{"4"} = "0100"; 18$pattern{"5"} = "0101"; 19$pattern{"6"} = "0110"; 20$pattern{"7"} = "0111"; 21$pattern{"8"} = "1000"; 22$pattern{"9"} = "1001"; 23$pattern{"a"} = "1010"; $pattern{"A"} = "1010"; 24$pattern{"b"} = "1011"; $pattern{"B"} = "1011"; 25$pattern{"c"} = "1100"; $pattern{"C"} = "1100"; 26$pattern{"d"} = "1101"; $pattern{"D"} = "1101"; 27$pattern{"e"} = "1110"; $pattern{"E"} = "1110"; 28$pattern{"f"} = "1111"; $pattern{"F"} = "1111"; 29 30$hexdig{"0000"} = "0"; 31$hexdig{"0001"} = "1"; 32$hexdig{"0010"} = "2"; 33$hexdig{"0011"} = "3"; 34$hexdig{"0100"} = "4"; 35$hexdig{"0101"} = "5"; 36$hexdig{"0110"} = "6"; 37$hexdig{"0111"} = "7"; 38$hexdig{"1000"} = "8"; 39$hexdig{"1001"} = "9"; 40$hexdig{"1010"} = "a"; $hexdig{"1010"} = "A"; 41$hexdig{"1011"} = "b"; $hexdig{"1011"} = "B"; 42$hexdig{"1100"} = "c"; $hexdig{"1100"} = "C"; 43$hexdig{"1101"} = "d"; $hexdig{"1101"} = "D"; 44$hexdig{"1110"} = "e"; $hexdig{"1110"} = "E"; 45$hexdig{"1111"} = "f"; $hexdig{"1111"} = "F"; 46 47while (<>) { 48 if (/^WEIGHT_NAME .*$/) { 49 s/"Medium"/"Bold"/; 50 print; 51 } elsif (/^FONT .*$/) { 52 s/-Medium-/-Bold-/; 53 print; 54 } elsif (/^FONTBOUNDINGBOX .*$/) { 55 @r = split; 56 $h = $r[2]; 57 $w = $r[1] + 1; 58 printf "FONTBOUNDINGBOX %d %d %d %d\n", $w, $h, $r[3], $r[4]; 59 } elsif (/^CHARS .*$/) { 60 print; 61 last; 62 } else { 63 print; 64 } 65} 66 67while (<>) { 68 if (/^STARTCHAR .*$/) { 69 print; 70 } elsif (/^ENDCHAR.*$/) { 71 print; 72 } elsif (/^ENCODING .*$/) { 73 print; 74 } elsif (/^SWIDTH .*$/) { 75 ; 76 } elsif (/^DWIDTH .*$/) { 77 ; 78 } elsif (/^BBX .*$/) { 79 @r = split; 80 $h = $r[2]; 81 $w = $r[1] + 1; 82 printf "SWIDTH %d 0\n", int ($w * 1000 / $h); 83 printf "DWIDTH %d 0\n", $w; 84 printf "BBX %d %d %d %d\n", $w, $h, $r[3], $r[4]; 85 } elsif (/^BITMAP.*$/) { 86 print "BITMAP\n"; 87 &makechar; 88 } 89} 90print "ENDFONT\n"; 91 92sub makechar { 93 for ($i=0; $i<$h; ++$i) { 94 chop ($line = <>); 95 @x = split (//, $line); 96 @b = (); 97 foreach $c (@x) { 98 push (@b, split (//, $pattern{$c})); 99 } 100 push (@b, ('0','0','0','0','0','0','0','0')); 101 for ($n=$w-1; $n>1; --$n) { 102 if ($b[$n]=='0' && $b[$n-1]=='1') { 103 $b[$n] = '1'; 104 } 105 } 106 for ($n=2*int(($w+7)/8); $n>0; --$n) { 107 @x = splice (@b, 0, 4); 108 $c = join ('', @x); 109 print $hexdig{$c}; 110 } 111 print "\n"; 112 } 113} 114