From 53bfba817df41c4aa5b7f9d794966bab3f40b5c3 Mon Sep 17 00:00:00 2001 From: dmester Date: Thu, 8 Jul 2021 13:36:48 +0200 Subject: [PATCH] Bug fix: line style changes didn't invalidate text style. --- src/PdfToSvg/Drawing/SvgRenderer.cs | 37 ++++++++++++++++++++++++----- 1 file changed, 31 insertions(+), 6 deletions(-) diff --git a/src/PdfToSvg/Drawing/SvgRenderer.cs b/src/PdfToSvg/Drawing/SvgRenderer.cs index 0e52613..b62f22a 100644 --- a/src/PdfToSvg/Drawing/SvgRenderer.cs +++ b/src/PdfToSvg/Drawing/SvgRenderer.cs @@ -343,28 +343,44 @@ private void cm_SetMatrix(double a, double b, double c, double d, double e, doub [Operation("gs/LW")] private void w_LineWidth(double lineWidth) { - graphicsState.StrokeWidth = lineWidth; + if (graphicsState.StrokeWidth != lineWidth) + { + graphicsState.StrokeWidth = lineWidth; + textBuilder.InvalidateStyle(); + } } [Operation("J")] [Operation("gs/LC")] private void J_LineCap(int lineCap) { - graphicsState.StrokeLineCap = lineCap; + if (graphicsState.StrokeLineCap != lineCap) + { + graphicsState.StrokeLineCap = lineCap; + textBuilder.InvalidateStyle(); + } } [Operation("j")] [Operation("gs/LJ")] private void j_LineJoin(int lineJoin) { - graphicsState.StrokeLineJoin = lineJoin; + if (graphicsState.StrokeLineJoin != lineJoin) + { + graphicsState.StrokeLineJoin = lineJoin; + textBuilder.InvalidateStyle(); + } } [Operation("M")] [Operation("gs/ML")] private void M_MiterLimit(double miterLimit) { - graphicsState.StrokeMiterLimit = miterLimit; + if (graphicsState.StrokeMiterLimit != miterLimit) + { + graphicsState.StrokeMiterLimit = miterLimit; + textBuilder.InvalidateStyle(); + } } [Operation("d")] @@ -372,6 +388,7 @@ private void d_DashArray(int[] dashArray, int dashPhase) { graphicsState.StrokeDashArray = dashArray; graphicsState.StrokeDashPhase = dashPhase; + textBuilder.InvalidateStyle(); } [Operation("gs/D")] @@ -383,13 +400,21 @@ private void gs_D_DashArray(object[] args) [Operation("gs/CA")] private void gs_CA_StrokeAlpha(double alpha) { - graphicsState.StrokeAlpha = alpha; + if (graphicsState.StrokeAlpha != alpha) + { + graphicsState.StrokeAlpha = alpha; + textBuilder.InvalidateStyle(); + } } [Operation("gs/ca")] private void gs_ca_FillAlpha(double alpha) { - graphicsState.FillAlpha = alpha; + if (graphicsState.FillAlpha != alpha) + { + graphicsState.FillAlpha = alpha; + textBuilder.InvalidateStyle(); + } } [Operation("gs")]