After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 752148 - Drawing from paths passed to cairo does not work with PANGOCAIRO_BACKEND=coretext
Drawing from paths passed to cairo does not work with PANGOCAIRO_BACKEND=core...
Status: RESOLVED FIXED
Product: GStreamer
Classification: Platform
Component: gst-plugins-base
git master
Other Mac OS
: Normal normal
: 1.6.0
Assigned To: GStreamer Maintainers
GStreamer Maintainers
Depends on:
Blocks:
 
 
Reported: 2015-07-08 22:50 UTC by Kyrylo V. Polezhaiev
Modified: 2015-09-22 16:34 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
How textoverlay's shadows looks when they're generated on OS X (228.35 KB, image/png)
2015-07-08 22:50 UTC, Kyrylo V. Polezhaiev
Details
on linux everything fine (302.28 KB, image/png)
2015-07-08 22:54 UTC, Kyrylo V. Polezhaiev
Details
gst-launch-1.0 videotestsrc num-buffers=1 ! te xtoverlay text="grasshoper" font-desc="Sans 72" valignment=4 ! pngenc ! filesink location=1.png (23.47 KB, image/png)
2015-07-12 16:13 UTC, Kyrylo V. Polezhaiev
Details
Pangon+Cairo+Coretext with newlines (215.92 KB, image/png)
2015-09-09 13:47 UTC, Kyrylo V. Polezhaiev
Details
Few more examples (903.25 KB, application/zip)
2015-09-09 13:49 UTC, Kyrylo V. Polezhaiev
Details
Output of simple GTK+ test program (69.56 KB, image/png)
2015-09-11 21:04 UTC, Kristian Rietveld
Details

Description Kyrylo V. Polezhaiev 2015-07-08 22:50:47 UTC
Created attachment 307112 [details]
How textoverlay's shadows looks when they're generated on OS X

They're obviously spoiled.
Comment 1 Kyrylo V. Polezhaiev 2015-07-08 22:52:13 UTC
Maybe this is not shadow (I didn't look carefully first time): I can see shadows also. This is some other kind of trash.
Comment 2 Kyrylo V. Polezhaiev 2015-07-08 22:54:27 UTC
Created attachment 307113 [details]
on linux everything fine
Comment 3 Nicolas Dufresne (ndufresne) 2015-07-09 13:53:25 UTC
Is that with the same version of fontconfig, freetype and pango ?
Comment 4 Kyrylo V. Polezhaiev 2015-07-09 14:24:16 UTC
Nope, I will try fontconfig, freetype and pango outside GStreamer.
Comment 5 Julien Isorce 2015-07-10 23:27:24 UTC
Works fine here using macports: fontconfig 2.11.1, freetype 17.4.11 and pango 1.36.8

What is your command line exactly ?
Comment 6 Kyrylo V. Polezhaiev 2015-07-12 15:56:05 UTC
My freetype version is 2.6 (from brew), pango and fontconfig versions same.
My pipeline isn't created from command line, it's a bit very difficult and created via GStreamer native C API.
Comment 7 Kyrylo V. Polezhaiev 2015-07-12 16:13:43 UTC
Created attachment 307311 [details]
gst-launch-1.0 videotestsrc num-buffers=1 ! te xtoverlay text="grasshoper" font-desc="Sans 72" valignment=4 ! pngenc ! filesink location=1.png

Okay, cause of https://bugzilla.gnome.org/show_bug.cgi?id=752147 and https://bugzilla.gnome.org/show_bug.cgi?id=752146 I can not output this to screen, however, here is the way I have similar glitch with command line:
Comment 8 Julien Isorce 2015-07-13 21:52:10 UTC
I wonder if this is a GStreamer bug. Maybe try some pango examples (out of GStreamer) and let me know.
Comment 9 Kyrylo V. Polezhaiev 2015-07-22 23:53:43 UTC
This issue disappears with PANGOCAIRO_BACKEND=fontconfig
Comment 10 Nicolas Dufresne (ndufresne) 2015-09-08 14:22:53 UTC
To me, this looks like the code to get the vectorial paths from the font is broken with coretext, I believe coretext backen is completly broken. Looks like a bug to report to Pango, not GStreamer (a standalone pango text could be nice).
Comment 11 Julien Isorce 2015-09-08 14:37:34 UTC
Could we just change the product field of this bug from GStreamer to Pango ? At least to check if they know the problem. If not then make a standalone app.

From GStreamer side we can still track the problem here https://bugzilla.gnome.org/show_bug.cgi?id=752147
Which has an attached patch. That set the backend to FT.
Comment 12 Nicolas Dufresne (ndufresne) 2015-09-08 15:08:46 UTC
Let's try.
Comment 13 Kristian Rietveld 2015-09-08 15:21:19 UTC
(In reply to Nicolas Dufresne (stormer) from comment #10)
> To me, this looks like the code to get the vectorial paths from the font is
> broken with coretext, I believe coretext backen is completly broken

What leads you to believe the coretext 'backen' is completely broken? It is actually working well for many GTK+ applications.

A standalone Pango test case that demonstrates the problem would be appreciated.
Comment 14 Nicolas Dufresne (ndufresne) 2015-09-08 16:09:23 UTC
(In reply to Kristian Rietveld from comment #13)
> (In reply to Nicolas Dufresne (stormer) from comment #10)
> > To me, this looks like the code to get the vectorial paths from the font is
> > broken with coretext, I believe coretext backen is completly broken
> What leads you to believe the coretext 'backen' is completely broken? It is
> actually working well for many GTK+ applications.

That's all according to the screenshot. Text looks like text but has nothing to do with the given description (at least the result has nothing to do with what fontconfig backend endup producing). Shadow, which theoretically is just a simple translation of that path (to the right and bottom by default) endup as a mess. Reporter might have tested wrong, I have no mean to test anything on OSX. Though, same code should give similar result regardless of the backend.

> A standalone Pango test case that demonstrates the problem would be
> appreciated.

Indeed, anyone that owns a Mac to take care of writing a standalone test, and maybe narrow down the scope ?
Comment 15 Kristian Rietveld 2015-09-08 16:27:30 UTC
(In reply to Nicolas Dufresne (stormer) from comment #14)
> > A standalone Pango test case that demonstrates the problem would be
> > appreciated.
> 
> Indeed, anyone that owns a Mac to take care of writing a standalone test,
> and maybe narrow down the scope ?

If somebody can point out what the steps to reproduce are or point me to the related code in GStreamer, I can also try to write the testcase.
Comment 16 Nicolas Dufresne (ndufresne) 2015-09-08 17:54:13 UTC
That would be really appreciated of course. Here's the line where the shadow is drawn.

http://cgit.freedesktop.org/gstreamer/gst-plugins-base/tree/ext/pango/gstbasetextoverlay.c#n1747

Which is followed by outline and the foreground/text. One interesting part is that there is very little difference between drawing the shadow and drawing the foreground text. The two differences is that the foreground attributes are filtered-out for this rendering, which gives option a) disabling a specific foreground attribute breaks the rendering. The second difference is that we translate the rendering, so option b) would be the something goes terribly wrong (aka overflow) upon translation.

But before stating that, I want to retract the comment about the rest being broken. I just notice that font-desc (the font description) is "Sans", which could match pretty much be any kind font type. So I believe the font rendering part might be fine (except that you'll notice this is a Serif font, not Sans).

A second thought is that this mess could actually be the outline rather then the shadow. Both shadow and foreground uses pango_cairo_show_layout (cr, overlay->layout);, while the outline uses pango_cairo_layout_path(). So it give a likely option c) that pango_cairo_layout_path() is broken with coretext. This is reinforced by the fact that something look like a shadow on the leg of the P.
Comment 17 Kyrylo V. Polezhaiev 2015-09-09 13:47:19 UTC
Created attachment 310979 [details]
Pangon+Cairo+Coretext with newlines
Comment 18 Kyrylo V. Polezhaiev 2015-09-09 13:49:23 UTC
Created attachment 310980 [details]
Few more examples

That was Liberation Sans Mono.

Here other fonts:
Comment 19 Nicolas Dufresne (ndufresne) 2015-09-09 13:54:58 UTC
Ok, I think these examples makes it very clear that it's the drawing of the outline that fails (which invalidate option a and b). You can confirm this by setting the outline color to 0 (transparent).
Comment 20 Kristian Rietveld 2015-09-11 21:04:06 UTC
Created attachment 311183 [details]
Output of simple GTK+ test program

This is what I get when I put the minimum of the referenced GStreamer code in a GTK+ test program (based on testcairo.c). The outline is rendered in green. It seems to be the outline is rendered correctly in this case (and pango_cairo_layout_path() is used for this, like it is in the GStreamer code). The rendered shadow is visible too.

Now, the GTK+ tester renders to a Cairo context provided by GDK, the GStreamer code renders to an image surface it creates. I wonder whether this makes a difference and that's the next thing to find out.

What I do gather from Kyrylo's images is that the outline is in fact rendered, but it seems at a completely wrong scaling factor.
Comment 21 Kristian Rietveld 2015-09-11 21:35:15 UTC
(In reply to Kyrylo V. Polezhaiev from comment #6)
> My freetype version is 2.6 (from brew), pango and fontconfig versions same.
> My pipeline isn't created from command line, it's a bit very difficult and
> created via GStreamer native C API.

What version of Cairo do you have installed?
Comment 22 Kyrylo V. Polezhaiev 2015-09-11 23:11:06 UTC
1.14.2
Comment 23 Kyrylo V. Polezhaiev 2015-09-11 23:16:40 UTC
Glitch disappears when outline colour's alpha set to 0.
Comment 24 Kyrylo V. Polezhaiev 2015-09-11 23:41:05 UTC
I can reproduce the problem using this example:
http://x11.gp2x.de/personal/google/example2.c
Comment 25 Kyrylo V. Polezhaiev 2015-09-11 23:50:42 UTC
bug appears when you replace

    pango_cairo_show_layout (cr, layout);

with
	
    pango_cairo_update_layout(cr, layout);
    pango_cairo_layout_path(cr, layout);
Comment 26 Kristian Rietveld 2015-09-12 10:04:23 UTC
(In reply to Kyrylo V. Polezhaiev from comment #23)
> Glitch disappears when outline colour's alpha set to 0.

I think that makes sense, because in this case the outline is not visibly drawn at all.



(In reply to Kyrylo V. Polezhaiev from comment #24)
> I can reproduce the problem using this example:
> http://x11.gp2x.de/personal/google/example2.c

To ensure: without modification this code shows you the problem?
Comment 27 Kristian Rietveld 2015-09-12 10:35:51 UTC
I *think* it's a cairo bug, when I downgrade to 1.14.2 from master, the issue appears. Will do a bisect so I can pinpoint the affecting commit for you and see if that commit explains it.
Comment 28 Kristian Rietveld 2015-09-12 13:13:50 UTC
Confirmed that this is a cairo issue. To have it fixed, you need a cairo that includes this commit:

commit 8b798c320f6fd2d87349d0a716304474022bc5ea
Author: Bryce Harrington <bryce@osg.samsung.com>
Date:   Fri Apr 24 18:23:46 2015 -0700

    Fix broken canvas text font size in Inkscape

    An earlier fix to bug 84324 added a regression in the font size of
    canvas text in Inkscape when compiled with the Quartz backend.

    Patch from Andrea Canciani

    Fixes:  https://bugs.freedesktop.org/show_bug.cgi?id=84324
    Reviewed-by: Bryce Harrington <bryce@osg.samsung.com>


However, from what I can gather the last cairo release is 1.14.2, which does *not* include this commit. So you need to fetch cairo from git or wait for the next release.

Do you want to reassign this bug back to gstreamer or should we close it here?
Comment 29 Kyrylo V. Polezhaiev 2015-09-12 13:42:12 UTC
Let's mark as duplicate?
Comment 30 Nicolas Dufresne (ndufresne) 2015-09-13 16:09:24 UTC
Thanks a lot for going through this, it is really appreciated.
Comment 31 Kyrylo V. Polezhaiev 2015-09-13 17:01:25 UTC
(In reply to Kristian Rietveld from comment #26)
> To ensure: without modification this code shows you the problem?
Yes, and I can switch problem on / off via switching between pango_cairo_show_layout (cr, layout) and pango_cairo_layout_path (cr, layout)
Comment 32 Nicolas Dufresne (ndufresne) 2015-09-22 14:03:39 UTC
Interesting, there is a workaround without updating pango?
Comment 33 Kristian Rietveld 2015-09-22 14:28:25 UTC
(In reply to Nicolas Dufresne (stormer) from comment #32)
> Interesting, there is a workaround without updating pango?

Again: it is not a bug in Pango, it is a bug in cairo. I am not sure you can workaround it without updating cairo, the problem is a wrong parameter that is passed to a font creation call by cairo. It is probably also not worth investigating a workaround as you can simply use Cairo master or wait for Cairo 1.14.4 which from what I have heard will be released shortly.

Resolving as not GNOME, since this is not a Pango issue.
Comment 34 Julien Isorce 2015-09-22 14:40:24 UTC
Moved back to GStreamer to keep it around until we bump cerbero's cairo recipe to 1.14.4: http://cgit.freedesktop.org/gstreamer/cerbero/tree/recipes/cairo.recipe
Comment 35 Nicolas Dufresne (ndufresne) 2015-09-22 15:46:19 UTC
I prefer a clean bug in fact.

*** This bug has been marked as a duplicate of bug 755423 ***
Comment 36 Nicolas Dufresne (ndufresne) 2015-09-22 16:34:30 UTC
Fixed by https://bugzilla.gnome.org/show_bug.cgi?id=755423