Re: Drawing a halo around text
- From: Behdad Esfahbod <behdad behdad org>
- To: Matt Hoosier <matt hoosier gmail com>
- Cc: gtk-i18n-list gnome org
- Subject: Re: Drawing a halo around text
- Date: Fri, 26 Oct 2007 12:17:37 -0400
On Fri, 2007-10-26 at 10:11 -0500, Matt Hoosier wrote:
> Hi,
>
> I'd like to draw some text over the top of a user-supplied splash
> screen. Because I can't know what the color scheme contained in that
> image will be, I need to do something like paint a small (1-pixel ?)
> border of known color around the edges of my glyphs, in order to
> guarantee that the lettering is visible.
>
> Is there a way to convince Pango to do that sort of thing?
Yes and no. You need to do it yourself, but pango gives you the tools
for.
First, use pangocairo with gdk. Then you can do things like:
cairo_move_to (cr, x, y);
cairo_pango_layout_path (cr, layout);
/* blue halo */
cairo_set_source_rgba (cr, 0., 0., 1., .5);
cairo_set_line_width (cr, 2.);
cairo_stroke_preserve (cr);
/* green letters */
cairo_set_source_rgb (cr, 0., 1., 0.);
cairo_fill (cr);
An uglier but possibly faster option is to render the text 5 times:
/* blue halo */
cairo_set_source_rgb (cr, 0., 0., 1.);
cairo_move_to (cr, x-1, y); cairo_pango_show_layout (cr, layout);
cairo_move_to (cr, x+1, y); cairo_pango_show_layout (cr, layout);
cairo_move_to (cr, x, y-1); cairo_pango_show_layout (cr, layout);
cairo_move_to (cr, x, y+1); cairo_pango_show_layout (cr, layout);
/* green letters */
cairo_set_source_rgb (cr, 0., 1., 0.);
cairo_move_to (cr, x, y); cairo_pango_show_layout (cr, layout);
> --Matt
Cheers,
--
behdad
http://behdad.org/
"Those who would give up Essential Liberty to purchase a little
Temporary Safety, deserve neither Liberty nor Safety."
-- Benjamin Franklin, 1759
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]