GNOME Bugzilla – Bug 742630
libgxps does not support static resource in a page
Last modified: 2017-06-10 08:45:29 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>
Yes, libgxps doesn't support resource dictionaries yet
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.
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.
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.
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.
(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!
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.
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.
opened bug 751357 for ImageBrush
Comment on attachment 303959 [details] [review] [2/2] Fix transformation for VisualBrush elements I've pushed this one to git master as well, thanks!
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.
*** Bug 703639 has been marked as a duplicate of this bug. ***
This is now fixed in master.