-#!/usr/local/bin/perl -w
+#!/usr/bin/perl -w
require 5.005;
use strict;
$fi{FontSpecificUnicodeNameToChar} = {};
$fi{filename} = $fn;
$fi{filename} =~ s/.*\///;
+ $fi{Ascender} = 0;
+ $fi{Descender} = 0;
open(FH, $fn) || die "Can't open $fn\n";
print STDERR "Reads global font info\n" if $q;
while (<FH>) {
chomp;
next if /^\s*$/ || /^\s*#/;
+ $fi{Ascender} = $1 if /^Ascender\s+(-?\d+)/;
+ $fi{Descender} = $1 if /^Descender\s+(-?\d+)/;
last if /^StartCharMetrics/;
next unless (/^(\S+)\s+(\S(.*\S)?)/);
my $id = $1;
$kerning_data_count + 2 * $highchars_count +
3 * 2 * $ligatures_count;
$info_code .= $indent1 . "{ /* $$fiR{filename} $packedSize bytes */\n";
- $info_code .= $i2 . "\"$$fiR{AfmFontName}\",";
- $info_code .= " \"$$fiR{AfmFullName}\",\n";
+ $info_code .= $i2 . "\"$$fiR{AfmFontName}\", \"$$fiR{AfmFullName}\",\n";
+ $info_code .= $i2 . $$fiR{Ascender} . ", " . $$fiR{Descender} . ",\n";
$info_code .= $i2 . $$fiR{widthsACName} . ",\n";
$info_code .= $i2 . $$fiR{kerning_indexACName} . ",\n";
$info_code .= $i2 . $$fiR{kerning_dataACName} . ",\n";
my $kerning_index = 0;
if (defined $kerningInfoR) {
my @kerns = ();
+ my $numKernings = 0;
foreach my $unicode2 (sort { $a <=> $b } keys %$kerningInfoR) {
my $delta = $$kerningInfoR{$unicode2};
+ $numKernings++;
append_escaped_16bit_int(\@kerns, $unicode2);
push(@kerns, $delta);
$had_kerning = 1;
}
- $kerning_index = append_8bit_subarray($kerning_dataA, 2, @kerns);
+ $kerning_index = append_8bit_subarray($kerning_dataA, $numKernings, @kerns);
}
append_to_array($kerning_indexA, $kerning_index);
}
sub append_8bit_subarray
{
- my ($aR, $elementsPerItem, @newElements) = @_;
+ my ($aR, $numItems, @newElements) = @_;
push(@$aR, 42) if !array_size($aR); # initial dummy value
+ die if $numItems > $#newElements + 1;
my $idx = $#{$aR} + 1;
#print "append_8bit_subarray ", ($#newElements+1), " = (", join(", ", @newElements), ") -> $idx\n";
- append_escaped_16bit_int($aR, ($#newElements + 1) / $elementsPerItem);
+ append_escaped_16bit_int($aR, $numItems);
push(@$aR, @newElements);
die "Can't handle that big sub array, sorry...\n" if $idx > 50000;
return $idx;
print CFILE ${$font_code{$_}}{TABLES} foreach @fonts;
print CFILE "const afm_fontinfo afm_fontinfolist[] = {\n";
print CFILE ${$font_code{$_}}{INFO} foreach @fonts;
- print CFILE $indent1 . "{ 0, 0, 0 }\n";
+ print CFILE $indent1 . "{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }\n";
print CFILE $indent0 . "};\n";
print CFILE $indent0 . "const int afm_fontinfo_count = ",
($#fonts + 1), ";\n";