layout/reftests/fonts/generate-bitpattern-font.pl

Wed, 31 Dec 2014 06:55:50 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:55:50 +0100
changeset 2
7e26c7da4463
permissions
-rw-r--r--

Added tag UPSTREAM_283F7C6 for changeset ca08bd8f51b2

     1 #!/usr/bin/perl -w
     3 # Generates an SVG Font where each glyph (identified on stdin by four
     4 # hex characters) consists of a bit pattern representing the Unicode
     5 # code point it is the glyph for.
     7 use strict;
     9 print <<EOF;
    10 <svg xmlns="http://www.w3.org/2000/svg">
    11 <font id="BitPattern" horiz-adv-x="1000">
    12   <font-face font-family="BitPattern" units-per-em="1000" ascent="800"/>
    13 EOF
    15 while (<>) {
    16   chomp;
    17   next if /^\s*$/;
    18   die unless /^[0-9A-Fa-f]{4}$/;
    19   my $c = hex;
    20   my $s = "  <glyph unicode='&#x$_;' d='";
    21   for (my $i = 0; $i < 32; $i++) {
    22     if ($c & (1 << $i)) {
    23       my $x = 100 * (7 - ($i % 8));
    24       my $y = 100 * int($i / 8);
    25       $s .= "M$x,$y v80h80v-80z ";
    26     }
    27   }
    28   $s .= "'/>\n";
    29   print $s;
    30 }
    32 print <<EOF;
    33 </font>
    34 </svg>
    35 EOF

mercurial