File: 026_unifont2

package info (click to toggle)
libpdf-builder-perl 3.027-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 23,992 kB
  • sloc: perl: 107,532; makefile: 10
file content (95 lines) | stat: -rw-r--r-- 2,899 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
#!/usr/bin/perl

# Display a selection of Unicode character pages in various fonts. 9 pages.
# Note that this is not strictly Unicode, especially in 00-FF, but closer
#   to MS CP-1252.
 
use strict;
use warnings;

use File::Basename;
use PDF::Builder;
use PDF::Builder::Util;
use Unicode::UCD 'charinfo';
use Encode qw[:all];
use Getopt::Long;
use utf8;

#my $compress = 'none'; # uncompress streams
my $compress = 'flate'; # compressed streams

my $api = PDF::Builder->new(-compress => $compress);

$api->mediabox(595,842);

my $helv = $api->corefont('Helvetica-Bold', -encode=>'latin1');
my $ge = $api->corefont('Times-Roman', -encode=>'latin1');
my $g2 = $api->corefont('Times-Roman', -encode=>'uni1');
my $g3 = $api->corefont('Times-Roman', -encode=>'uni2');
my $g4 = $api->corefont('Times-Roman', -encode=>'uni3');
my $g5 = $api->corefont('Times-Roman', -encode=>'uni4');
my $g6 = $api->corefont('Times-Roman', -encode=>'uni5');
my $zf = $api->corefont('zapfdingbats');
my $wd = $api->corefont('wingdings');

my $sx = 33;
my $sy = 45;
my $fx = 20;

my ($uf);

my @label = ();
$label[   0] = '0000 - 00FF Basic Latin (ASCII) and Latin-1';
$label[   1] = '0100 - 01FF Latin Extended-A and part of -B';
$label[   2] = '0200 - 02FF rem. Latin Ext-B, IPA, Spacing Modifiers';
$label[   3] = '0300 - 03FF Comb. diacriticals, Greek and Coptic';
$label[   4] = '0400 - 04FF Cyrillic';
$label[   5] = '0500 - 05FF Cyrillic supplementary, Armenian, Hebrew';
$label[0x26] = '2600 - 26FF Miscellaneous Symbols';
$label[0x27] = '2700 - 27FF Dingbats';
$label[0xf0] = 'F000 - F0FF (Private Use, shiftJIS encoded)';
	
$uf = $api->unifont(
    $ge,
    [$g2, [1]],
    [$g3, [2]],
    [$g4, [3]],
    [$g5, [4]],
    [$g6, [5]],
    [$zf, [0x26,0x27]],
    [$wd, [0xf0]], -encode=>'shiftjis');

my $toprow = 50 + $sy*15;
my $leftcol = 50;

# block is starting offset in Unicode (block of 256 characters)
foreach my $block (0,1,2,3,4,5,0x26,0x27,0xf0) {
    print STDERR ".";  # one page being output

    my $page = $api->page();
    $page->mediabox(595,842);

    my $gfx = $page->gfx();
    delete $gfx->{'Filter'};
    my $text = $page->text();
    
    # label page
    $text->textlabel($leftcol, 50+$toprow, $helv, 20, $label[$block]);

    # character is Unicode $block*256 + $y*16 + $x (0..255), arranged in grid
    # 00 at upper left to FF in lower right
    foreach my $y (0..15) {      # row T to B
        foreach my $x (0..15) {  # column L to R
	    # character (no bounding box)
            $text->textlabel($leftcol+($sx*$x), $toprow-($sy*$y), $uf, $fx, pack('U',$block*256+$y*16+$x));
	    # label (Unicode name) below, at a slant to fit horizontally
            $text->textlabel($leftcol+($sx*$x), $toprow-($sy*$y)-6, $helv, 6, nameByUni($block*256+$y*16+$x), -color=>'#a00000', -hscale=>80, -rotate=>-15);
        }
    }
}

$api->saveas("$0.pdf");
$api->end();
print STDERR "\n";

__END__