Commits

Anonymous committed f76be78

- sync to 1.8.1

Comments (0)

Files changed (1)

 # at Faculty of Informatics, Masaryk University in Brno, Czech Republic.
 #
 # Example of use:
-# fstobdf -s fontserverhost:7100 -fn 8x16 | ~/perl/bdftogd FontLarge gdfontl
+# fstobdf -s fontserverhost:7100 -fn 8x16 | ./bdftogd FontLarge gdfontl
 #
 
 use strict;
 
-my $VERSION = '0.51';
+my $VERSION = '0.60';
 my $now = localtime;
 
 if (@ARGV != 2)
 my (@data, @left, @bottom);
 my ($globalleft, $globaltop);
 
+my ($minchar, $maxchar);
+
 my ($copyright, $fontdef);
 
 my $currentchar;
 while (<>)
 	{
 	chomp;
+	s/\r$//;
 	my ($tag, $value) = split / /, $_, 2;
 	die "Font is not fixed width\n"
 			if $tag eq 'SPACING' and not $value =~ /[CM]/i;
 	
 	$currentchar = $value if $tag eq 'ENCODING';
+	$minchar = $currentchar if not defined $minchar
+		or $currentchar < $minchar;
+	$maxchar = $currentchar if not defined $maxchar
+		or $currentchar > $maxchar;
 	
 	if ($tag eq 'ENDCHAR')
 		{
 		$gobitmap = 0;
 		my $bottom = $globaltop - $bottom[$currentchar];
 		
+
 		if ($bottom > 0)
-			{ $data[$currentchar] = substr $data[$currentchar], 0, length $data[$currentchar] - $bottom * $width; }
+			{ $data[$currentchar] = substr $data[$currentchar], 0, length($data[$currentchar]) - $bottom * $width; }
 		else
 			{ $data[$currentchar] .= '0' x (-$bottom * $width); }
 		}
 char ${gdname}Data[] = {
 EOF
 
-my ($i);
-for $i (0 .. 255)
+$minchar = 0 unless defined $minchar;
+$maxchar = 255 unless defined $maxchar;
+for (my $i = $minchar; $i <= $maxchar; $i++)
 	{
 	$data[$i] = '' unless defined $data[$i];
 	$data[$i] = '0' x ($width * $height - length $data[$i]) . $data[$i];
 	
 	print FILEC "/* Char $i */\n";
-	my ($line);
-	for $line (0 .. $height - 1)
+	for my $line (0 .. $height - 1)
 		{ print FILEC join ',', split(//, substr($data[$i], $line * $width, $width)), "\n"; }
 
 	print FILEC "\n";
 };
 
 gdFont ${gdname}Rep = {
-	256,
-	0,
+	@{[ $maxchar - $minchar + 1]},
+	$minchar,
 	$width,
 	$height,
 	${gdname}Data
 #ifndef $capdef
 #define $capdef 1
 
-#ifdef __cplusplus
-extern "C" {
-#endif
-
 $info
 
 #include "gd.h"
 
 extern gdFontPtr $gdname;
 
-#ifdef __cplusplus
-}
-#endif
-
 #endif
 
 EOF
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.