Re: Gnome2::Canvas surprising behaviour
- From: muppet <scott asofyet org>
- To: James Muir <hemlock vtlink net>
- Cc: gtk-perl-list gnome org
- Subject: Re: Gnome2::Canvas surprising behaviour
- Date: Wed, 17 Aug 2005 22:36:24 -0400
On Aug 17, 2005, at 8:31 PM, James Muir wrote:
I discovered something surprising with the "aliased" version of the
Gnome2::Canvas.
If you place a Gnome2::Canvas::Text item on an "anti-aliased"
canvas and forget to set the 'fill-color' you see nothing. This
seems reasonable. If you place a Gnome2::Canvas::Text item on an
"aliased" canvas, the text will be displayed even without setting
the 'fill-color'. Nice, I suppose, but is this a bug in
Gnome2::Canvas?
Has nothing to do with Gnome2::Canvas --- it's just an implementation
detail of libgnomecanvas-2.0.
The classic gdk canvas uses gdk to do its drawing, and canvas items
are drawn with the draw() vfunc. gnome_canvas_text_draw() (a private
function) calls gdk_draw_layout() to draw the text with the item's
gc, which was created in realize() with all the defaults. The
defaults, of course, include a text drawing color of black. When you
do a set_property on the canvas text item in gdk mode, the rgb value
you set gets placed directly into the gc.
The antialiased canvas does everything with client-side rendering.
To achieve this, the canvas items are drawn with the render() vfunc
rather than the draw() vfunc. The canvas text item keeps a current
rgba foreground value, and uses this as the foreground color and
alpha for blitting the image drawn by pango_ft2_render_layout() into
the temporary pixel buffer passed in to gnome_canvas_text_render().
It just so happens that there is no initial value explicitly set in
the instance initializer, so it takes the value given to the entire
block by memset() at allocation time -- 0. Since the rgba value is
an unsigned 32 bit int, that means the RGB is all zero, or black...
but the alpha is also 0, and alpha of 0 means "completely transparent".
So, you may want to file a bug against libgnomecanvas in
bugzilla.gnome.org, pointing out that the gnome_canvas_item_text()
needs to set text->rgba = 0x000000ff.... but now that gtk+ 2.8 is
out with cairo support, and havoc and company are talking about a new
canvas widget, don't be surprised if you get a lukewarm response.
(keep in mind, however, that it will still be many months before any
Gnome2::Canvas replacement is viable.)
In the meantime, it's best just to be explicit and always set a fill
color on your Gnome2::Canvas::Text items. ;-)
--
"the ternary operator makes it a bit less ugly."
-- kaffee
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]