Return to BSD News archive
Newsgroups: comp.os.386bsd.apps
Path: sserve!newshost.anu.edu.au!munnari.oz.au!news.Hawaii.Edu!ames!elroy.jpl.nasa.gov!swrinde!cs.utexas.edu!uunet!news.cnri.reston.va.us!newsserver.jvnc.net!gmd.de!mururoa!veit
From: veit@mururoa.gmd.de (Holger Veit)
Subject: font converter (perl) raw->codrv-bdf (forward)
Message-ID: <1993Jul15.073818.16632@gmd.de>
Keywords: codrv,bdf,font
Sender: veit@mururoa (Holger Veit)
Nntp-Posting-Host: mururoa
Organization: GMD - German National Research Center for Computer Science
Date: Thu, 15 Jul 1993 07:38:18 GMT
Lines: 105
The following is posted for a guy who has no post access to
the comp.os.386bsd.* groups. I think this is a nice addition,
some of the tools you sometime might need, but then do not find.
Holger
==================================================================
Hello Holger,
I cannot post directly into the 386bsd newsgroups so I send you what
follows. If you find it interesting for others maybe you can post it.
I've made in perl a converter between what I will call `raw font
files' (16 bytes par character and 256 characters) and your pseudo-bdf
font files. I took the same parameters as the ones present into your
examples.
I can improve it a bit to support variable number of characters if it
is interesting.
What do you think ?
------------------------------------------------------------
#!/usr/local/bin/perl
#
# fnt2bdf.pl
#
# Conversion utility between raw VGA 8x16 fonts into almost-X compatible
# bdf-type font.
#
# Raw format :
# 16 bytes per character, 256-characters table
#
# pseudo-bdf format :
# see vgafont(5)
#
die "Usage : $0 [font file]\n" if ($ARGV[0] eq "");
#
$font_name = $ARGV[0];
#
# if extention replace it else add it
#
($bdf_name = $font_name) =~ s/(\.\w+)?$/.bdf/;
#
open (RAW, "<$font_name") || die "Can't open raw font file $font_name: $?\n";
open (BDF, ">$bdf_name") || die "Can't open bdf font file $bdf_name: $?\n";
#
$| = 1;
#
print "Generating BDF font file $bdf_name from RAW file $font_name...\n";
#
print BDF <<"EOF";
COMMENT This font file has been generated from $font_name
COMMENT by the perl script fnt2bdf.pl for use with Holger Veit\'s co(4)
COMMENT console driver for 386bsd. This font is *not* usable
COMMENT with X-Windows.
COMMENT
COMMENT fnt2bdf.pl by Ollivier Robert (roberto@keltia.frmug.fr.net)
STARTFONT 2.1
FONT vga
SIZE 16 75 75
FONTBOUNDINGBOX 8 16 0 -4
STARTPROPERTIES 1
DEFAULT_CHAR 0
ENDPROPERTIES
CHARS 256
EOF
#
foreach $char_num (0..255)
{
read (RAW, $char, 16);
@char_val = unpack ("C" x16, $char);
printf (BDF "STARTCHAR C%04x\n", $char_num);
print BDF <<"EOF";
ENCODING $char_num
SWIDTH 666 0
DWIDTH 8 0
BBX 8 16 0 -4
BITMAP
EOF
foreach $i (@char_val)
{
printf (BDF "%02x\n", $i);
}
print BDF "ENDCHAR\n";
print "Character #$char_num\r";
}
print BDF "ENDFONT\n";
#
print "\nThe End. 256 characters processes\n";
close BDF;
close RAW;
------------------------------------------------------------
--
Ollivier ROBERT roberto@keltia.frmug.fr.net
386BSD and PERL maniac ... ...!frmug!renux!keltia!roberto
===========================================================
--
Dr. Holger Veit | INTERNET: Holger.Veit@gmd.de
| | / GMD-SET German National Research | Phone: (+49) 2241 14 2448
|__| / Center for Computer Science | Fax: (+49) 2241 14 2342
| | / P.O. Box 13 16 | Had a nightmare yesterday:
| |/ Schloss Birlinghoven | My system started up with
53731 St. Augustin, Germany | ... Booting vmunix.el ...