Fork us on GitHub Follow us on Facebook Follow us on Twitter

Changeset 98895c5c in mainline for contrib/font/bdf2c.pl


Ignore:
Timestamp:
2009-03-24T16:09:17Z (13 years ago)
Author:
Martin Decky <martin@…>
Branches:
lfn, master, serial
Children:
2fce275
Parents:
6a75902c
Message:

simplify glyph mapping function
draw invalid glyphs with a distinctive color

File:
1 edited

Legend:

Unmodified
Added
Removed
  • contrib/font/bdf2c.pl

    r6a75902c r98895c5c  
    102102@chars = sort { $a <=> $b } (@chars);
    103103
    104 print "#define FONT_GLYPHS     " . @chars . "\n";
     104print "#define FONT_GLYPHS     " . (@chars + 1). "\n";
    105105print "#define FONT_SCANLINES  " . $height . "\n";
    106106
    107107print "\n";
    108108print "index_t fb_font_glyph(const wchar_t ch)\n";
    109 print "{";
     109print "{\n";
     110print "\tif (ch == 0x0000)\n";
     111print "\t\treturn 0;\n\n";
    110112
    111113my $pos = 0;
     
    118120                        if ($start == $prev) {
    119121                                printf "\tif (ch == 0x%.4x)\n", $start;
     122                                print "\t\treturn " . $start_pos . ";\n";
    120123                        } else {
    121124                                printf "\tif ((ch >= 0x%.4x) && (ch <= 0x%.4x))\n", $start, $prev;
     125                                print "\t\treturn (ch - " . ($start - $start_pos) . ");\n";
    122126                        }
    123127                       
    124                         print "\t\treturn (ch - " . ($start - $start_pos) . ");\n";
    125128                        print "\t\n";
    126129                }
     
    129132                $start_pos = $pos;
    130133        }
     134       
    131135        $pos++;
    132136        $prev = $index;
    133137}
    134138
    135 print "\treturn 31;\n";
     139print "\treturn " . @chars . ";\n";
    136140print "}\n";
    137141
     
    139143print "uint8_t fb_font[FONT_GLYPHS][FONT_SCANLINES] = {";
    140144
    141 my $f1 = 0;
    142145for $index (@chars) {
    143         print "," if ($f1 > 0);
    144146        print "\n\t{";
    145147       
     
    150152        }
    151153       
    152         print "}";
    153         $f1++;
     154        print "},";
    154155}
    155156
    156 print "\n};\n";
     157print "\n\t\n\t/* Special glyph for unknown character */\n\t{";
     158my $y;
     159for ($y = 0; $y < $height; $y++) {
     160        print ", " if ($y > 0);
     161        printf "0x%.2x", $glyphs[63]->[$y];
     162}
     163
     164print "}\n};\n";
Note: See TracChangeset for help on using the changeset viewer.