r3940 - trunk/misc/ttf2conchars

DONOTREPLY at icculus.org DONOTREPLY at icculus.org
Sun Jul 27 05:54:22 EDT 2008


Author: div0
Date: 2008-07-27 05:54:20 -0400 (Sun, 27 Jul 2008)
New Revision: 3940

Modified:
   trunk/misc/ttf2conchars/foo.sh
   trunk/misc/ttf2conchars/ttf2conchars.c
Log:
fix some bugs :P


Modified: trunk/misc/ttf2conchars/foo.sh
===================================================================
--- trunk/misc/ttf2conchars/foo.sh	2008-07-27 09:54:04 UTC (rev 3939)
+++ trunk/misc/ttf2conchars/foo.sh	2008-07-27 09:54:20 UTC (rev 3940)
@@ -1,9 +1,14 @@
 #!/bin/sh
 
+# assumes gfx is a symlink to Nexuiz's gfx dir
+if ! [ -e "gfx/conchars.tga" ]; then
+	echo "Symlink your Nexuiz gfx dir to gfx in this folder."
+	echo "Then retry."
+	exit 1
+fi
+
 set -ex
 gcc -Wall -Wextra ttf2conchars.c `sdl-config --cflags --libs` -lSDL_ttf -lSDL_image -ggdb3
-#./a.out source.tga /home/rpolzer/.nexuiz/data/gfx/vera-sans.tga /usr/share/fonts/truetype/ttf-bitstream-vera/VeraBd.ttf /usr/share/fonts/truetype/ttf-bitstream-vera/VeraSeBd.ttf /usr/share/fonts/truetype/ttf-bitstream-vera/VeraBI.ttf 0.05 0.004 0.000000000000001
-#./a.out source.tga 0 56 /home/rpolzer/.nexuiz/data/gfx/vera-sans.tga /usr/share/fonts/truetype/ttf-bitstream-vera/VeraBd.ttf "" "" 0.05 0.004 0.000000000000001
-./a.out ~/software/games/nexuiz/data/gfx/conchars.tga 0 56 64 /home/rpolzer/.nexuiz/data/gfx/vera-sans.tga /usr/share/fonts/truetype/ttf-bitstream-vera/VeraBd.ttf "" "" 0.05 0.004 0.000000000000001
-#./a.out source.tga /home/rpolzer/.nexuiz/data/gfx/conchars.tga /usr/share/fonts/truetype/ttf-bitstream-vera/VeraMoBd.ttf /usr/share/fonts/truetype/ttf-bitstream-vera/VeraSeBd.ttf /usr/share/fonts/truetype/ttf-bitstream-vera/VeraBI.ttf 0.05 0.004 0.000000000000001
-display /home/rpolzer/.nexuiz/data/gfx/vera-sans.tga
+./a.out gfx/conchars.tga 0 56 64 gfx/vera-sans.tga /usr/share/fonts/truetype/ttf-bitstream-vera/VeraBd.ttf "" "" 0.05 0.004 0.000000000000001
+./a.out gfx/conchars.tga 0 56 64 gfx/vera-sans-big.tga /usr/share/fonts/truetype/ttf-bitstream-vera/VeraBd.ttf "" "" 0.18 0.05  0.000000000000001
+display gfx/vera-sans-big.tga

Modified: trunk/misc/ttf2conchars/ttf2conchars.c
===================================================================
--- trunk/misc/ttf2conchars/ttf2conchars.c	2008-07-27 09:54:04 UTC (rev 3939)
+++ trunk/misc/ttf2conchars/ttf2conchars.c	2008-07-27 09:54:20 UTC (rev 3940)
@@ -220,7 +220,7 @@
 {
 	unsigned char *c = (unsigned char *) c_;
 	if(!d)
-		return (*c >= 0x20 && *c <= 0x7E) || (*c >= 0xA0 && *c <= 0xFE) ? 0 : -1;
+		return ((*c >= 0x20 && *c <= 0x7E) || (*c >= 0xA0 && *c <= 0xFE)) ? 0 : -1;
 	if(*c >= 0x20 && *c <= 0x7E)
 		return 0;
 	if(*c >= 0xA0 && *c <= 0xAF)
@@ -574,17 +574,27 @@
 	{
 		fonts[0] = TTF_OpenFont(font0, currentSize);
 		if(!fonts[0])
-			errx(1, "TTF_OpenFont failed: %s", TTF_GetError());
+			errx(1, "TTF_OpenFont %s failed: %s", font0, TTF_GetError());
 
 		if(strcmp(font0, font1) || strcmp(font0, font2))
 		{
-			fonts[1] = TTF_OpenFont(font1, currentSize);
-			if(!fonts[1])
-				warnx("TTF_OpenFont failed: %s", TTF_GetError());
+			if(*font1)
+			{
+				fonts[1] = TTF_OpenFont(font1, currentSize);
+				if(!fonts[1])
+					warnx("TTF_OpenFont %s failed: %s", font1, TTF_GetError());
+			}
+			else
+				fonts[1] = NULL;
 
-			fonts[2] = TTF_OpenFont(font2, currentSize);
-			if(!fonts[2])
-				warnx("TTF_OpenFont failed: %s", TTF_GetError());
+			if(*font2)
+			{
+				fonts[2] = TTF_OpenFont(font2, currentSize);
+				if(!fonts[2])
+					warnx("TTF_OpenFont %s failed: %s", font2, TTF_GetError());
+			}
+			else
+				fonts[2] = NULL;
 
 			differentFonts = 1;
 		}
@@ -699,8 +709,8 @@
 
 			dest.x = 0;
 			dest.y = (destBottom * referenceTop - destTop * referenceBottom) / (double) (referenceTop - referenceBottom);
+			dest.h = cell * (destBottom - destTop) / (double) (referenceBottom - referenceTop);
 			dest.w = dest.h;
-			dest.h = cell * (destBottom - destTop) / (double) (referenceBottom - referenceTop);
 
 			/*
 			if(dest.y < 0)




More information about the nexuiz-commits mailing list