about summary refs log tree commit diff
path: root/src/engine/client
diff options
context:
space:
mode:
authorJakob Fries <jakob.fries@gmail.com>2007-06-10 17:25:08 +0000
committerJakob Fries <jakob.fries@gmail.com>2007-06-10 17:25:08 +0000
commit03422bc3c51cd4d247518e0e89d4bff8df863085 (patch)
tree59c5331f46464588a325c3e239635de0663b7d88 /src/engine/client
parentca30d750b2d4452d8e90f0039778ccc84745d0fc (diff)
downloadzcatch-03422bc3c51cd4d247518e0e89d4bff8df863085.tar.gz
zcatch-03422bc3c51cd4d247518e0e89d4bff8df863085.zip
kerning editor
Diffstat (limited to 'src/engine/client')
-rw-r--r--src/engine/client/gfx.cpp28
1 files changed, 21 insertions, 7 deletions
diff --git a/src/engine/client/gfx.cpp b/src/engine/client/gfx.cpp
index 71b5de7d..9287bfaf 100644
--- a/src/engine/client/gfx.cpp
+++ b/src/engine/client/gfx.cpp
@@ -610,6 +610,8 @@ pretty_font default_font =
 0
 };
 
+double extra_kerning[256*256] = {0};
+
 pretty_font *current_font = &default_font;
 
 void gfx_pretty_text(float x, float y, float size, const char *text)
@@ -623,8 +625,6 @@ void gfx_pretty_text(float x, float y, float size, const char *text)
 		const int c = *text;
 		const float width = current_font->m_CharEndTable[c] - current_font->m_CharStartTable[c];
 		
-		text++;
-
 		gfx_quads_setsubset(
 			(c%16)/16.0f + current_font->m_CharStartTable[c]/16.0f, // startx
 			(c/16)/16.0f, // starty
@@ -633,7 +633,13 @@ void gfx_pretty_text(float x, float y, float size, const char *text)
 
 		gfx_quads_drawTL(x, y, width * size, size);
 
-		x += (width + spacing) * size;
+		double x_nudge = 0;
+		if (text[1])
+			x_nudge = extra_kerning[text[0] + text[1] * 256];
+
+		x += (width + spacing + x_nudge) * size;
+
+		text++;
 	}
 
 	gfx_quads_end();
@@ -642,13 +648,21 @@ void gfx_pretty_text(float x, float y, float size, const char *text)
 float gfx_pretty_text_width(float size, const char *text)
 {
 	const float spacing = 0.05f;
-	float width = 0.0f;
+	float w = 0.0f;
 
 	while (*text)
 	{
-		const int c = *text++;
-		width += size * (current_font->m_CharEndTable[c] - current_font->m_CharStartTable[c] + spacing);
+		const int c = *text;
+		const float width = current_font->m_CharEndTable[c] - current_font->m_CharStartTable[c];
+
+		double x_nudge = 0;
+		if (text[1])
+			x_nudge = extra_kerning[text[0] + text[1] * 256];
+
+		w += (width + spacing + x_nudge) * size;
+
+		text++;
 	}
 
-	return width;
+	return w;
 }