10
fop-ttc-metrics.pl - script to handle TrueType font Collections.
14
fop-ttc-metrics.pl <options>
18
--help Display help message
19
--man Display the man page
20
--outdir Change the output directory for the metric xml files
21
--share Change the share directory where publican common files
26
FOP <= 0.95 can not automatically generate metrics for true Type collections so
27
Publican must generate them at build time.
29
This script will look for known ttc files and generate metrics if they are found.
30
This requires the packaging system to Require the ttc font packages as build and
37
my $outdir = 'font-metrics';
38
my $share = '/usr/share/publican';
39
my $conf_file = 'datadir/fop/fop.xconf';
44
'outdir|d=s' => \$outdir,
46
'conffile=s' => \$conf_file,
48
pod2usage(1) if $help;
49
pod2usage( -verbose => 2 ) if $man;
51
# FYI you also need to add the font names to template pickfont in datadir/xsl/pdf.xsl
54
path => '/usr/share/fonts/cjkuni-uming/uming.ttc',
55
style => [ 'normal', 'italic' ],
56
weight => [ 'normal', 'bold' ],
59
path => '/usr/share/fonts/cjkuni-uming/uming.ttc',
60
style => [ 'normal', 'italic' ],
61
weight => [ 'normal', 'bold' ],
66
= 'java -cp /usr/share/java/fop.jar:/usr/share/java/avalon-framework.jar:/usr/share/java/commons-logging.jar:/usr/share/java/commons-io.jar:/usr/share/java/xmlgraphics-commons.jar org.apache.fop.fonts.apps.TTFReader';
68
open( my $conf, '>', $conf_file )
69
|| croak("Can't open fop.xconf for output!: $!");
73
system("mkdir -p $outdir");
74
croak("can't create metric dir: $!") if ($@);
76
foreach my $font ( sort( keys(%ttclist) ) ) {
77
my $path = $ttclist{$font}{path};
78
my $spaces_break_stupid_os = $font;
79
$spaces_break_stupid_os =~ s/\s/_/g;
80
my $url = qq{$share/fop/font-metrics/$spaces_break_stupid_os.xml};
84
= qq{$ttfcommand -fn "$font" -ttcname "$font" $path $outdir/$spaces_break_stupid_os.xml};
85
print STDERR $command;
86
my $result = system($command );
87
croak("FAILED to create font metric for $font: $!")
90
qq{\t\t\t\t<font metrics-url="$url" kerning="yes" embed-url="$path">\n};
91
foreach my $style ( @{ $ttclist{$font}{style} } ) {
92
foreach my $weight ( @{ $ttclist{$font}{weight} } ) {
94
qq{\t\t\t\t\t<font-triplet name="$font" style="$style" weight="$weight"/>\n};
97
print {$conf} qq{\t\t\t\t</font>\n};
103
<?xml version="1.0"?>
106
\t<source-resolution>72</source-resolution>
107
\t<target-resolution>72</target-resolution>
108
\t<default-page-settings height="240mm" width="120mm"/>
110
\t\t<renderer mime="application/pdf">
112
\t\t\t\t<value>flate</value>
119
print {$conf} <<BOTTOM;
120
\t\t\t\t<auto-detect/>