www.pudn.com > sdk_host_2520.rar > build_sgms.pl
# build_SGMs.pl
# Builds the Secondary Glyph Maps resource (prefix_SGMs.src)
#
# The "PGM_list" and "SGM_list_xx" files must already exist.
# Also, the files, "build_all_SGMs.bat" and "SGMs.inc".
#
# "prefix" is the font identifier, used to name the output file
# (e.g. "arial_6").
#
# This batch file creates a number of intermediate files (SGM_xx.src,
# SGM.inc, SGM.bin, SGMs_xx.src, SGMs.inc, and prefix_SGMs.bin). It
# will delete them, at the end, if nothing goes wrong. It it fails,
# you'll have to delete them by hand.
use strict;
use File::Basename;
sub build_SGMs { # ($prefix, \%SGMs, $def_script_idx, $def_glyph_idx)
my $font_prefix = shift;
my $pSGMs = shift;
my $default_script_index = shift;
my $default_glyph_index = shift;
my $filename;
print STDERR "Creating the individual SGM resources\n";
open SGMs_INC_FILE, ">SGMs.inc" || die "Can't open file: SGMs.inc\n";
my $SGMs_index = 0;
my $highByte;
for ($highByte=0; $highByte<256; $highByte++) {
if (defined($pSGMs->{$highByte})) {
# Create SGM_$highByte file
$filename = sprintf("SGM_%02x.src", $highByte);
build_SGM_src($filename, $pSGMs->{$highByte}, $SGMs_index, $default_script_index,
$default_glyph_index);
# and add entry to SGMs.inc
printf SGMs_INC_FILE "SGM_%02x\tequ\t%d\t;\$FILENAME SGM_%02x.src\n",
$highByte, 1 + $SGMs_index, $highByte;
$SGMs_index++;
}
}
close SGMs_INC_FILE;
print STDERR "Combining SGM entries into resource file\n";
(system "rsclink -d -hSGMs.inc -o$font_prefix\_SGMs.bin") == 0 || die "ERROR-SGMs: rsclink failed";
print STDERR "Converting resource file to nested resource\n";
(system "buildres -r$font_prefix\_SGMs.bin") == 0 || die "ERROR-SGMs: buildres failed";
print STDERR "build_SGMs: Cleaning up\n";
system "del SGM_*.src";
system "del $font_prefix\_SGMs.asm";
system "del SGMs.inc";
system "del $font_prefix\_SGMs.bin";
}
1;