www.pudn.com > sdk_host_2520.rar > build_font.pl


#;/////////////////////////////////////////////////////////////////////////////// 
#; Copyright(C) SigmaTel, Inc. 2000-2001 
#; 
#; Filename: build_font.pl 
#; Usage:  
#   build_font_resources.pl font_prefix [-mN] [restrictionLIst1 [restrictionList2 ...]] 
#; Description: Build font resource files, starting from glyph bitmaps. 
#               Glyph bitmaps be named like this: 
#                          some_prefix_xxxx.bmp 
#               where "some_prefix" is a unique identifer for the font, 
#               such as "arial_6" (Arial typeface, 6 pixels high) and 
#               "xxxx" is the hex Unicode value for the "default character", 
#               i.e. the glyph to be used when the desired glyph is not 
#               present in the resource. 
#               -mN sets the modulo value for the bitmap build. 
#;/////////////////////////////////////////////////////////////////////////////// 
 
 
use File::Basename; 
my $tool_dir = $0; 
my $ModuloOption=""; 
$tool_dir = (dirname $tool_dir) . "/build_font"; 
push @INC, $tool_dir; 
 
print STDERR "TOOL_DIR = $tool_dir\n"; 
print STDERR "INC = ", @INC, "\n"; 
 
require "build_font_lists.pl"; 
require "build_PGM.pl"; 
require "build_SGMs.pl"; 
require "build_scripts.pl"; 
 
 
use strict; 
 
my $argCnt = @ARGV; 
if ($argCnt < 1) { 
    die("Usage: build_font_resources.pl font_prefix  " . 
        "[-mN] [restrictionLIst1 [restrictionList2 ...]]\n"); 
} 
 
my $font_prefix = shift; 
my $default_char = 1;       #hard coded to 1 
 
if ($ARGV[0] =~ /^-/) { 
    if ($ARGV[0] =~ /^-m[0-9]+/i ) { 
 
    $ModuloOption = shift; 
    } 
    else { 
        die("Usage: build_font_resources.pl font_prefix  " . 
            "[-mN] [restrictionLIst1 [restrictionList2 ...]]\n"); 
    } 
 
} 
 
my @restrictionLists; 
if (@ARGV > 0) { 
    @restrictionLists = @ARGV; 
} 
 
use File::Basename; 
my $tool_dir = $0; 
$tool_dir = dirname $tool_dir; 
push @INC, $tool_dir; 
 
my $build_PGM = $tool_dir . "\\build_PGM.pl"; 
my $build_SGMs = $tool_dir . "\\build_SGMs.pl"; 
my $build_scripts = $tool_dir . "\\build_scripts.pl"; 
my $rsclink = "rsclink"; 
my $buildres = "buildres"; 
 
my $default_script_index; 
my $default_glyph_index; 
 
my %PGM;                               # Hash keys are Unicode range (upper byte of code point) 
                                       # Value is index (starts at zero) of SGM/Script for range,  
                                       # or undefined 
 
my %SGMs;                              # Hash keys are Unicode range (upper byte of code point) 
                                       # Value is reference (pointer) to another hash, or undefined. 
                                       # Sub-hash's keys are the lower byte of the code point. 
                                       # Value of sub-hash is glyph index (starts at zero). 
 
($default_script_index, $default_glyph_index) =  
	build_font_lists($font_prefix, @restrictionLists, \%PGM, \%SGMs, $default_char); 
 
 
print STDERR "Default char: script $default_script_index, glyph $default_glyph_index\n"; 
 
 
 
build_PGM($font_prefix, \%PGM, $default_script_index, $default_glyph_index); 
 
build_SGMs($font_prefix, \%SGMs, $default_script_index, $default_glyph_index); 
 
build_scripts($font_prefix, \%SGMs,$ModuloOption); 
 
 
print STDERR "Cleanup\n"; 
 
system "del resource.tmp"; 
system "del resource.map";