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

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

mercurial