|Project:||The Open Toolkit library|
OpenTK relies on System.Drawing (GDI+) to render glyphs and lay them out to form text. Unfortunately, Mono's implementation of GDI+ suffers from several bugs: it cannot handle newline characters or word-wrapping.
We have worked around the first issue by splitting text on newline characters. This allows text rendering to work on Mono, but puts pressure on the GC. Unfortunately, there is no workaround for the second issue.
There are two solutions to this issue:
- Wait for Mono to finish it's new Pango-based text renderer, which will (hopefully) fix the bugs. This won't likely appear before Mono 2.8 (scheduled for December 2009 or somewhere near to that).
- Implement our own Mono.Pango-based IGlyphRasterizer.
The internal IGlyphRasterizer interface (OpenTK.Utilities) defines the methods for the rasterizer. There are two main methods in
MeasureText, which returns a collection of
TextExtentinstances describing the layout of the text (one TextExtent per character).
Rasterize, which rasterizes a glyph into a
We need to find how these methods can be implemented with Pango/Mono.Pango. As far as I can see, we need three things:
- Create a Pango context. I think we need to create a Cairo or GTK# context first.
- Map the desired
- Perform text layout and glyph rasterization using either high- or low-level Pango methods.
Once these are implemented, we can simply hook the new PangoGlyphRasterizer into the existing engine and use it when
OpenTK.Configuration.RunningOnMono is true.
Any help with tasks 1 - 3 will be appreciated!
You can download Mono.Pango from mono-project.com (it is in the GTK# installer). It should come pre-installed on Ubuntu.