Text Shadows

47 views
Skip to first unread message

Jason Moiron

unread,
Sep 9, 2011, 4:48:25 PM9/9/11
to vim_mac
Hey All,

I've recently written a hacky little patch for vim gtk+x11 which will
draw faux shadows under text. I quite like the look of this, and
wanted to get this going on my OSX laptop as well. Unfortunately, I
have experience with C and Gtk but not much with Cocoa/ObjC; I cannot
make a ton of sense of MMTextView.m, and I'm not sure if Cocoa will
natively support text shadows in some nicer way or if I could use the
same double-render technique that I used in gtk.

Gvim's text view uses drawing primatives to paint text with the
appropriate fg & bg color; my patch simply painted the text twice,
once using a slightly darkened bg color as the fg color, transposed 1y
& 1x pixel, and then again using the standard fg color.

I don't mind if this type of feature isn't desirable or not really in
contention for inclusion in the main line; I'd gladly maintain my own
patch and builds. Any pointers on how to start on this?

-- Jason

Janusz Bossy

unread,
Sep 9, 2011, 5:22:45 PM9/9/11
to vim...@googlegroups.com
On Fri, Sep 9, 2011 at 10:48 PM, Jason Moiron <jlmo...@gmail.com> wrote:
> I've recently written a hacky little patch for vim gtk+x11 which will
> draw faux shadows under text.  I quite like the look of this, and
> wanted to get this going on my OSX laptop as well.

Hi Jason,

unfortunately I can't help you with your problem but I just wanted to
see how the effect looks on your linux machine. Can you point me to
the patch or just upload a couple of screenshots?

Thanks,
Janusz

Jason Moiron

unread,
Sep 10, 2011, 3:31:14 AM9/10/11
to vim_mac
Sure.

The patch is here: (I should really set up an hg mirror, I'm thinking
more and more I want to make this a bit less ugly than some compile-
time always-on hack)

http://dev.jmoiron.net/vim-shadow.patch

Here are some assorted screenshots:

http://jmoiron.net/~jmoiron/ss/vim-shadow.png
http://jmoiron.net/~jmoiron/ss/vim-shadow2.png
http://jmoiron.net/~jmoiron/ss/vim-shad-dark.png
http://jmoiron.net/~jmoiron/ss/vim-shad-light.png

It doesn't look all that hot on light backgrounds; I think either my
darkening algorithm is a little too severe. I worked in a catch for
fairly bright colors, but it's got all sorts of caveats (anything very
red will be considered "bright"). Still, once rendering the effect is
possible, determining the right shadow color is probably a less
difficult issue.

-- Jason


On Sep 9, 5:22 pm, Janusz Bossy <janusz.bo...@gmail.com> wrote:

Jason Moiron

unread,
Sep 11, 2011, 4:23:41 PM9/11/11
to vim_mac
I've updated the patch to have a better darkening algorithm based on
hsv color coordinates. I'd still appreciate if anyone has any
pointers on how to achieve this effect in MacVim.

Thanks!

-- Jason

On Sep 10, 3:31 am, Jason Moiron <jlmoi...@gmail.com> wrote:
> Sure.
>
> The patch is here:  (I should really set up an hg mirror, I'm thinking
> more and more I want to make this a bit less ugly than some compile-
> time always-on hack)
>
> http://dev.jmoiron.net/vim-shadow.patch
>
> Here are some assorted screenshots:
>
> http://jmoiron.net/~jmoiron/ss/vim-shadow.pnghttp://jmoiron.net/~jmoiron/ss/vim-shadow2.pnghttp://jmoiron.net/~jmoiron/ss/vim-shad-dark.pnghttp://jmoiron.net/~jmoiron/ss/vim-shad-light.png

björn

unread,
Sep 12, 2011, 1:45:36 PM9/12/11
to vim...@googlegroups.com
On 11 September 2011 22:23, Jason Moiron wrote:
> I've updated the patch to have a better darkening algorithm based on
> hsv color coordinates.  I'd still appreciate if anyone has any
> pointers on how to achieve this effect in MacVim.

I think what you are trying to achieve will be much easier if you
enable the experimental renderer (in the advanced preferences) and
then patch MMCoreTextView instead of trying to patch MMTextView.

Note that I am not really interested in adding text shadow support so
even if you do get around to writing this patch it is very unlikely
that I will ever merge it with mainline. Sorry.

Björn

Jason Moiron

unread,
Sep 13, 2011, 2:57:17 AM9/13/11
to vim_mac
Thank's very much Björn! Without your pointers, I was lost!

Since this is for my own personal use, the patch is extremely rough
and simply enables the drawing of these faux text shadows everywhere
in exactly the same manner of the linux patch I've linked above. If
anyone else is interested, it can be viewed here:

https://github.com/jmoiron/macvim/commit/3f609d05ff517d3988f1a0774c6afefd8ba9521b

-- Jason
Reply all
Reply to author
Forward
0 new messages