On Wed, Jun 18, 2008 at 6:45 AM, Maximilian Albert <Anhalter42@...173...> wrote:
Yes. My question is how the "... that renders text" part would work.
Since you don't need to worry about exact font, kerning, etc., which all may be tricky, cairo is the natural choice for this. Each canvas item has a render method which is passed the SPCanvasBuf; you can just deconstruct it to access the actual memory buffer, create a temporary cairo surface and context in the render method of your text canvas item, and draw text to it using cairo's show_text.
But that would be wasteful and hacky, although acceptable as a temporary solution. The proper solution that would take us one step closer to total cairofication is to create a common cairo context in sp-canvas, associated with SPCanvasBuf, and pass it down to all canvas buffer so they could draw to it using cairo at once. That is what needs to be done, the biggest obstacle being that most canvasitems are drawn with direct bit-flipping in the buffer and they assume 3 bytes per pixel and fixed RGB order, neither of which is true for cairo which only has 4 bytes whose order depends on endianness. So all of canvas items must be switched to cairo (or at least to 4 bytes) at once, this cannot be done incrementally. This is what I'll have to do as soon as I have some time to devote to it (unless someone comes to my rescue :)