]> mj.ucw.cz Git - osdd.git/commitdiff
Experiments: Better outlining
authorMartin Mares <mj@ucw.cz>
Tue, 8 Oct 2013 19:48:49 +0000 (21:48 +0200)
committerMartin Mares <mj@ucw.cz>
Tue, 8 Oct 2013 19:48:49 +0000 (21:48 +0200)
test.c

diff --git a/test.c b/test.c
index dc3a3bed1f803ae2c6876bcb9583ba385c37bc88..15fcd9fd939d18efcc17cca1e251389a1b2209ce 100644 (file)
--- a/test.c
+++ b/test.c
@@ -102,6 +102,7 @@ main(int argc, char **argv)
   osd->font = XftFontOpenName(osd->dpy, osd->screen, "times-64");
   if (!osd->font)
     die("Cannot open font");
+  DBG("Font: asc=%d desc=%d ht=%d", osd->font->ascent, osd->font->descent, osd->font->height);
 
   osd->mask_draw = XftDrawCreateBitmap(osd->dpy, osd->mask_bitmap);
   if (!osd->mask_draw)
@@ -123,12 +124,12 @@ main(int argc, char **argv)
   if (!XftColorAllocValue(osd->dpy, osd->visual, osd->cmap, &xrcm, &xfcm))
     die("XftColorAllocValue failed");
 
-  // FIXME: This is very ugly!
-  XftDrawStringUtf8(osd->mask_draw, &xfcm, osd->font, 100, 100, str, strlen((char *) str));
-  for (int off=1; off<=2; off++)
-    for (int dir=0; dir<9; dir++)
-      if (dir != 4)
-       XftDrawStringUtf8(osd->mask_draw, &xfcm, osd->font, 100 + (dir/3 - 1) * off, 100 + (dir%3 - 1) * off, str, strlen((char *) str));
+  // This is slow, but unlike the method used by libxosd, the result isn't ugly.
+  int outline = 3;
+  for (int dx = -outline; dx <= outline; dx++)
+    for (int dy = -outline; dy <= outline; dy++)
+      if (dx*dx + dy*dy <= outline*outline)
+       XftDrawStringUtf8(osd->mask_draw, &xfcm, osd->font, 100 + dx, 100 + dy, str, strlen((char *) str));
 
 #if 0
   XGlyphInfo gi;