
Zitat von bulia byak <buliabyak@...400...>:
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.
Is there boilerplate code available somewhere for creating and managing such a context? In particular, how would I tie it into SPCanvasBuf? Is the guchar* buf variable the memory buffer you are talking about? Why/how do I need to access it and what's the interconnection with the cairo context? Sorry if these are very basic questions, but I don't have any experience yet with Inkscape's on-canvas rendering.
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 :)
How difficult and/or time-consuming do you expect this to be? Could it be done without knowing anything about the bit-flipping and other issues you mentioned? If you think that it would be worth it to take this little detour from my actual SoC project, I'd be glad to be this "someone". :) But I neither have any experience with cairo nor am I familiar with the problems you mentioned. So someone would need to give me step-by-step instructions of what needs to be done.
Max