Re: [Inkscape-devel] Temporary canvas items
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
On Mon, Jun 23, 2008 at 3:40 PM, Maximilian Albert <Anhalter42@...173...> wrote:
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?
Please hold on - since my writing to you I have actually started working on that, and hope to be able to commit the result today or tomorrow. Then it will be easy to use cairo to render canvas items. Canvas bpaths are already cairoified in my local tree.
Please hold on - since my writing to you I have actually started working on that, and hope to be able to commit the result today or tomorrow. Then it will be easy to use cairo to render canvas items. Canvas bpaths are already cairoified in my local tree.
Awesome news!! Thanks a lot!
Max
On Mon, Jun 23, 2008 at 11:01 PM, bulia byak wrote:
On Mon, Jun 23, 2008 at 3:40 PM, Maximilian Albert wrote:
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?
Please hold on - since my writing to you I have actually started working on that, and hope to be able to commit the result today or tomorrow. Then it will be easy to use cairo to render canvas items. Canvas bpaths are already cairoified in my local tree.
I'm sorry for raising this issue once again for a millionth time, but now that Inkscape uses Cairo is it possible to make text antialising happen? I know this isn't any good for printing, but us, display people, really need nice antialiased letters. See, ehenever I do something in Inkscape that involves text at small font size I'm bound to switch to GIMP and add the text above exported PNG just because the text looks ugly. This really is a must for screen graphics and web design.
Alexandre
On Wed, Jul 30, 2008 at 1:18 PM, Alexandre Prokoudine > I'm sorry for raising this issue once again for a millionth time, but
now that Inkscape uses Cairo is it possible to make text antialising happen?
You probably meant to say "NOT to happen" because now text is always antialiased. Unfortunately the answer is no, cairo does not yet support non-AA rendering and I'm not sure if it ever will (although you will get a better answer from cairo folks).
On Wed, Jul 30, 2008 at 9:08 PM, bulia byak wrote:
On Wed, Jul 30, 2008 at 1:18 PM, Alexandre Prokoudine > I'm sorry for raising this issue once again for a millionth time, but
now that Inkscape uses Cairo is it possible to make text antialising happen?
You probably meant to say "NOT to happen" because now text is always antialiased.
That very much contradicts to what I see :) See attachments
In UI (gtk+ applications, for instance) a DejaVu Sans 10pt looks very much different.
Alexandre
On Wed, Jul 30, 2008 at 2:17 PM, Alexandre Prokoudine
In UI (gtk+ applications, for instance) a DejaVu Sans 10pt looks very much different.
It's not AA, it's hinting. See https://bugs.launchpad.net/inkscape/+bug/170392. Inkscape does not do hinting because with its freedom of zoom, it would basically mean you're getting a different picture depending on zoom, which is not a good thing. In any case, the rendering architecture always outputs letters as shapes, and this would be quite hard to change, cairo or no cairo.
BTW Xara has the same "problem". Though personally I always considered it more of a benefit: I like the fact that we treat everything the same, and that when zoomed out, the page with text looks very much like a paper page viewed from afar, without the distortions of hinting that try to make it still readable at any cost.
On Wed, Jul 30, 2008 at 9:31 PM, bulia byak wrote:
BTW Xara has the same "problem". Though personally I always considered it more of a benefit: I like the fact that we treat everything the same, and that when zoomed out, the page with text looks very much like a paper page viewed from afar, without the distortions of hinting that try to make it still readable at any cost.
Hmmm, I don't really mind seing it inside an Inkscape document, I do mind seing it in a PNG file or in bitmap inside a PDF file :)
Is there absolutely no way to make this work on export only (optionally, of course)?
Alexandre
On Wed, Jul 30, 2008 at 2:46 PM, Alexandre Prokoudine <alexandre.prokoudine@...400...> wrote:
Hmmm, I don't really mind seing it inside an Inkscape document, I do mind seing it in a PNG file or in bitmap inside a PDF file :)
Is there absolutely no way to make this work on export only (optionally, of course)?
The problem is not whether it's for export or not. I would be happy to see it implemented for screen display as well. The problem is that it's pretty hard to do, export or no export, as it requires some deep changes in the way we render text.
participants (3)
-
Alexandre Prokoudine
-
bulia byak
-
Maximilian Albert