#!/usr/bin/perl
$descent=100;
$ascent=800-$descent;
print << "END";
SplineFontDB: 1.0
FontName: unifont
FullName: LGM Unifont
FamilyName: unifont
Weight: Medium
Copyright: Created by Luis Gonzalez Miranda from GNU Unifont with FontForge 1.0 (http://fontforge.sf.net)
Comments: 2005-10-27: Created.
Version: 001.000
ItalicAngle: 0
UnderlinePosition: -100
UnderlineWidth: 40
Ascent: $ascent
Descent: $descent
NeedsXUIDChange: 1
XUID: [1021 140 1293607838 5610107]
FSType: 0
PfmFamily: 33
TTFWeight: 500
TTFWidth: 5
Panose: 2 0 6 4 0 0 0 0 0 0
LineGap: 72
VLineGap: 0
OS2WinAscent: 0
OS2WinAOffset: 1
OS2WinDescent: 0
OS2WinDOffset: 1
HheadAscent: 0
HheadAOffset: 1
HheadDescent: 0
HheadDOffset: 1
ScriptLang: 1
 1 latn 1 dflt 
Encoding: UnicodeBmp
UnicodeInterp: none
DisplaySize: -24
AntiAlias: 1
FitToEm: 1
WinInfo: 0 50 22
TeXData: 1 0 0 346030 173015 115343 0 1048576 115343 783286 444596 497025 792723 393216 433062 380633 303038 157286 324010 404750 52429 2506097 1059062 262144
BeginChars: 65536 3
END
$count=0;
while(<STDIN>) {
	chomp;
	($c,$d)=split(/:/);
	$width=length($d)/4;
	$ptwidth=50*$width;
	$cn=hex($c);
	print << "END";
StartChar: $c
Encoding: $cn $cn $count
Width: $ptwidth
Flags: H
TeX: 0 0 0 0
Fore
END

	for($i=0;$i<16;$i++) {
		$l=substr($d,$i*$width/4,$width/4);
		$num=hex($l);
		$prev=0;
		for($j=0;$j<$width;$j++) {
			$x=$width-1-$j;
			$y=15-$i;
			if($num%2) {
				# point at i, width-1-j
				if(!$prev) {
					$x1=$x*50+50;
					$y1=$y*50-$descent;
					$x2=$x1+50;
					$y2=$y1+50;
				}
				$prev=1;
			} else {
				if($prev) {
					$x2=$x*50+50;
					print << "END";
$x1 $y1 m 25
 $x1 $y2 l 25
 $x2 $y2 l 25
 $x2 $y1 l 25
 $x1 $y1 l 25
END
				}
				$prev=0;
			}
			$num=int($num/2);
		}
		if($prev) {
			$x2=0;
			print << "END";
$x1 $y1 m 25
 $x1 $y2 l 25
 $x2 $y2 l 25
 $x2 $y1 l 25
 $x1 $y1 l 25
END
		}
	}
	print << "END";
EndSplineSet
EndChar
END
	$count++;
}
print << "END";
EndChars
EndSplineFont
END
