[Gtk-sharp-list] Drawing a string
m.j.hutchinson at gmail.com
Fri Mar 9 13:27:41 EST 2007
On 3/9/07, Aaron Oxford <aaron at hardwarehookups.com.au> wrote:
> I want to be sure that this code will build in MonoDevelop and in
> Visual Studio. I went down the DrawingSample (from the Gtk#2.8.3
> installer for Windows) path until I realised I was using Graphics, a
> Windows.Forms component. Then I went to look at Cairo, but I can't
> seem to find the right reference to add in order to compile. Where is
> Mono.Cairo in the list of references - OK not there, so I found the
> DLL, but what is this strange DLL, do I copy it to my bin directory?
> And what do I do to make this work under Linux, where presumably
> there is no such things as Mono.Cairo.DLL?
Mono.Cairo.dll should be in the GAC. If not then the installer needs
updating (I think).
GTK's drawing is done via GDK (sort of like a common platform layer)
and Pango, so those should always be present on every GTK+ platform.
Since GTK+ 2.8 it also uses Cairo.
Also, the Gtk.DotNet namespace (not sure what assembly it's in)
provides a way to get a System.Drawing.Graphics context from
Gdk.Drawable, so you can actually use a Graphics object with GTK#.
> So I've worked my way around that with the built-in drawing routines
> (there needs to be a better sample for that), until it was time to
> draw text. Now it looks like I need Pango AND Cairo just to label
> something. I'm completely stuck, and I was going so well!
> Does anyone have an example of working cross-platform text drawing
> routines and/or know how to get Cairo going under Visual Studio. Any
> help will be hugely appreciated.
Sorry, no examples as I've never done this myself, but I'm fairly
certain that Pango and Cairo are indeed the way to go.
You might have luck looking in the source code of an application like
Banshee for examples. Or you could try translating this from C:
This may also be helpful:
More information about the Gtk-sharp-list