• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!/usr/bin/perl
2
3@encodings=();
4for($i=0;$i<256*5;$i++) {
5  $encodings[$i]="0";
6}
7
8$out="";
9$counter=0;
10$fontname="default";
11
12$i=0;
13$searchfor="";
14$nullx="0x";
15
16while(<>) {
17  if(/^FONT (.*)$/) {
18    $fontname=$1;
19    $fontname=~y/\"//d;
20  } elsif(/^ENCODING (.*)$/) {
21    $glyphindex=$1;
22    $searchfor="BBX";
23    $dwidth=0;
24  } elsif(/^DWIDTH (.*) (.*)/) {
25    $dwidth=$1;
26  } elsif(/^BBX (.*) (.*) (.*) (.*)$/) {
27    ($width,$height,$x,$y)=($1,$2,$3,$4);
28    @encodings[$glyphindex*5..($glyphindex*5+4)]=($counter,$width,$height,$x,$y);
29    if($dwidth != 0) {
30      $encodings[$glyphindex*5+1]=$dwidth;
31    } else {
32      $dwidth=$width;
33    }
34    $searchfor="BITMAP";
35  } elsif(/^BITMAP/) {
36    $i=1;
37  } elsif($i>0) {
38    if($i>$height) {
39      $i=0;
40      $out.=" /* $glyphindex */\n";
41    } else {
42      if(int(($dwidth+7)/8) > int(($width+7)/8)) {
43	$_ .= "00"x(int(($dwidth+7)/8)-int(($width+7)/8));
44      }
45      $_=substr($_,0,(int(($dwidth+7)/8)*2));
46      $counter+=(int(($dwidth+7)/8));
47      s/(..)/$nullx$1,/g;
48      $out.=$_;
49      $i++;
50    }
51  }
52}
53
54print "unsigned char " . $fontname . "FontData[$counter]={\n" . $out;
55print "};\nint " . $fontname . "FontMetaData[256*5]={\n";
56for($i=0;$i<256*5;$i++) {
57  print $encodings[$i] . ",";
58}
59print "};\nrfbFontData " . $fontname . "Font={" .
60  $fontname . "FontData, " . $fontname . "FontMetaData};\n";
61