From 0da912bd846bce7469705971c0553bb8a6fc89fc Mon Sep 17 00:00:00 2001 From: wp_xyz Date: Thu, 5 Jan 2023 16:53:42 +0100 Subject: [PATCH] fpvectorial: Fix scaling of pen width in wmf format. --- components/fpvectorial/fpvectorial.pas | 4 +++- components/fpvectorial/fpvutils.pas | 8 +++++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/components/fpvectorial/fpvectorial.pas b/components/fpvectorial/fpvectorial.pas index 29567bd20a..660653272c 100644 --- a/components/fpvectorial/fpvectorial.pas +++ b/components/fpvectorial/fpvectorial.pas @@ -3911,11 +3911,13 @@ end; procedure TvEntityWithPen.ApplyPenToCanvas(constref ARenderInfo: TvRenderInfo; APen: TvPen); var ADest: TFPCustomCanvas absolute ARenderInfo.Canvas; + AMulX: Double absolute ARenderInfo.MulX; + AMulY: Double absolute ARenderInfo.MulY; begin if ADest = nil then exit; ADest.Pen.FPColor := AdjustColorToBackground(APen.Color, ARenderInfo); - ADest.Pen.Width := Max(1, APen.Width); // wp: why was here "1;//APen.Width;" ??? + ADest.Pen.Width := Max(1, FPVSizeToCanvas(APen.Width, Max(AMulX, abs(AMulY)))); ADest.Pen.Style := APen.Style; {$ifdef USE_LCL_CANVAS} if (APen.Style = psPattern) then diff --git a/components/fpvectorial/fpvutils.pas b/components/fpvectorial/fpvutils.pas index 4ba4e4b926..f927b75cbd 100644 --- a/components/fpvectorial/fpvutils.pas +++ b/components/fpvectorial/fpvutils.pas @@ -49,6 +49,7 @@ function CanvasCoordsToFPVectorial(AY: Integer; AHeight: Integer): Integer; inli function CanvasTextPosToFPVectorial(AY: Integer; ACanvasHeight, ATextHeight: Integer): Integer; function CoordToCanvasX(ACoord: Double; ADestX: Integer; AMulX: Double): Integer; inline; function CoordToCanvasY(ACoord: Double; ADestY: Integer; AMulY: Double): Integer; inline; +function FPVSizeToCanvas(ASize, AMul: Double): Integer; // Other routines function SeparateString(AString: string; ASeparator: char): T10Strings; procedure SeparateStringInTwo(AString: string; ASeparator: char; out AStart, AEnd: string); @@ -225,6 +226,11 @@ begin Result := Round(ADestY + AmulY * ACoord); end; +function FPVSizeToCanvas(ASize, AMul: Double): Integer; +begin + Result := Round(ASize * abs(AMul)); +end; + {@@ Reads a string and separates it in substring using ASeparator to delimite them. @@ -244,7 +250,7 @@ begin for i := 0 to 9 do Result[i] := ''; - { Iterates througth the string, filling strings } + { Iterates through the string, filling strings } for i := 1 to Length(AString) do begin if Copy(AString, i, 1) = ASeparator then