From a9f558b56b3343aaef7192b291db25d1c8878fcd Mon Sep 17 00:00:00 2001 From: wp Date: Wed, 13 Jan 2016 15:20:49 +0000 Subject: [PATCH] TAChart: Add "ResetFont" to drawing interface to fix issue #27163 without interfering with nogui widgetset. git-svn-id: trunk@51266 - --- components/tachart/tadrawerbgra.pas | 6 ++++++ components/tachart/tadrawercanvas.pas | 6 ++++++ components/tachart/tadrawerfpcanvas.pas | 6 ++++++ components/tachart/tadrawerfpvectorial.pas | 6 ++++++ components/tachart/tadraweropengl.pas | 5 +++++ components/tachart/tadrawersvg.pas | 6 ++++++ components/tachart/tadrawutils.pas | 1 + components/tachart/tagraph.pas | 11 ++--------- 8 files changed, 38 insertions(+), 9 deletions(-) diff --git a/components/tachart/tadrawerbgra.pas b/components/tachart/tadrawerbgra.pas index fccb747e56..01ecc3af38 100644 --- a/components/tachart/tadrawerbgra.pas +++ b/components/tachart/tadrawerbgra.pas @@ -60,6 +60,7 @@ type AStartAngle16Deg, AAngleLength16Deg: Integer); procedure Rectangle(const ARect: TRect); procedure Rectangle(AX1, AY1, AX2, AY2: Integer); + procedure ResetFont; procedure SetBrushColor(AColor: TChartColor); procedure SetBrushParams(AStyle: TFPBrushStyle; AColor: TChartColor); procedure SetPenParams(AStyle: TFPPenStyle; AColor: TChartColor); @@ -214,6 +215,11 @@ begin Rectangle(Left, Top, Right, Bottom) end; +procedure TBGRABitmapDrawer.ResetFont; +begin + Canvas.Font.Orientation := 0; +end; + procedure TBGRABitmapDrawer.SetAntialiasingMode(AValue: TChartAntialiasingMode); begin Canvas.AntialiasingMode := TAntialiasingMode(AValue); diff --git a/components/tachart/tadrawercanvas.pas b/components/tachart/tadrawercanvas.pas index 3a5888f0ab..877d2cff48 100644 --- a/components/tachart/tadrawercanvas.pas +++ b/components/tachart/tadrawercanvas.pas @@ -65,6 +65,7 @@ type AStartAngle16Deg, AAngleLength16Deg: Integer); procedure Rectangle(const ARect: TRect); procedure Rectangle(AX1, AY1, AX2, AY2: Integer); + procedure ResetFont; procedure SetAntialiasingMode(AValue: TChartAntialiasingMode); procedure SetBrushColor(AColor: TChartColor); procedure SetBrushParams(AStyle: TFPBrushStyle; AColor: TChartColor); @@ -264,6 +265,11 @@ begin GetCanvas.Rectangle(ARect); end; +procedure TCanvasDrawer.ResetFont; +begin + GetCanvas.Font.Orientation := 0; +end; + procedure TCanvasDrawer.SetAntialiasingMode(AValue: TChartAntialiasingMode); begin GetCanvas.AntialiasingMode := TAntialiasingMode(AValue); diff --git a/components/tachart/tadrawerfpcanvas.pas b/components/tachart/tadrawerfpcanvas.pas index bf94a28880..bad9025f7f 100644 --- a/components/tachart/tadrawerfpcanvas.pas +++ b/components/tachart/tadrawerfpcanvas.pas @@ -65,6 +65,7 @@ type AStartAngle16Deg, AAngleLength16Deg: Integer); procedure Rectangle(const ARect: TRect); procedure Rectangle(AX1, AY1, AX2, AY2: Integer); + procedure ResetFont; procedure SetBrushColor(AColor: TChartColor); procedure SetBrushParams(AStyle: TFPBrushStyle; AColor: TChartColor); procedure SetPenParams(AStyle: TFPPenStyle; AColor: TChartColor); @@ -231,6 +232,11 @@ begin FCanvas.Rectangle(ARect); end; +procedure TFPCanvasDrawer.ResetFont; +begin + FCanvas.Font.Orientation := 0; +end; + procedure TFPCanvasDrawer.SetBrush(ABrush: TFPCustomBrush); begin AssignFPCanvasHelper(FCanvas.Brush, ABrush); diff --git a/components/tachart/tadrawerfpvectorial.pas b/components/tachart/tadrawerfpvectorial.pas index 4dffa2111c..27ae538c77 100644 --- a/components/tachart/tadrawerfpvectorial.pas +++ b/components/tachart/tadrawerfpvectorial.pas @@ -68,6 +68,7 @@ type AStartAngle16Deg, AAngleLength16Deg: Integer); procedure Rectangle(const ARect: TRect); procedure Rectangle(AX1, AY1, AX2, AY2: Integer); + procedure ResetFont; procedure SetBrushColor(AColor: TChartColor); procedure SetBrushParams(AStyle: TFPBrushStyle; AColor: TChartColor); procedure SetPenParams(AStyle: TFPPenStyle; AColor: TChartColor); @@ -303,6 +304,11 @@ begin Rectangle(Left, Top, Right, Bottom); end; +procedure TFPVectorialDrawer.ResetFont; +begin + FFont.Orientation := 0; +end; + procedure TFPVectorialDrawer.SetBrush(ABrush: TFPCustomBrush); begin if ABrush is TBrush then diff --git a/components/tachart/tadraweropengl.pas b/components/tachart/tadraweropengl.pas index 0c6c807f2d..80fee6208e 100644 --- a/components/tachart/tadraweropengl.pas +++ b/components/tachart/tadraweropengl.pas @@ -61,6 +61,7 @@ type AStartAngle16Deg, AAngleLength16Deg: Integer); procedure Rectangle(const ARect: TRect); procedure Rectangle(AX1, AY1, AX2, AY2: Integer); + procedure ResetFont; procedure SetAntialiasingMode(AValue: TChartAntialiasingMode); procedure SetBrushColor(AColor: TChartColor); procedure SetBrushParams(AStyle: TFPBrushStyle; AColor: TChartColor); @@ -254,6 +255,10 @@ begin Rectangle(ARect.Left, ARect.Top, ARect.Right, ARect.Bottom); end; +procedure TOpenGLDrawer.ResetFont; +begin +end; + procedure TOpenGLDrawer.SetAntialiasingMode(AValue: TChartAntialiasingMode); begin case AValue of diff --git a/components/tachart/tadrawersvg.pas b/components/tachart/tadrawersvg.pas index 1d67ca6ad1..83c58263b7 100644 --- a/components/tachart/tadrawersvg.pas +++ b/components/tachart/tadrawersvg.pas @@ -89,6 +89,7 @@ type AStartAngle16Deg, AAngleLength16Deg: Integer); procedure Rectangle(const ARect: TRect); procedure Rectangle(AX1, AY1, AX2, AY2: Integer); + procedure ResetFont; procedure SetAntialiasingMode(AValue: TChartAntialiasingMode); procedure SetBrushColor(AColor: TChartColor); procedure SetBrushParams(AStyle: TFPBrushStyle; AColor: TChartColor); @@ -378,6 +379,11 @@ begin Rectangle(Left, Top, Right, Bottom); end; +procedure TSVGDrawer.ResetFont; +begin + FFont.Orientation := 0; +end; + procedure TSVGDrawer.SetAntialiasingMode(AValue: TChartAntialiasingMode); const AM_TO_CSS: array [amOn .. amOff] of String = diff --git a/components/tachart/tadrawutils.pas b/components/tachart/tadrawutils.pas index 3bad72051b..cd5844bc29 100644 --- a/components/tachart/tadrawutils.pas +++ b/components/tachart/tadrawutils.pas @@ -90,6 +90,7 @@ type AStartAngle16Deg, AAngleLength16Deg: Integer); procedure Rectangle(const ARect: TRect); procedure Rectangle(AX1, AY1, AX2, AY2: Integer); + procedure ResetFont; function Scale(ADistance: Integer): Integer; procedure SetAntialiasingMode(AValue: TChartAntialiasingMode); procedure SetBrushColor(AColor: TChartColor); diff --git a/components/tachart/tagraph.pas b/components/tachart/tagraph.pas index f09e05bf55..599efc3f08 100644 --- a/components/tachart/tagraph.pas +++ b/components/tachart/tagraph.pas @@ -817,7 +817,6 @@ procedure TChart.Draw(ADrawer: IChartDrawer; const ARect: TRect); var ldd: TChartLegendDrawingData; s: TBasicChartSeries; - fnt: TFont; begin Prepare; @@ -882,14 +881,8 @@ begin // Undo changes made by the drawer (mainly for printing). The user may print // something else after the chart and, for example, would not expect the font - // to be rotated. - // (Workaround for issue #0027163) - fnt := TFont.Create; // to effectively reset font orientation - try - ADrawer.Font := fnt; - finally - fnt.Free; - end; + // to be rotated (Fix for issue #0027163) + ADrawer.ResetFont; ADrawer.SetPenParams(psSolid, clDefault); ADrawer.SetBrushParams(bsSolid, clWhite); ADrawer.SetAntialiasingMode(amDontCare);