Home | History | Annotate | Download | only in utils
      1 #!/usr/bin/perl
      2 
      3 # convert a linux console font (8x16 format) to a font definition
      4 # suitable for processing with LibVNCServer
      5 
      6 #if($#ARGV == 0) { exit; }
      7 
      8 foreach $i (@ARGV) {
      9   $fontname = $i;
     10   $fontname =~ s/\.fnt$//;
     11   $fontname =~ s/^.*\///g;
     12   $fontname =~ y/+/_/;
     13 
     14   print STDERR "$i -> $fontname\n";
     15 
     16   open IN, "<$i";
     17   print STDERR read(IN,$x,4096);
     18   close(IN);
     19 
     20   open OUT, ">$fontname.h";
     21   print OUT "unsigned char ".$fontname."FontData[4096+1]={";
     22   for($i=0;$i<4096;$i++) {
     23     if(($i%16)==0) {
     24       print OUT "\n";
     25     }
     26     printf OUT "0x%02x,", ord(substr($x,$i));
     27   }
     28 
     29   print OUT "\n};\nint ".$fontname."FontMetaData[256*5+1]={\n";
     30   for($i=0;$i<256;$i++) {
     31     print OUT ($i*16).",8,16,0,0,";
     32   }
     33 
     34   print OUT "};\nrfbFontData ".$fontname."Font = { ".$fontname."FontData, "
     35     .$fontname."FontMetaData };\n";
     36 
     37   close OUT;
     38 }
     39