Subject: Font shadow "flooding"?

From: Dominik Vogt <[email-masked]>
Date: Thu, 18 Jul 2002 15:22:20 +0200

I'm still loking for a reliable way to get a good contrast between
text and a random background picture.  The best I've come up with
yet is:

  colorset 27 transparent, fg white, fgsh black
  menustyle * menucolorset 27
  menustyle * font "Shadow=1 n s e w nw ne sw se:lucidasanstypewriter-14"

A black halo is drawn around the the white text.  But the halo is
still too thin to give a good contrast.  If it were possible to
extend the halo to a size of 2 it would be much more readable.
Look at this:

  .......
  .......
  .......
  ...x...
  .......
  .......
  .......

The X in the center marks the upper left pixel of the text.  The
shadow (size 1) is drawn eight times at these offsets:

  .......
  .......
  ..ooo..
  ..o.o..
  ..ooo..
  .......
  .......

With size 2 it is drawn like this:

  .......
  .o.o.o.
  ..ooo..
  .oo.oo.
  ..ooo..
  .o.o.o.
  .......

But I need this:

  .......
  .ooooo.
  .ooooo.
  .oo.oo.
  .ooooo.
  .ooooo.
  .......

Any chance you get around to implement something like this,
Olivier?  All that would be needed is another "direction" option
"center" and a loop drawing the shadows:

  for (x = -size; x <= size; x++)
  {
    for (y = -size; y <= size; y++)
    {
      if (x < -offset || x > offset || y < -offset || y > offset)
      {
        draw_shadow_at(x, y);
      }
    }
  }

Bye

Dominik ^_^  ^_^

 --
Dominik Vogt, mail: [email-masked], phone: 0721/91374-382
Schlund + Partner AG, Erbprinzenstr. 4-12, D-76133 Karlsruhe
--
Visit the official FVWM web page at <URL:http://www.fvwm.org/>.
To unsubscribe from the list, send "unsubscribe fvwm-workers" in the
body of a message to [email-masked].
To report problems, send mail to [email-masked]

---

From: Dominik Vogt <[email-masked]>
Date: Sat, 20 Jul 2002 00:47:45 +0200

> extend the halo to a size of 2 it would be much more readable.
[snip]

I have implemented this.  Try the following with a colourful
background image:

  colorset 27 transparent, fg white, fgsh black
  menustyle * menucolorset 27
  menustyle * font "Shadow=3 c:lucidasanstypewriter-14"

Bye

Dominik ^_^  ^_^

 --
Dominik Vogt, [email-masked]
Reply-To: [email-masked]
--
Visit the official FVWM web page at <URL:http://www.fvwm.org/>.
To unsubscribe from the list, send "unsubscribe fvwm-workers" in the
body of a message to [email-masked].
To report problems, send mail to [email-masked]

---

From: Mikhael Goikhman <[email-masked]>
Date: Sat, 20 Jul 2002 05:57:23 +0000

> extend the halo to a size of 2 it would be much more readable.

I postponed this reply, and now it seems to be too late. Anyway, I am
posting it, because I think it is a more general solution than the special
"center" direction (by the way we already have "all", do we need both?).

Some time ago I wrote that I would disable shade size greater than 1 with
more then one direction (i.e. force size 1 if there are more than 1
direction), because it looks unnaturally bad.

I think there may be added support for sizes 2+ with multiple directions
using this simple algorithm. If the current 8 directions are encoded using
one bit per direction, bits 12346 currently produce ugly:

  .......   .......   o..o..o
  .......   .o.o.o.   .o.o.o.
  ..ooo..   ..ooo..   ..ooo..
  ...xo..   ...xoo.   ...xooo
  ...o...   ...o...   ...o...
  .......   ...o...   ...o...
  .......   .......   ...o...

But they may produce instead a bit more natural:

  .......   .......   ooooooo
  .......   .ooooo.   .oooooo
  ..ooo..   ..oooo.   ..ooooo
  ...xo..   ...xoo.   ...xooo
  ...o...   ...o...   ...o...
  .......   ...o...   ...o...
  .......   .......   ...o...

For each of 8 pairs of bits (i, i+1), if both are set then in addition to
2 shadow pixels drawn in each iteraction, all pixels between them are
drawn too. If size=N and offset=0 this is N-1 additional line pixels.

This may also get rid of this diagonal problem (when specifying "r br").

    "br"     (old)     (new)
  .......   .......   .......
  ....x..   ....xoo   ....xoo
  ...x.o.   ...xooo   ...xooo
  ..x.o.o   ..xoo.o   ..xoooo
  ...o.o.   ...o.o.   ...ooo.
  ....o..   ....o..   ....o..

So all three "n s e w nw ne sw se", "all" and "center" would be the same.

Currently "all" works like "center", but the code suggests that it should
work like "n s e w nw ne sw se", not "center". I don't know why it is.

Starting from yesterday xft fonts with shadow are very slow.

Regards,
Mikhael.

---

From: Mikhael Goikhman <[email-masked]>
Date: Sat, 20 Jul 2002 06:25:43 +0000

> Starting from yesterday xft fonts with shadow are very slow.

Actually, "all" was always slow with xft. Now it is slower, because
it draws more text, but this is not a new problem. Try "3 all".
It is probably possible to draw on the background, especially for menus.

Regards,
Mikhael.

---

From: Dominik Vogt <[email-masked]>
Date: Sat, 20 Jul 2002 21:35:37 +0200

> "center" direction (by the way we already have "all", do we need both?).

Well, "all" doesn't provide the effect "center" does.  Now that we
have the latter, "all" is pointless.  I think I'll remove it.

> direction), because it looks unnaturally bad.

I fail to see what multiple directions are good for in the first
place.  Why would I have a N+S or a S+SE+E shadow?

> This may also get rid of this diagonal problem (when specifying "r br").

Well, feel free to give it a shot.  It's quite easy to do.  In
FlocaleGetShadowTextPosition, the code handing "center" scans the
grid of pixels around the origin for positions where a shadow
pixel has to be drawn.  All you need to do is modify this code to
handle the normal directions and the merging between adjacent
directions.  There is one pitfall:  since a "center" shadow is
symmetrical, I didn't handle text rotation.

> work like "n s e w nw ne sw se", not "center". I don't know why it is.

Because "all" includes "center" at the moment.

> Starting from yesterday xft fonts with shadow are very slow.

Any shadows or just the ones using "all"?  If this happens only
with "all", see above.  If not, please add a debug statement
around line 437 in Fft.c:

fprintf(stderr, "\n");
  while (FlocaleGetShadowTextPosition(&xt, &yt, &gstp_args))
  {
fprintf(stderr, "fftds: fgstp returned %d %d\n", xt, yt);
    DrawStringFunc(fftdraw, &fft_fgsh, uf, xt, yt, str, len);
  }

I don't have a working Xft library.

Bye

Dominik ^_^  ^_^

---

From: Mikhael Goikhman <[email-masked]>
Date: Sat, 20 Jul 2002 22:02:44 +0000

> place.  Why would I have a N+S or a S+SE+E shadow?

We are still experimenting, but it seems that in some cases (white fg,
lucidasanstypewriter-14, offset 0) S+SW or SE+S+SW looks better than SW.
But not with the old way of handling of sizes greater than 1.

>     DrawStringFunc(fftdraw, &fft_fgsh, uf, xt, yt, str, len);

Yes, with "all" shadow texts were printed twice. It is fixed now.

It is still impossibly slow with wide menus and "Shadow=2 center:xft...".

Regards,
Mikhael.