From marc at jeanmougin.fr Fri Jun 14 15:53:44 2019 From: marc at jeanmougin.fr (Marc Jeanmougin) Date: Fri, 14 Jun 2019 17:53:44 +0200 Subject: [cairo] dithering in cairo ? Message-ID: <21104561-415b-99ea-23c1-0308f3ab13c0@jeanmougin.fr> Hi all,  I'm interested in being able to create dithered images in Inkscape (it would be useful in a lot of other contexts). A dithering path has been recently added into pixman which makes it possible, but I'm struggling on what would be the best way : At first I thought that I could do the same as what is done with cairo_filter_t at the pattern level : "just" cairo_pattern_get/set_filter ( https://gitlab.freedesktop.org/cairo/cairo/merge_requests/24/diffs?commit_id=730a268b90a60bf050b42505801bc6bc085af759 ). However this seems to be not enough : when creating a cairo_image_surface with pixman format, the code directly creates the pixman_image but I get no direct access to it. I'm also not exactly sure what would happen with the surfaces created with push_group().  I'm not sure where to go from here: I was thinking about either add a cairo_image_surface_get_pixman_image to let the user deal directly with it at the pixman level, or having something like pixman_image_surface_set_dither(). Could you give me some advice on where to go from here? Thanks a lot, -- Marc Jeanmougin From wvick at europa.uk.com Tue Jun 25 06:09:42 2019 From: wvick at europa.uk.com (Warren Vick) Date: Tue, 25 Jun 2019 06:09:42 +0000 Subject: [cairo] Text stuffing with Cairo/pycairo? In-Reply-To: <573610459.3407508.1556732455404@mail.yahoo.com> References: <695485279.2814876.1556646482268.ref@mail.yahoo.com> <695485279.2814876.1556646482268@mail.yahoo.com> <573610459.3407508.1556732455404@mail.yahoo.com> Message-ID: I’ve made some good progress working with pyCairo after porting Eric’s C code below. I am, however, having a problem with selecting fonts… I’m using pyCairo on Windows. No matter what font I select using select_font_face on a context, I seem to get Arial output in my PDF. Does pyCairo pick-up fonts installed on Windows or do the TTF files need to be copied somewhere specific? Or, have I misunderstood what is meant by the face name? e.g. “Noto Sans Condensed”. Regards, Warren From: cecashon at aol.com Sent: 01 May 2019 18:41 To: Warren Vick ; cairo at cairographics.org Subject: Re: [cairo] Text stuffing with Cairo/pycairo? It is worth mentioning here that when you draw lines around the box with the usual way of doing this, cairo_fill_preserve(cr); cairo_set_source_rgba(cr, 0.0, 0.0, 0.0, 1.0); cairo_stroke(cr); the scale will cause the lines to be non uniform. This is mentioned in the Cairo Tutorial under Working with Transforms. To get the lines around the box to be uniform, the transformed points can be mapped to device space or the starting coordinates that cairo uses. Then the lines around the box can be drawn. The following shows this. Have fun drawing. Eric ... //Order transforms and draw. cairo_save(cr); cairo_translate(cr, center_box_x, center_box_y); cairo_rotate(cr, rotate); cairo_scale(cr, box_width/fabs(2.0*move_x), box_height/fabs(2.0*move_y)); cairo_set_source_rgba(cr, 0.0, 1.0, 0.0, 0.4); double r1=-fabs(scale_x); double r2=-fabs(scale_y); double r3=fabs(2.0*scale_x); double r4=fabs(2.0*scale_y); cairo_rectangle(cr, r1, r2, r3, r4); cairo_fill(cr); //Save device cordinates for the rectangle so that lines are drawn correctly. double c1=r1; double c2=r2; double c3=r1; double c4=r2+r4; double c5=r1+r3; double c6=r2+r4; double c7=r1+r3; double c8=r2; cairo_user_to_device(cr, &c1, &c2); cairo_user_to_device(cr, &c3, &c4); cairo_user_to_device(cr, &c5, &c6); cairo_user_to_device(cr, &c7, &c8); cairo_set_source_rgba(cr, 0.0, 0.0, 0.0, 1.0); cairo_move_to(cr, move_x, move_y); cairo_show_text(cr, string); cairo_restore(cr); //Draw box lines. cairo_save(cr); cairo_set_source_rgba(cr, 0.0, 0.0, 1.0, 1.0); cairo_set_line_width(cr, 4.0); //Reset transform matrix. cairo_identity_matrix(cr); cairo_move_to(cr, c1, c2); cairo_line_to(cr, c3, c4); cairo_line_to(cr, c5, c6); cairo_line_to(cr, c7, c8); cairo_close_path(cr); cairo_stroke(cr); cairo_restore(cr); } -------------- next part -------------- An HTML attachment was scrubbed... URL: From wvick at europa.uk.com Tue Jun 25 06:24:23 2019 From: wvick at europa.uk.com (Warren Vick) Date: Tue, 25 Jun 2019 06:24:23 +0000 Subject: [cairo] Text stuffing with Cairo/pycairo? In-Reply-To: References: <695485279.2814876.1556646482268.ref@mail.yahoo.com> <695485279.2814876.1556646482268@mail.yahoo.com> <573610459.3407508.1556732455404@mail.yahoo.com> Message-ID: Curiously, when I just select the font face as simply “Times”, the output is different (serif) and Acrobat reports the embedded font as “TimesNewRomanPSMT”. I don’t have a font of that name installed, as far as I’m aware! Regards, Warren From: cairo On Behalf Of Warren Vick Sent: 25 June 2019 07:10 To: cairo at cairographics.org Subject: Re: [cairo] Text stuffing with Cairo/pycairo? I’ve made some good progress working with pyCairo after porting Eric’s C code below. I am, however, having a problem with selecting fonts… I’m using pyCairo on Windows. No matter what font I select using select_font_face on a context, I seem to get Arial output in my PDF. Does pyCairo pick-up fonts installed on Windows or do the TTF files need to be copied somewhere specific? Or, have I misunderstood what is meant by the face name? e.g. “Noto Sans Condensed”. Regards, Warren From: cecashon at aol.com > Sent: 01 May 2019 18:41 To: Warren Vick >; cairo at cairographics.org Subject: Re: [cairo] Text stuffing with Cairo/pycairo? It is worth mentioning here that when you draw lines around the box with the usual way of doing this, cairo_fill_preserve(cr); cairo_set_source_rgba(cr, 0.0, 0.0, 0.0, 1.0); cairo_stroke(cr); the scale will cause the lines to be non uniform. This is mentioned in the Cairo Tutorial under Working with Transforms. To get the lines around the box to be uniform, the transformed points can be mapped to device space or the starting coordinates that cairo uses. Then the lines around the box can be drawn. The following shows this. Have fun drawing. Eric ... //Order transforms and draw. cairo_save(cr); cairo_translate(cr, center_box_x, center_box_y); cairo_rotate(cr, rotate); cairo_scale(cr, box_width/fabs(2.0*move_x), box_height/fabs(2.0*move_y)); cairo_set_source_rgba(cr, 0.0, 1.0, 0.0, 0.4); double r1=-fabs(scale_x); double r2=-fabs(scale_y); double r3=fabs(2.0*scale_x); double r4=fabs(2.0*scale_y); cairo_rectangle(cr, r1, r2, r3, r4); cairo_fill(cr); //Save device cordinates for the rectangle so that lines are drawn correctly. double c1=r1; double c2=r2; double c3=r1; double c4=r2+r4; double c5=r1+r3; double c6=r2+r4; double c7=r1+r3; double c8=r2; cairo_user_to_device(cr, &c1, &c2); cairo_user_to_device(cr, &c3, &c4); cairo_user_to_device(cr, &c5, &c6); cairo_user_to_device(cr, &c7, &c8); cairo_set_source_rgba(cr, 0.0, 0.0, 0.0, 1.0); cairo_move_to(cr, move_x, move_y); cairo_show_text(cr, string); cairo_restore(cr); //Draw box lines. cairo_save(cr); cairo_set_source_rgba(cr, 0.0, 0.0, 1.0, 1.0); cairo_set_line_width(cr, 4.0); //Reset transform matrix. cairo_identity_matrix(cr); cairo_move_to(cr, c1, c2); cairo_line_to(cr, c3, c4); cairo_line_to(cr, c5, c6); cairo_line_to(cr, c7, c8); cairo_close_path(cr); cairo_stroke(cr); cairo_restore(cr); } -------------- next part -------------- An HTML attachment was scrubbed... URL: From simon at ctsn.co.uk Tue Jun 25 11:16:35 2019 From: simon at ctsn.co.uk (Simon Elliott) Date: Tue, 25 Jun 2019 12:16:35 +0100 Subject: [cairo] Cairo and Wayland Message-ID: <278807a0-6236-c7b1-287f-2181f85b06fb@ctsn.co.uk> I want to use Cairo with Wayland on an embedded system. I found this tutorial: https://jan.newmarch.name/Wayland/Cairo/ and this article from the mailing list archive: https://lists.cairographics.org/archives/cairo/2017-June/028168.html both of which suggested I needed to use wl_egl_window -> EGLSurface -> cairo_surface_t So I started to write some sample code on Ubuntu 18.04 to try this out, and found that Cairo GL/EGL support is disabled. This report is back from 2014 but it seems that support is still not enabled. https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=765684 This leaves me with a few questions: Q1: is wl_egl_window -> EGLSurface -> cairo_surface_t still considered the right way to use Cairo with Wayland? Or is there a better way? Q2: is the Cairo GL/EGL backend still experimental? Thanks! From tarnyko at tarnyko.net Wed Jun 26 07:56:05 2019 From: tarnyko at tarnyko.net (Tarnyko) Date: Wed, 26 Jun 2019 09:56:05 +0200 Subject: [cairo] Cairo and Wayland In-Reply-To: <278807a0-6236-c7b1-287f-2181f85b06fb@ctsn.co.uk> References: <278807a0-6236-c7b1-287f-2181f85b06fb@ctsn.co.uk> Message-ID: Hi Simon, About your foreword: - Ubuntu doesn't need the "--enable-egl=yes" option until they officially support a Wayland compositor ; - Ubuntu doesn't need the "--enable-glesv2=yes" option until they remove X11 completely (regardless of whether or not Wayland is supported). About Q1: Look here for a recent (May) sample of using Cairo-GLES : https://github.com/wayland-project/weston/blob/master/clients/window.c#L561 Regards, Tarnyko Simon Elliott writes: > I want to use Cairo with Wayland on an embedded system. > > I found this tutorial: https://jan.newmarch.name/Wayland/Cairo/ > and this article from the mailing list archive: > https://lists.cairographics.org/archives/cairo/2017-June/028168.html > > both of which suggested I needed to use wl_egl_window -> EGLSurface -> > cairo_surface_t > > So I started to write some sample code on Ubuntu 18.04 to try this out, > and found that Cairo GL/EGL support is disabled. This report is back from > 2014 but it seems that support is still not enabled. > https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=765684 > > This leaves me with a few questions: > > Q1: is wl_egl_window -> EGLSurface -> cairo_surface_t still considered the > right way to use Cairo with Wayland? Or is there a better way? > > Q2: is the Cairo GL/EGL backend still experimental? > > Thanks! > > -- > cairo mailing list > cairo at cairographics.org > https://lists.cairographics.org/mailman/listinfo/cairo From wvick at europa.uk.com Wed Jun 26 09:25:56 2019 From: wvick at europa.uk.com (Warren Vick) Date: Wed, 26 Jun 2019 09:25:56 +0000 Subject: [cairo] Text stuffing with Cairo/pycairo? In-Reply-To: References: <695485279.2814876.1556646482268.ref@mail.yahoo.com> <695485279.2814876.1556646482268@mail.yahoo.com> <573610459.3407508.1556732455404@mail.yahoo.com> Message-ID: I’ve managed to answer my own question so here it is, just in case it’s useful for anyone else in the future. Cairo’s built-in font support is quite basic, which is the reason why they’re referred to as “toy fonts”. The documentation concedes that Cairo alone will probably not be sufficient for professional standard work and recommends a pairing with the Pango project. For my immediate project, I’m going to have to stick to Arial now, but that’s not the end of the world since it’s not a bad font for my intended purpose. While the docs say any CSS2 style face name will work (e.g. “serif, sans-serif”), in Windows, the only font faces that seem to work for me are “Arial” and “Times”. “Courier” goes very wrong! Having worked with it for a few days now, I quite like Cairo, but feel it’s a shame the text support is not as strong as I’d hoped for. Regards, Warren From: cairo On Behalf Of Warren Vick Sent: 25 June 2019 07:24 To: cairo at cairographics.org Subject: Re: [cairo] Text stuffing with Cairo/pycairo? Curiously, when I just select the font face as simply “Times”, the output is different (serif) and Acrobat reports the embedded font as “TimesNewRomanPSMT”. I don’t have a font of that name installed, as far as I’m aware! Regards, Warren From: cairo > On Behalf Of Warren Vick Sent: 25 June 2019 07:10 To: cairo at cairographics.org Subject: Re: [cairo] Text stuffing with Cairo/pycairo? I’ve made some good progress working with pyCairo after porting Eric’s C code below. I am, however, having a problem with selecting fonts… I’m using pyCairo on Windows. No matter what font I select using select_font_face on a context, I seem to get Arial output in my PDF. Does pyCairo pick-up fonts installed on Windows or do the TTF files need to be copied somewhere specific? Or, have I misunderstood what is meant by the face name? e.g. “Noto Sans Condensed”. Regards, Warren From: cecashon at aol.com > Sent: 01 May 2019 18:41 To: Warren Vick >; cairo at cairographics.org Subject: Re: [cairo] Text stuffing with Cairo/pycairo? It is worth mentioning here that when you draw lines around the box with the usual way of doing this, cairo_fill_preserve(cr); cairo_set_source_rgba(cr, 0.0, 0.0, 0.0, 1.0); cairo_stroke(cr); the scale will cause the lines to be non uniform. This is mentioned in the Cairo Tutorial under Working with Transforms. To get the lines around the box to be uniform, the transformed points can be mapped to device space or the starting coordinates that cairo uses. Then the lines around the box can be drawn. The following shows this. Have fun drawing. Eric ... //Order transforms and draw. cairo_save(cr); cairo_translate(cr, center_box_x, center_box_y); cairo_rotate(cr, rotate); cairo_scale(cr, box_width/fabs(2.0*move_x), box_height/fabs(2.0*move_y)); cairo_set_source_rgba(cr, 0.0, 1.0, 0.0, 0.4); double r1=-fabs(scale_x); double r2=-fabs(scale_y); double r3=fabs(2.0*scale_x); double r4=fabs(2.0*scale_y); cairo_rectangle(cr, r1, r2, r3, r4); cairo_fill(cr); //Save device cordinates for the rectangle so that lines are drawn correctly. double c1=r1; double c2=r2; double c3=r1; double c4=r2+r4; double c5=r1+r3; double c6=r2+r4; double c7=r1+r3; double c8=r2; cairo_user_to_device(cr, &c1, &c2); cairo_user_to_device(cr, &c3, &c4); cairo_user_to_device(cr, &c5, &c6); cairo_user_to_device(cr, &c7, &c8); cairo_set_source_rgba(cr, 0.0, 0.0, 0.0, 1.0); cairo_move_to(cr, move_x, move_y); cairo_show_text(cr, string); cairo_restore(cr); //Draw box lines. cairo_save(cr); cairo_set_source_rgba(cr, 0.0, 0.0, 1.0, 1.0); cairo_set_line_width(cr, 4.0); //Reset transform matrix. cairo_identity_matrix(cr); cairo_move_to(cr, c1, c2); cairo_line_to(cr, c3, c4); cairo_line_to(cr, c5, c6); cairo_line_to(cr, c7, c8); cairo_close_path(cr); cairo_stroke(cr); cairo_restore(cr); } -------------- next part -------------- An HTML attachment was scrubbed... URL: From cecashon at aol.com Thu Jun 27 18:55:13 2019 From: cecashon at aol.com (cecashon at aol.com) Date: Thu, 27 Jun 2019 18:55:13 +0000 (UTC) Subject: [cairo] Text stuffing with Cairo/pycairo? References: <1863738645.892778.1561661713391.ref@mail.yahoo.com> Message-ID: <1863738645.892778.1561661713391@mail.yahoo.com> Hi Warren, I don't have a windows computer to test with. On linux, cairo is usually built with freetype support. This is probably why even the "toy fonts" work pretty good. On windows, you might not have cairo built with freetype support. Cairo does have the following https://cairographics.org/manual/cairo-Win32-Fonts.html to try out. Or, try to find a build with freetype support and use freetype to get specific fonts on windows. Eric -------------- next part -------------- An HTML attachment was scrubbed... URL: