unifont-7.0.06.tar.gz
[unifont.git] / src / unipng2hex
index e69481266909de535c1bea5c4a2de1e6f19d4bfe..4519b64cb6936dea1a377c5a8ce428ffc3517878 100755 (executable)
@@ -37,7 +37,7 @@ $result = GetOptions (
 );
 
 if ($opt_help) {
-       print << "END";
+       print << "END" or die ("Cannot print to stdout.\n");
 
 Turn a .png glyph matrix into a GNU Unifont hex glyph set of 256 characters
 
@@ -70,7 +70,7 @@ if (not $input) {
 #}
 
 GD::Image->trueColor (1);
-$im = new GD::Image ("$input") or die ("Cannot open image\n");
+$im = new GD::Image ("$input") or die ("Cannot open image.\n");
 
 if ($im->isTrueColor ()) {
        $im->trueColorToPalette ();
@@ -107,9 +107,15 @@ if ($boxsize == 32) {
                $charheight = 16;
                $charmaxwidth = 3;
        } elsif ($im->rgb ($pixel) == ($white_red, $white_green, $white_blue)) {
-               $charyoffset = 4;
-               $charheight = 24;
+               $charyoffset = 7;
+               $charheight = 16;
                $charmaxwidth = 3;
+#
+#              Use the settings below for a height of 24 pixels in the future;
+#              for now, hard code glyph height to 16 pixels.
+#              $charyoffset = 4;
+#              $charheight = 24;
+#              $charmaxwidth = 3;
        } else {
                die ("Cannot determine font height\n")
        }
@@ -179,7 +185,7 @@ $codepoint = ($codepoint << 4);
 $display_width = $codepoint > 0xFFFF ? 6 : 4;
 
 if ($output) {
-       open (HEXFILE, ">$output") or die ("Cannot save file\n");
+       open (HEXFILE, ">$output") or die ("Cannot save hex file.\n");
 } else {
        *HEXFILE = *STDOUT;
 }
@@ -220,7 +226,7 @@ for ($col = 0; $col < 16; $col++) {
                                $char = $char . sprintf ("%0*X", $charwidth * 2, $line);
                        }
 
-                       print HEXFILE "$char\n";
+                       print HEXFILE "$char\n" or die ("Cannot print to hex file.\n");
                }
 
                $codepoint += 1;
@@ -229,5 +235,5 @@ for ($col = 0; $col < 16; $col++) {
 
 # Only close HEXFILE if it isn't mapped to STDOUT.
 if ($output) {
-       close HEXFILE;
+       close HEXFILE or die ("Cannot properly close hex file.\n");
 }