add shadows.. supposedly
authorDana Jansens <danakj@orodu.net>
Tue, 3 Jun 2003 20:31:03 +0000 (20:31 +0000)
committerDana Jansens <danakj@orodu.net>
Tue, 3 Jun 2003 20:31:03 +0000 (20:31 +0000)
glft/render.c

index 730e47fb2fb204a5bf9d3b91f4c9249aafd0c0ce..3590ad6a3c09937a9770b15129cf00f06aa4778a 100644 (file)
@@ -50,17 +50,12 @@ void GlftRenderGlyph(FT_Face face, struct GlftGlyph *g)
     g_free(padbuf);
 }
 
-void GlftRenderString(struct GlftFont *font, const char *str, int bytes,
-                      struct GlftColor *color, int x, int y)
+static void drawstring(struct GlftFont *font, const char *str, int bytes,
+                       struct GlftColor *color, int x, int y)
 {
     const char *c;
     struct GlftGlyph *g, *p = NULL;
 
-    if (!g_utf8_validate(str, bytes, NULL)) {
-        GlftDebug("Invalid UTF-8 in string\n");
-        return;
-    }
-
     glColor4f(color->r, color->g, color->b, color->a);
     glPushMatrix();
     glTranslatef(x, y, 0.0);
@@ -94,6 +89,29 @@ void GlftRenderString(struct GlftFont *font, const char *str, int bytes,
     glPopMatrix();
 }
 
+void GlftRenderString(struct GlftFont *font, const char *str, int bytes,
+                      struct GlftColor *color, int x, int y)
+{
+    if (!g_utf8_validate(str, bytes, NULL)) {
+        GlftDebug("Invalid UTF-8 in string\n");
+        return;
+    }
+
+    drawstring(font, str, bytes, color, x, y);
+    if (font->shadow && font->shadow_alpha != 0) {
+        struct GlftColor c;
+        if (font->shadow_alpha > 0) {
+            c.r = c.g = c.b = 0.0;
+            c.a = font->shadow_alpha;
+        } else {
+            c.r = c.g = c.b = 1.0;
+            c.a = -font->shadow_alpha;
+        }
+        drawstring(font, str, bytes, &c,
+                   x + font->shadow_offset, y + font->shadow_offset);
+    }
+}
+
 void GlftMeasureString(struct GlftFont *font,
                        const char *str,
                        int bytes,