From 3a1d150eb99b5875e6e86117029a72e4c87b0547 Mon Sep 17 00:00:00 2001 From: Luboš Luňák Date: Wed, 5 May 2021 14:20:01 +0200 Subject: scale stroked line properly in cairocanvas MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Line width should be scaled by the scaled vector, not just its X component (see VclMetafileProcessor2D::getTransformedLineWidth()). - Lenths of dashes should not be scaled by the scaled line width, but by the scaling. Testcase document sd/qa/unit/data/pptx/tdf134053_dashdot.pptx . Change-Id: I4116f82e91620f5612f5e4e187468508f683b93e Reviewed-on: https://gerrit.libreoffice.org/c/core/+/115147 Tested-by: Jenkins Reviewed-by: Luboš Luňák --- canvas/source/cairo/cairo_canvashelper.cxx | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'canvas') diff --git a/canvas/source/cairo/cairo_canvashelper.cxx b/canvas/source/cairo/cairo_canvashelper.cxx index d308961a0865..2711634e9948 100644 --- a/canvas/source/cairo/cairo_canvashelper.cxx +++ b/canvas/source/cairo/cairo_canvashelper.cxx @@ -913,10 +913,12 @@ namespace cairocanvas useStates( viewState, renderState, true ); cairo_matrix_t aMatrix; - double w = strokeAttributes.StrokeWidth, h = 0; cairo_get_matrix( mpCairo.get(), &aMatrix ); - cairo_matrix_transform_distance( &aMatrix, &w, &h ); - cairo_set_line_width( mpCairo.get(), w ); + double scaleFactorX = 1; + double scaleFactorY = 0; + cairo_matrix_transform_distance( &aMatrix, &scaleFactorX, &scaleFactorY ); + double scaleFactor = basegfx::B2DVector( scaleFactorX, scaleFactorY ).getLength(); + cairo_set_line_width( mpCairo.get(), strokeAttributes.StrokeWidth * scaleFactor ); cairo_set_miter_limit( mpCairo.get(), strokeAttributes.MiterLimit ); @@ -952,14 +954,14 @@ namespace cairocanvas break; } - //tdf#103026 If the w scaling is 0, then all dashes become zero so + //tdf#103026 If the scaling is 0, then all dashes become zero so //cairo will set the cairo_t status to CAIRO_STATUS_INVALID_DASH //and no further drawing will occur - if (strokeAttributes.DashArray.hasElements() && w > 0.0) + if (strokeAttributes.DashArray.hasElements() && scaleFactor > 0.0) { auto aDashArray(comphelper::sequenceToContainer>(strokeAttributes.DashArray)); for (auto& rDash : aDashArray) - rDash *= w; + rDash *= scaleFactor; cairo_set_dash(mpCairo.get(), aDashArray.data(), aDashArray.size(), 0); } -- cgit