[Gtk-sharp-list] Inserting attributes into a Pango.Layout

Tiago Lima tiago.lima@vianw.pt
Mon, 23 Feb 2004 15:08:37 +0000


Hi,

I have some problems inserting Attributes into the Pango.Layout. Well, the 
attributes are inserted (I guess) but when it comes to draw the layout (in 
Gdk.Drawable.DrawLayout it gives me a null pointer exception inside the 
"unmanaged" code (i think in the C code ?)...

Unhandled Exception: System.Reflection.TargetInvocationException: Exception 
has been thrown by the target of an invocation. ---> 
System.NullReferenceException: A null value was found where an object 
instance was required
in (unmanaged) (wrapper managed-to-native) Gdk.Drawable:gdk_draw_layout 
(intptr,intptr,int,int,intptr)
in <0x00004> (wrapper managed-to-native) Gdk.Drawable:gdk_draw_layout 
(intptr,intptr,int,int,intptr)
in <0x00061> Gdk.Drawable:DrawLayout (Gdk.GC,int,int,Pango.Layout)

Is this a bug or should I initialize some more things before ?

For example, I'm doing this:

	_pangoLayout = _gtkDrawingArea.CreatePangoLayout("some text");
	_pangoLayout.Attributes = new AttrList();  // because _pangoLayout.Attributes 
is null !
	_pangoLayout.SetText("hello this is a test text");
	
	Pango.Attribute attribute = Pango.Attr.ForegroundNew(0xff, 0, 0); // red 
color
	attribute.start_index = 0;
	attribute.end_index = 1;
	_pangoLayout.Attributes.Insert(attribute);

This is ok, now when it draws:

		protected void OnExpose(object sender, ExposeEventArgs args)
		{
			_gtkDrawingArea.GdkWindow.DrawLayout(_gtkDrawingArea.Style.BlackGC, 0, 0, 
_pangoLayout);
		}

it gives the exception (inside the DrawLayout function).

Do you want me to post a bug on this ?

Is anyone using Pango right now? Anybody experiencing this?

Thanks,
	Tiago Lima