How do I use cairomm and librsvg?

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

How do I use cairomm and librsvg?

ghosty
I have a C++ program that uses cairomm, and I'd like to use librsvg with
it to render SVG files to Cairo surfaces. However, librsvg is in C, and
rsvg_handle_render_cairo expects a cairo_t value, while cairomm's
Cairo::Context doesn't give access to the underlying C type (it's
protected). I tried subclassing Cairo::Context and implementing a
function that returned a pointer to the underlying cairo_t type, but it
doesn't seem to be working.

Code is as follows:

main.cpp: https://paste.gnome.org/p9fzmosnu
Makefile: https://paste.gnome.org/p6qswmxgr
mor.glade: https://paste.gnome.org/phlvgqqt5

It just prints
(mor:7839): librsvg-CRITICAL **: rsvg_handle_render_cairo_sub: assertion
'handle != NULL' failed
repeatedly, and doesn't render anything.

Any help would be appreciated.
_______________________________________________
gtkmm-list mailing list
[hidden email]
https://mail.gnome.org/mailman/listinfo/gtkmm-list
Reply | Threaded
Open this post in threaded view
|

Re: How do I use cairomm and librsvg?

Gtkmm mailing list
What's wrong with using the cobj() method in Cairo::Context? I thought Cairo::Context did provide access to the underlying C type, just for this situation.


This method returns a pointer to Cairo::Context::cobject which is just a typedef of cairo_t. Then you shouldn't need to do any of that subclassing work. I haven't tested your code in any way, but that's what my understanding from the documentation is.


On Sat, Jul 21, 2018 at 10:02 PM, <[hidden email]> wrote:
I have a C++ program that uses cairomm, and I'd like to use librsvg with it to render SVG files to Cairo surfaces. However, librsvg is in C, and rsvg_handle_render_cairo expects a cairo_t value, while cairomm's Cairo::Context doesn't give access to the underlying C type (it's protected). I tried subclassing Cairo::Context and implementing a function that returned a pointer to the underlying cairo_t type, but it doesn't seem to be working.

Code is as follows:

main.cpp: https://paste.gnome.org/p9fzmosnu
Makefile: https://paste.gnome.org/p6qswmxgr
mor.glade: https://paste.gnome.org/phlvgqqt5

It just prints
(mor:7839): librsvg-CRITICAL **: rsvg_handle_render_cairo_sub: assertion 'handle != NULL' failed
repeatedly, and doesn't render anything.

Any help would be appreciated.
_______________________________________________
gtkmm-list mailing list
[hidden email]
https://mail.gnome.org/mailman/listinfo/gtkmm-list


_______________________________________________
gtkmm-list mailing list
[hidden email]
https://mail.gnome.org/mailman/listinfo/gtkmm-list
Reply | Threaded
Open this post in threaded view
|

Re: How do I use cairomm and librsvg?

ghosty
Thanks a lot! I don't know how I missed that - it does exactly what I'm
looking for.

On 2018-07-22 09:48, Ezekiel Oruven wrote:

> What's wrong with using the cobj() method in Cairo::Context? I thought
> Cairo::Context did provide access to the underlying C type, just for
> this situation.
>
> https://www.cairographics.org/documentation/cairomm/reference/classCairo_1_1Context.html#a614bcb4e9570c5b5c54b3bfc304c194a
>
> This method returns a pointer to Cairo::Context::cobject which is just
> a typedef of cairo_t. Then you shouldn't need to do any of that
> subclassing work. I haven't tested your code in any way, but that's
> what my understanding from the documentation is.
>
> On Sat, Jul 21, 2018 at 10:02 PM, <[hidden email]> wrote:
>
>> I have a C++ program that uses cairomm, and I'd like to use librsvg
>> with it to render SVG files to Cairo surfaces. However, librsvg is
>> in C, and rsvg_handle_render_cairo expects a cairo_t value, while
>> cairomm's Cairo::Context doesn't give access to the underlying C
>> type (it's protected). I tried subclassing Cairo::Context and
>> implementing a function that returned a pointer to the underlying
>> cairo_t type, but it doesn't seem to be working.
>>
>> Code is as follows:
>>
>> main.cpp: https://paste.gnome.org/p9fzmosnu [1]
>> Makefile: https://paste.gnome.org/p6qswmxgr [2]
>> mor.glade: https://paste.gnome.org/phlvgqqt5 [3]
>>
>> It just prints
>> (mor:7839): librsvg-CRITICAL **: rsvg_handle_render_cairo_sub:
>> assertion 'handle != NULL' failed
>> repeatedly, and doesn't render anything.
>>
>> Any help would be appreciated.
>> _______________________________________________
>> gtkmm-list mailing list
>> [hidden email]
>> https://mail.gnome.org/mailman/listinfo/gtkmm-list [4]
>
>
>
> Links:
> ------
> [1] https://paste.gnome.org/p9fzmosnu
> [2] https://paste.gnome.org/p6qswmxgr
> [3] https://paste.gnome.org/phlvgqqt5
> [4] https://mail.gnome.org/mailman/listinfo/gtkmm-list
_______________________________________________
gtkmm-list mailing list
[hidden email]
https://mail.gnome.org/mailman/listinfo/gtkmm-list