Re: Pango Layout Mystery
- From: "muppet" <scott asofyet org>
- To: gtk-perl-list gnome org
- Subject: Re: Pango Layout Mystery
- Date: Mon, 13 Mar 2006 14:09:38 -0500 (EST)
James Muir wrote:
Can anyone explain to me why "$layout->get_pixel_size()" returns
different values than those I'd get when I get the Gnome2:Canvas::Item
'text-height' and 'text-width' properties? I've looked at several other
Layout properties (spacing, indent, justify) and they all return "0". In
the example below, I get:
text, text: Hello World! font: Ariel Normal 10 text_height: 13
layout_height: 17 text_width: 66 layout_width: 76
When i run it, i get text_height: 17 and layout_height: 17, but text_width: 77
and layout_height: 72.
At the end of gnome_canvas_text_set_property() i found this code:
if (text->layout)
pango_layout_get_pixel_size (text->layout,
&text->max_width,
&text->height);
else {
text->max_width = 0;
text->height = 0;
}
which appears to be the only place where the values of ->height and
->max_width are set. Those values are used in
gnome_canvas_text_get_property() like so:
case PROP_TEXT_WIDTH:
g_value_set_double (value, text->max_width /
text->item.canvas->pixels_per_unit);
break;
case PROP_TEXT_HEIGHT:
g_value_set_double (value, text->height / text->item.canvas->pixels_per_unit);
break;
That is, when you do this:
my $text_width = $text->get('text-width');
my $text_height = $text->get('text-height');
you're essentially doing
my ($layout_width, $layout_height) = $layout->get_pixel_size();
$layout_width /= $text->pixels_per_unit;
$layout_height /= $text->pixels_per_unit;
Granted, this is based on looking for about two minutes at stuff i had lying
around.
--
muppet <scott at asofyet dot org>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]