about summary refs log tree commit diff
path: root/src/engine/client/ec_gfx.c
diff options
context:
space:
mode:
authorJakob Fries <jakob.fries@gmail.com>2007-12-24 13:09:34 +0000
committerJakob Fries <jakob.fries@gmail.com>2007-12-24 13:09:34 +0000
commita02611511c1704c653e5951a44b294a953cdb470 (patch)
treeadf7232a41d0bd1133b82f8aea952af80a3f53be /src/engine/client/ec_gfx.c
parent1ddfbba3666a835b59fc79b59aaae367ee93a6ea (diff)
downloadzcatch-a02611511c1704c653e5951a44b294a953cdb470.tar.gz
zcatch-a02611511c1704c653e5951a44b294a953cdb470.zip
more font stuffs
Diffstat (limited to 'src/engine/client/ec_gfx.c')
-rw-r--r--src/engine/client/ec_gfx.c40
1 files changed, 38 insertions, 2 deletions
diff --git a/src/engine/client/ec_gfx.c b/src/engine/client/ec_gfx.c
index d93d07df..106226a4 100644
--- a/src/engine/client/ec_gfx.c
+++ b/src/engine/client/ec_gfx.c
@@ -12,6 +12,8 @@
 #include <stdio.h>
 #include <math.h>
 
+#include "ec_font.h"
+
 /* compressed textures */
 #define GL_COMPRESSED_RGB_ARB 0x84ED
 #define GL_COMPRESSED_RGBA_ARB 0x84EE
@@ -882,13 +884,47 @@ static int word_length(const char *text)
 	}
 }
 
-
-
 static float pretty_r=1;
 static float pretty_g=1;
 static float pretty_b=1;
 static float pretty_a=1;
 
+void gfx_text(void *font_set_v, float x, float y, const char *text, float size)
+{
+    const unsigned char *c = (unsigned char *)text;
+
+    FONT_SET *font_set = font_set_v;
+    FONT *font = font_set_pick(font_set, size);
+
+    gfx_texture_set(font->texture);
+
+	gfx_quads_begin();
+	gfx_setcolor(pretty_r, pretty_g, pretty_b, pretty_a);
+    
+    while (*c)
+    {
+        float tex_x0, tex_y0, tex_x1, tex_y1;
+        float width, height;
+        float x_offset, y_offset, x_advance;
+
+        float advance;
+
+        font_character_info(font, *c, &tex_x0, &tex_y0, &tex_x1, &tex_y1, &width, &height, &x_offset, &y_offset, &x_advance);
+
+		gfx_quads_setsubset(tex_x0, tex_y0, tex_x1, tex_y1);
+
+		gfx_quads_drawTL(x+x_offset*size, y+y_offset*size, width*size, height*size);
+
+        advance = x_advance + font_kerning(font, *c, *(c+1));
+
+        x += advance*size;
+
+        c++;
+    }
+
+	gfx_quads_end();
+}
+
 void gfx_pretty_text_color(float r, float g, float b, float a)
 {
 	pretty_r = r;