GNOME Bugzilla – Bug 97036
Gdk::Drawable::draw_glyphs() uses a C type.
Last modified: 2004-12-22 21:47:04 UTC
(from my mail to the mailing list) I would like to make two aditional remarks on the methods I used for low level text rendering: - the method Gdk::Drawable::draw_glyphs, which is used for low level text rendering, takes a c pointer PangoGlyphString* glyphs instead of a Pango::GlyphString object. This is not a problem since one can use the gobj method of Pango::GlyphStringto get the c pointer from the object, but it looks a bit inconsistent to me. void draw_glyphs (const Glib::RefPtr<const GC>& gc, const Glib::RefPtr<const Pango::Font>& font, int x, int y, PangoGlyphString* glyphs) - similar point for pango_shape where no c++ wrapper exists. Again one can use the c function directly by using the gobj methods. void pango_shape (const gchar *text, gint length, PangoAnalysis *analysis, PangoGlyphString *glyphs); Of course both functions are needed for low level text rendering with pango only and this is rather esoteric and discouraged for most uses anyway. So I wouldn't mind, if you decide not to do anything about this.
As Martin Schulze pointed out in the mailing list, I was wrong about the missing pango_shape wrapper. It's a shape mathod for Pango::Item. Sorry. Morus
In void draw_glyphs (const Glib::RefPtr<const GC>& gc, const Glib::RefPtr<const Pango::Font>& font, int x, int y, PangoGlyphString* glyphs) The glyphs parameter is an _array_, not a single instance. The C documentation suggests that it's difficult to get such an array: http://developer.gnome.org/doc/API/2.0/gdk/gdk-drawing-primitives.html#gdk-draw-glyphs and says that this is a very low-level function. And this documentation is reused in gtkmm's reference docs: http://www.gtkmm.org/gtkmm2/docs/reference/html/classGdk_1_1Drawable.html#a19 So, unless someone can suggest how it might be improved, I will close this bug.
The documentation of gdk_draw_glyphs() sounds complicated, but it really isn't -- at least from a narrow-minded lets-wrap-this-function point of view ;) The glyphs parameter itself is _not_ an array. What they probably mean is that PangoGlyphString contains an array of glyphs, just like a C-string really is an array of char. But unlike char*, PangoGlyphString is a self-contained struct we don't have to know anything about in order to wrap it. It becomes clearer by looking at the PangoGlyphString docs: http://developer.gnome.org/doc/API/2.0/pango/pango-glyph-storage.html#PangoGlyphString From that you can see that the PangoGlyphString struct takes care of the array of glyphs. So all we have to do is defining a Pango::GlyphString to PangoGlyphString* conversion (if it doesn't exists already) and use it in _WRAP_METHOD(). Business as usual. Well, one for 2.2. --Daniel
OK, thanks for the explanation. Awaiting a patch for a future API-break maybe 2.2. or 2.4.
Now would be a good time to submit a patch. We must freeze the API soon.
Commited in cvs.