Subject: Shadow Text

From: Olivier Chapuis <[email-masked]>
Date: Fri, 17 May 2002 08:28:52 +0200

It does not seem that FVWM CVS send a message about my last
commit which implements shadow text rendering.

Here the log:

* Implemented shadow text rendering.
* The FlocaleWinString structure has now a colorset_structure member,
shadow rendering is handled if the module passes the colorset_struct.
At present time only fvwm, FvwmIdent and FvwmTaskBar do that.
* New colour colorset option "fgsh" which defines the shadow text colour.
* Shadow rendering is defined at font loading. For example:
          Style * "shadowsize=2:your_font_desc" 
* Added -DFVWM_COLORSET_PRIVATE to fvwm AM_CFLAGS to allow a libs
include file to include libs/Colorset.h in a safe way

A few comments.
- Shadow text rendering works only if Colorset are used. I think this
reasonable, but if someone really want that shadow text rendering works
with "old" colors cfg I can do it (this is just boring and not really
pretty from the implementation point of view).  
- The result can be good (and even really cool) if the shadow color
(fgsh) is well chosen (the font can come into the game too).
At present time fgsh is computed as sh is computed from bg. This is
not a definitive solution at all. Any idea is really welcome :o)
Maybe Jos Riswick has an idea about this.
- I've not added the doc about shadowsize=int in the front of a
font description as I do not know where I should put the doc.
Maybe this should go into the (future) Colorset section?
- Attached a screenshot: fvwm-themes root menu with a transparent
bg and a small xft font (shadowsize=2:xft:Verdana:Medium:pixelsize=10).

Olivier

---

From: Dan Espen <[email-masked]>
Date: Fri, 17 May 2002 09:32:27 -0400

Olivier Chapuis <[email-masked]> writes:
> Heres the log:
...
> A few comments.
> - Shadow text rendering works only if Colorsets are used. I think this is
> reasonable, but if someone really wants that shadow text rendering to work
> with the "old" colors cfg I can do it (this is just boring and not really

I have no desire to complicate my config by using colorsets,
but I'd really like to use shadow text, especially in titlebars.

-- 
Dan Espen                           E-mail: [email-masked]
444 Hoes Lane  Room RRC 1C-214      Phone: (732) 699-5570
Piscataway, NJ 08854
--
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: Fri, 17 May 2002 16:43:42 +0000

> but I'd really like to use shadow text, especially in titlebars.

For me colorsets simplify config, not complicate it.

I don't think this duplicated functionality should be added (and then
removed in 3.0). This also requires adding fgsh color configuration in a
lot of places, because the default is usually not what user wants.

Dan, you should really start to use colorsets and benefit from all nice
features they will have in 2.6. If you worry about your users, I may think
about an automated convertion using fvwm-convert-2.6.

You should add 3 lines to get shadow text in window titles now (if you
don't use colorsets yet), copy these 4 colors from Style * BackColor etc:

  Colorset 1 fg A, bg B   # inactive window title fg+bg
  Colorset 2 fg C, bg D   # active window title fg+bg

  Style * Colorset 1, HilightColorset 2

If you want to add shadow colors to menus, convert these lines:

  MenuStyle * Foreground A, Background B, Greyed C
  MenuStyle * ActiveFore D, HilightBack E
  MenuStyle * MenuFace F

to:

  Colorset 5 fg A, bg B, Pixmap F  # inactive menu item fg+bg and face
  Colorset 6 fg D, bg E, Plain     # active menu item fg+bg
  Colorset 7 fg C, bg C, Plain     # greyed menu item fg

  MenuStyle * MenuColorset 5, ActiveColorset 6, GreyedColorset 7

Now add shadowsize to font, like:

  Style     * Font "shadowsize=3:xft:Luxi Mono:Bold:pixelsize=14"
  MenuStyle * Font "shadowsize=1:-adobe-helvetica-bold-r-*-*-*-120-*"

Optionally add fgsh to colorsets, try: fg gray90, fgsh gray40, bg gray20.

Regards,
Mikhael.

---

From: Dan Espen <[email-masked]>
Date: Fri, 17 May 2002 13:34:53 -0400

> don't use colorsets yet), copy these 4 colors from Style * BackColor etc:

Gee, when you're right, you're right.  Its really not that hard.

Its not as simple as just adding a shadow to the font,
but I guess I can manage it.

So, I tried it out.
I was surprised to see that the shadow descends down below the
character.  Isn't the effect in FvwmScript the opposite,
Ie. the shadow is above the letters?

Since thats where I want the shadow,  I tried using negative
numbers.  That didn't seem to work.  Large negative numbers are
interesting, they can make the titlebar disappear.

Shouldn't the shadow stuff be at the end of the font name along
with the other modifiers?

---

From: Mikhael Goikhman <[email-masked]>
Date: Fri, 17 May 2002 17:38:30 +0000

> not a definitive solution at all. Any idea is really welcome :o)

In my humble opinion, there is a good effect when fgsh is:

  fgsh = (fg + 3 * bg) / 4

All 3 rgb components are evaluated independently unsing this formula.

I.e. fgsh should be something between fg and bg, 3 times closer to bg.
At least it is much better for a default than "sh".

> Maybe this should go into the (future) Colorset section?

It should be in FONTS section, because colorset itself does not define
shadow, fgsh is always present.

> bg and a small xft font (shadowsize=2:xft:Verdana:Medium:pixelsize=10).

Nice.

Regards,
Mikhael.

---

From: Olivier Chapuis <[email-masked]>
Date: Fri, 17 May 2002 20:47:35 +0200

> interesting, they can make the titlebar disappear.

Yep, not yet implemented :o)
 
> with the other modifiers?

I do not think so (for coding simplicity). Note that the "xft:" modifier
is at the "begining".

Regards, Olivier

---

From: Dan Espen <[email-masked]>
Date: Fri, 17 May 2002 15:18:35 -0400

> Yep, not yet implemented :o)

Fair enough.

> I do not think so (for coding simplicity). Note that the "xft:" modifier

Yep, I re-read the man page, and I agree, the front is OK.

Its not clear what happens with a list:

"shadowsize=2:9x15,fixed"

or

"shadowsize=2:9x15,shadowsize=2:fixed"

it looks like it accepts either, but ignores the second
shadowsize.

---

From: Mikhael Goikhman <[email-masked]>
Date: Sat, 18 May 2002 03:01:53 +0000

> At least it is much better for a default than "sh".

This formula produces soft shadows, it is ok for a default, because this
does not disturb a user too much, but usually a user wants a more hard
(contrast) text shadow. I think, this revised formula produces better
results in some cases:

  fgsh = (5 * bg - fg) / 4

If bg is lighter than fg, the soft formula may be applied. And if fg and
bg are too close one to other, set fgsh to 0, or maybe to (fg + bg) / 4.
I used the following test (runs 2 minutes) for random fg and bg colors:

*FvwmIdent: Font "shadowsize=2:xft:Luxi Mono:Roman:pixelsize=13"
*FvwmIdent: Colorset 21
Next (XTerm) FvwmIdent

# the leading minus is important
-SendToModule FvwmPerl eval detach(); \
        for (1 .. 20) { \
                $f = 0; \
                for $d (0 .. 2) { \
                        $a[$d] = int(rand(256)); \
                        $b[$d] = int(rand(256)); \
                        $c[$d] = int((5 * $b[$d] - $a[$d]) / 4); \
                        $c[$d] = int((3 * $b[$d] + $a[$d]) / 4) \
                                if $a[$d] < $b[$d] || $c[$d] < 0; \
                        $c[$d] = 0 if $a[$d] - $b[$d] < 32 && \
                                $a[$d] - $b[$d] > -32; \
                } \
                $e{fg} = sprintf("rgb:%02x/%02x/%02x", @a[0 .. 2]); \
                $e{bg} = sprintf("rgb:%02x/%02x/%02x", @b[0 .. 2]); \
                $e{fs} = sprintf("rgb:%02x/%02x/%02x", @c[0 .. 2]); \
                command("Colorset 21 fg $e{fg}, bg $e{bg}"); \
                sleep(3); \
                command("Colorset 21 fg $e{fg}, bg $e{bg}, fgsh $e{fs}"); \
                sleep(3); \
        }

You may use system("xmessage 'fg $e{fg}, bg $e{bg}, fgsh $e{fs}'")
instead of sleep(3) if you want to see numbers too.

This algorithm is not perfect at all, but it produces good results.

Regards,
Mikhael.

---

From: Olivier Chapuis <[email-masked]>
Date: Sun, 19 May 2002 07:30:45 +0200

> > > Ie. the shadow is above the letters?

In fact FvwmScript relief is equivalent to "shadowsize=1" and
Colorset fgsh [csX.hi].

> > Yep, not yet implemented :o)

Do you mean that we do not need "negative shadow text"?
  
> it looks like it accepts either, but ignores the second

"shadowsize=int:" should be at the beginning only. It will be
complicate (impossible) to support shadowsize in a ","
separated list as such list is given directly to XLoadFontSet
(and X choose itself the good font relatively to the locale
charset).

Olivier

---

From: Dan Espen <[email-masked]>
Date: Sun, 19 May 2002 05:35:32 -0400

> Do you mean that we do not need "negative shadow text"?

No, I'd like to see shadows at the top too.

> (and X choose itself the good font relatively to the locale

One shadowsize at the front, that applies to the whole list
is OK.

---

From: Olivier Chapuis <[email-masked]>
Date: Mon, 20 May 2002 15:29:43 +0200

> This algorithm is not perfect at all, but it produces good results.

This algo is now in used in fvwm.
Regards, Olivier

---

From: Olivier Chapuis <[email-masked]>
Date: Wed, 22 May 2002 21:24:53 +0200

> No, I'd like to see shadows at the top too.

Done. So we have shadow text with a top-left to bottom-right direction.
Maybe we should implement shadow text with a top-right to bottom-left
direction?

Olivier

---

From: Dan Espen <[email-masked]>
Date: Wed, 22 May 2002 16:19:16 -0400

> Maybe we should implement shadow text with a top-right to bottom-left

Yes.

Actually, I just saw some screenshots for Metacity, and it looked
like the shadows were going to the right.

We could do that with:

shadowsize=[+-]x[+-]y

---

From: Mikhael Goikhman <[email-masked]>
Date: Thu, 23 May 2002 05:15:28 +0000

> > Maybe we should implement shadow text with a top-right to bottom-left

It seems that the original "size" name is totally overloaded.

Actually I thought about all kinds of extensions, including specifying x
and y values and even a full loop range by x and y not just size.

And I think what we need is this:

  shadow=<size>[,<direction>]

<size> is positive. <direction> dafaults to 16, but 1, 4, 64 are good too.
There are 8 directions, not just 4 diagonal. 8 directions = 8 bits.
(-1, -1), (0, -1), (1, -1), (1, 0), (1, 1), (0, 1), (-1, 1), (-1, 0).

I don't know whether specifying more than 1 direction (more than 1 bit)
looks good, say 3 directions [n, ne, e] are encoded by 2+4+8=14.

But I know that a shadow _around_ text should look nice:

  shadow=1,255

This draws a shadow 8 times, one in each direction. Just an idea.

Regards,
Mikhael.

---

From: Olivier Chapuis <[email-masked]>
Date: Sat, 25 May 2002 01:03:42 +0200

>   shadow=<size>[,<direction>]

Yes, I am agree. One point is that I do not think that we need
distincts x and y (Dan?).
  
> There are 8 directions, not just 4 diagonal. 8 directions = 8 bits.

Yes agree again. But do you think that the user will like to give
the directions with a number?
So the syntax may be:

	shadow=<size> [directions]

where directions is a space separated list constituted by se (default), s,
n, o, e, so, ne, no and all. Or maybe we can use "iconbox" directions
bl, b, t, l, r, br, tr, tl.

Olivier

---

From: Dan Espen <[email-masked]>
Date: Fri, 24 May 2002 19:30:26 -0400

> bl, b, t, l, r, br, tr, tl.

Consistency is good.

Lets see, a 1 pixel shadow on the upper right would be:

Font "shadow=1,ur:9x15bold"

A 2 pixed shadow all around the character would be:

Font "shadow=2,l r t b ur ul lr ll:9x15bold"

It seems easy enough to figure out.

---

From: Mikhael Goikhman <[email-masked]>
Date: Sat, 25 May 2002 00:00:23 +0000

> Font "shadow=2,l r t b ur ul lr ll:9x15bold"

Just to make it sure we all agree.
I think comma to separate size and direction is better than space.
A space or a plus may separate directions. I think the "all" name is ok.

I am not sure before seeing it we really need more than 1 direction word.
If this looks ugly (t+bl) we may restrict the direction part to one word.

Regards,
Mikhael.

---

From: Dan Espen <[email-masked]>
Date: Fri, 24 May 2002 20:09:24 -0400

> If this looks ugly (t+bl) we may restrict the direction part to one word.

I agree with all your comments.

---

From: Olivier Chapuis <[email-masked]>
Date: Sun, 26 May 2002 22:27:28 +0200

> A space or a plus may separate directions. I think the "all" name is ok.

I've chosen to do not use "," but space between size and direction.
First "," are used in the XLFD to separated different fonts. So
it seems to me that a "," denote an alternative in font name.
Also it seems to me that "," is a strong separator from fvwm
syntax point of view.

About directions. I've used  l r u b ur ul br bl. Is "u" alone should
be t?

Olivier

---

From: Dominik Vogt <[email-masked]>
Date: Sun, 26 May 2002 23:43:18 +0200

> About directions. I've used  l r u b ur ul br bl. Is "u" alone should

Don't forget that there is already a direction parsing function in
libs/gravity.c that can be easily extended to handle 't', 'u', ...

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]