From 1387fe0001f830f204d564311e845fdf317b0c3b Mon Sep 17 00:00:00 2001 From: Martin Mares Date: Tue, 8 Oct 2013 21:48:49 +0200 Subject: [PATCH 1/1] Experiments: Better outlining --- test.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/test.c b/test.c index dc3a3be..15fcd9f 100644 --- 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; -- 2.39.5