Changeset 4231


Ignore:
Timestamp:
2003-05-06T15:57:22+12:00 (21 years ago)
Author:
mdewsnip
Message:

Added special case code for generating Kazakh images, which is pretty messy. Kazakh is a superset of Russian (with 9 new letters), so none of the KOI8 encodings is suitable. Therefore, the Kazakh strings are mapped to an 8-bit encoding that matches a Kazakh font available at http://www.unesco.kz/ci/projects/greenstone/kazakh_fonts/helv_k.ttf and helv_k1.ttf (bold).

Since Russian is a subset of Kazakh, the same font and encoding can be used to produce the Russian images. However it was decided (for now) to leave the Russian images generated using the KOI8-R encoding and font, since this is a standard.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/gsdl/bin/script/translate.pl

    r4227 r4231  
    191191    # special case for russian images - fonts expect text to be koi8-r encoded
    192192    if ($language_symbol eq "ru") {
    193     $text = &unicode::unicode2koi8r(&unicode::utf82unicode($text));
     193    $text = &unicode::unicode2singlebyte(&unicode::utf82unicode($text), "koi8_r");
     194    }
     195    # special case for Kazakh images (can also handle Russian) - encode to match Kazakh font
     196    elsif ($language_symbol eq "kz") {  # || $language_symbol eq "ru") {
     197    $text = &unicode::unicode2singlebyte(&unicode::utf82unicode($text), "kazakh");
    194198    }
    195199
     
    204208    if ($language_symbol eq "ru") {
    205209        $options .= " -fontsize 10 -height 20 -whitespace -image_dir $image_dir";
    206         $options .= " -foundry cronyx -fontname helvetica";
    207     } else {
     210        $options .= " -foundry cronyx -fontname helvetica -fontweight bold";
     211    }
     212    # special case for Kazakh images (can also handle Russian)
     213    elsif ($language_symbol eq "kz") {  # || $language_symbol eq "ru") {
     214        $options .= " -fontsize 10 -height 20 -whitespace -image_dir $image_dir";
     215        $options .= " -foundry 2rebels -fontname \"helv kaz\" -fontweight bold";
     216    }
     217    else {
    208218        $options .= " -fontsize 12 -height 20 -whitespace -image_dir $image_dir";
    209219    }
     
    224234        $options .= " -foundry cronyx -fontname helvetica";
    225235    }
     236    # special case for Kazakh images (can also handle Russian)
     237    elsif ($language_symbol eq "kz") {  # || $language_symbol eq "ru") {
     238        $options .= " -foundry 2rebels -fontname \"helv kaz\"";
     239    }
    226240    `$ENV{'GSDLHOME'}/bin/script/gimp/flash_button-1.2.pl $options`;
    227241
     
    231245    # special case for russian images
    232246    if ($language_symbol eq "ru") {
    233         $options .= " -foundry cronyx -fontname helvetica";
     247            $options .= " -foundry cronyx -fontname helvetica";
     248    }
     249    # special case for Kazakh images (can also handle Russian)
     250    elsif ($language_symbol eq "kz") {  # || $language_symbol eq "ru") {
     251        $options .= " -foundry 2rebels -fontname \"helv kaz\"";
    234252    }
    235253    `$ENV{'GSDLHOME'}/bin/script/gimp/green_bar-1.2.pl $options`;
     
    239257    &process_width_macro ($fullfilename, $image_name, \$image_macros);
    240258
     259    } elsif ($image_type eq "document_button") {
     260
     261    # generate on and off images
     262    my $options = "-text \"$text\" -filenamestem $image_name";
     263    $options .= " -fixed_width -whitespace -image_dir $image_dir";
     264    # special case for russian images
     265    if ($language_symbol eq "ru") {
     266        $options .= " -fontsize 8 -foundry cronyx -fontname helvetica";
     267    }
     268    # special case for Kazakh images (can also handle Russian)
     269    elsif ($language_symbol eq "kz") {  # || $language_symbol eq "ru") {
     270        $options .= " -fontsize 8 -foundry 2rebels -fontname \"helv kaz\"";
     271    }
     272    `$ENV{'GSDLHOME'}/bin/script/gimp/flash_button-1.2.pl $options`;
     273
     274    # get width of new images and edit width macro
     275    # my $fullfilename = &util::filename_cat ($image_dir, "${image_name}on.gif");
     276    # &process_width_macro ($fullfilename, $image_name, \$image_macros);
     277
    241278    } elsif ($image_type eq "collector_bar_button") {
    242279
    243     # unescape any newline characters in the text
    244280    $text =~ s/\\n/\n/g;
     281    if ($text !~ /\n/) {
     282        # Format the text so it is centered, one word per line
     283        local @textparts = split(/[ \t\n]+/, $text);
     284        local $maxlength = 0;
     285        for ($i = 0; $i < scalar(@textparts); $i++) {
     286        if (length($textparts[$i]) > $maxlength) {
     287            $maxlength = length($textparts[$i]);
     288        }
     289        }
     290        $text = "";
     291        for ($i = 0; $i < scalar(@textparts); $i++) {
     292        if (length($textparts[$i]) < $maxlength) {
     293            $text .= ' ' x ((($maxlength - length($textparts[$i])) / 2) + 1);
     294        }
     295        $text .= $textparts[$i] . "\n";
     296        }
     297    }
    245298
    246299    # generate on and off images (yellow)
     
    250303    if ($language_symbol eq "ru") {
    251304        $options .= " -foundry cronyx -fontname helvetica";
     305    }
     306    # special case for Kazakh images (can also handle Russian)
     307    elsif ($language_symbol eq "kz") {  # || $language_symbol eq "ru") {
     308        $options .= " -foundry 2rebels -fontname \"helv kaz\"";
    252309    }
    253310    `$ENV{'GSDLHOME'}/bin/script/gimp/flash_button-1.2.pl $options`;
     
    261318        $options .= " -foundry cronyx -fontname helvetica";
    262319    }
     320    # special case for Kazakh images (can also handle Russian)
     321    elsif ($language_symbol eq "kz") {  # || $language_symbol eq "ru") {
     322        $options .= " -foundry 2rebels -fontname \"helv kaz\"";
     323    }
    263324    `$ENV{'GSDLHOME'}/bin/script/gimp/flash_button-1.2.pl $options`;
    264325
     
    271332        $options .= " -foundry cronyx -fontname helvetica";
    272333    }
    273     `$ENV{'GSDLHOME'}/bin/script/gimp/flash_button-1.2.pl $options`;
    274 
     334    # special case for Kazakh images (can also handle Russian)
     335    elsif ($language_symbol eq "kz") {  # || $language_symbol eq "ru") {
     336        $options .= " -foundry 2rebels -fontname \"helv kaz\"";
     337    }
     338    `$ENV{'GSDLHOME'}/bin/script/gimp/flash_button-1.2.pl $options`;
    275339    # delete the unused dark image
    276     if (-e util::filename_cat($image_dir, "nc$image_name" . "on.gif")) {
    277         unlink(util::filename_cat($image_dir, "nc$image_name" . "on.gif"));
    278     }
    279 
    280     } elsif ($image_type eq "document_button") {
    281 
    282     # generate on and off images
    283     my $options = "-text \"$text\" -filenamestem $image_name";
    284     $options .= " -fixed_width -whitespace -image_dir $image_dir";
    285     if ($language_symbol eq "ru") {
    286         $options .= " -fontsize 8 -foundry cronyx -fontname helvetica";
    287     }
    288     `$ENV{'GSDLHOME'}/bin/script/gimp/flash_button-1.2.pl $options`;
    289 
    290     # get width of new images and edit width macro
    291     # my $fullfilename = &util::filename_cat ($image_dir, "${image_name}on.gif");
    292     # &process_width_macro ($fullfilename, $image_name, \$image_macros);
     340    unlink(util::filename_cat($image_dir, "nc$image_name" . "on.gif"));
    293341
    294342    } elsif ($image_type eq "green_bar_left_aligned") {
     
    298346    my $options = "-text \"$text\" -filename ${image_name}.gif -dont_center";
    299347    $options .= " -width 537 -width_space 15 -image_dir $image_dir";
    300     if ($language_symbol eq "ru") {
    301         $options .= " -foundry cronyx -fontname helvetica";
     348    # special case for russian images
     349    if ($language_symbol eq "ru") {
     350        $options .= " -foundry cronyx -fontname helvetica";
     351    }
     352    # special case for Kazakh images (can also handle Russian)
     353    elsif ($language_symbol eq "kz") {  # || $language_symbol eq "ru") {
     354        $options .= " -foundry 2rebels -fontname \"helv kaz\"";
    302355    }
    303356    `$ENV{'GSDLHOME'}/bin/script/gimp/green_bar-1.2.pl $options`;
     
    316369    if ($language_symbol eq "ru") {
    317370        $options .= " -foundry cronyx -fontname helvetica";
     371    }
     372    # special case for Kazakh images (can also handle Russian)
     373    elsif ($language_symbol eq "kz") {  # || $language_symbol eq "ru") {
     374        $options .= " -foundry 2rebels -fontname \"helv kaz\"";
    318375    }
    319376    `$ENV{'GSDLHOME'}/bin/script/gimp/title_icon-1.2.pl $options`;
Note: See TracChangeset for help on using the changeset viewer.