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 742630 - libgxps does not support static resource in a page
libgxps does not support static resource in a page
Status: RESOLVED FIXED
Product: libgxps
Classification: Platform
Component: general
0.2.x
Other Linux
: Normal normal
: ---
Assigned To: libgxps maintainers
libgxps maintainers
: 703639 (view as bug list)
Depends on:
Blocks: 703639
 
 
Reported: 2015-01-09 07:35 UTC by Kriss Liu
Modified: 2017-06-10 08:45 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
the test xps (42.67 KB, application/vnd.ms-xpsdocument)
2015-01-09 07:35 UTC, Kriss Liu
  Details
[1/2] Add partial support for-resource dictionaries (36.25 KB, patch)
2015-05-26 01:52 UTC, Jason Crain
none Details | Review
[2/2] Fix transformation for VisualBrush elements (4.68 KB, patch)
2015-05-26 01:54 UTC, Jason Crain
committed Details | Review
resources brush (2.47 KB, patch)
2017-01-26 20:50 UTC, Ignacio Casal Quinteiro (nacho)
none Details | Review

Description Kriss Liu 2015-01-09 07:35:39 UTC
Created attachment 294140 [details]
the test xps

When I tried to convert a XPS file to SVG file, I got an error message:

Error rendering page 1: Error rendering page /Documents/1/Pages/1.fpage: /Documents/1/Pages/1.fpage:16:202 invalid content in attribute 'Fill' of element 'Path': {StaticResource b1}


The content in page 1 looks like:

<LinearGradientBrush x:Key="b1" StartPoint="20.000004426845,-0.382808678279619" EndPoint="20.000004426845,39.6171746178818" ColorInterpolationMode="SRgbLinearInterpolation" MappingMode="Absolute" SpreadMethod="Pad">
    <LinearGradientBrush.GradientStops>
        <GradientStop Color="#FF3A3019" Offset="0" />
        <GradientStop Color="#FF776D5E" Offset="1" />
    </LinearGradientBrush.GradientStops>
</LinearGradientBrush>

<VisualBrush x:Key="b2" ViewportUnits="Absolute" TileMode="None" ViewboxUnits="Absolute" Viewbox="8.85368990566349E-06,-3.81469999410911E-06,39.9999911463101,38.6249046325711" Viewport="0,0,30,30">
    <VisualBrush.Visual>
        <Canvas>
            <Path Fill="{StaticResource b1}" Data="F1M40,38.6249L8.85369E-06,38.6249 8.85369E-06,6.62492 6.03388,6.62492 6.04428,0.0103912 33.9928,-3.8147E-06 34.0129,6.62492 40,6.62492 40,38.6249Z" />
        </Canvas>
    </VisualBrush.Visual>
</VisualBrush>
Comment 1 Carlos Garcia Campos 2015-01-10 10:06:04 UTC
Yes, libgxps doesn't support resource dictionaries yet
Comment 2 Kriss Liu 2015-01-12 07:53:27 UTC
Will resource dictionary be supported in plan? I saw libxps has not been updated for a long time. I really need it to convert my xps file to svg. Thanks.
Comment 3 Carlos Garcia Campos 2015-01-12 13:24:15 UTC
Unfortunately I don't have enough free time to work on this at the moment. But, of course, patches are welcome, and I'll have time for sure to review any patches.
Comment 4 Jason Crain 2015-05-26 01:52:50 UTC
Created attachment 303958 [details] [review]
[1/2] Add partial support for-resource dictionaries

This patch adds partial support for resource dictionaries and remote resource dictionaries.  It adds support for brushes and transformation matrices, but does not add PathGeometry, Path, Glyphs, or Canvas elements because I didn't see a simple way of doing it.
Comment 5 Jason Crain 2015-05-26 01:54:04 UTC
Created attachment 303959 [details] [review]
[2/2] Fix transformation for VisualBrush elements

This patch fixes the transformation for VisualBrush elements.  Otherwise some of the paths in this document get filled incorrectly.
Comment 6 Carlos Garcia Campos 2015-06-04 11:14:46 UTC
(In reply to Jason Crain from comment #5)
> Created attachment 303959 [details] [review] [review]
> [2/2] Fix transformation for VisualBrush elements
> 
> This patch fixes the transformation for VisualBrush elements.  Otherwise
> some of the paths in this document get filled incorrectly.

This looks like a different issue then. Could you explain what's wrong? Are transformations of ImageBrush also wrong? or this is specific to VisualBrush? Thanks!
Comment 7 Jason Crain 2015-06-05 09:01:25 UTC
The VisualBrush stuff doesn't take into account the output surface's scaling, so it will draw with an incorrect scaling at anything other than 96 ppi.  Lower than 96 ppi and the VisualBrush will be scaled too small, higher than 96 and it will be scaled too large.  The VisualBrush will move around as you change zoom levels in evince.

That could be fixed by multiplying in the pattern's default matrix, example:

--- a/libgxps/gxps-brush.c
+++ b/libgxps/gxps-brush.c
@@ -1030,6 +1030,8 @@ brush_end_element (GMarkupParseContext  *context,
                                    -port_matrix.x0 * x_scale,
                                    -port_matrix.y0 * y_scale);
 
+                cairo_pattern_get_matrix (visual->brush->pattern, &tmp_matrix);
+                cairo_matrix_multiply (&matrix, &matrix, &tmp_matrix);
                 cairo_pattern_set_matrix (visual->brush->pattern, &matrix);
                 if (cairo_pattern_status (visual->brush->pattern)) {
                         GXPS_DEBUG (g_debug ("%s", cairo_status_to_string (cairo_pattern_status (visual->brush->pattern))));

But then I noticed other problems too.  You could set up the viewbox, viewport, and matrix so that the VisualBrush is drawn at an inappropriate resolution, leading to either pixelation or excessive memory consumption.  Part of that patch works to find a good surface size.  And it didn't really handle rotation or shearing.
Comment 8 Jason Crain 2015-06-05 10:01:11 UTC
I'll take a closer look at ImageBrush.  I think that it's not right with regard to viewbox and a rotation or shearing matrix.
Comment 9 Jason Crain 2015-06-23 07:02:11 UTC
opened bug 751357 for ImageBrush
Comment 10 Carlos Garcia Campos 2015-08-13 10:09:22 UTC
Comment on attachment 303959 [details] [review]
[2/2] Fix transformation for VisualBrush elements

I've pushed this one to git master as well, thanks!
Comment 11 Ignacio Casal Quinteiro (nacho) 2017-01-26 20:50:56 UTC
Created attachment 344356 [details] [review]
resources brush

A patch following the one from #777731 that adds resources support for brushes and seems to at least generate the pdf from the test xps file attached.
Comment 12 Carlos Garcia Campos 2017-01-29 07:58:23 UTC
*** Bug 703639 has been marked as a duplicate of this bug. ***
Comment 13 Ignacio Casal Quinteiro (nacho) 2017-06-10 08:45:29 UTC
This is now fixed in master.