mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-10-23 11:22:36 +02:00
TAChart: Fix sub/superscripts for OpenGL, bgra, wmf and aggpas drawers (aggpas still has issues with text positioning).
git-svn-id: trunk@55432 -
This commit is contained in:
parent
b6a11cc0d9
commit
0b870a2687
@ -28,7 +28,6 @@ type
|
||||
procedure SetPen(APen: TFPCustomPen);
|
||||
strict protected
|
||||
FCanvas: TAggLCLCanvas;
|
||||
function GetFontAngle: Double; override;
|
||||
function SimpleTextExtent(const AText: String): TPoint; override;
|
||||
procedure SimpleTextOut(AX, AY: Integer; const AText: String); override;
|
||||
public
|
||||
@ -41,6 +40,7 @@ type
|
||||
procedure Ellipse(AX1, AY1, AX2, AY2: Integer);
|
||||
procedure FillRect(AX1, AY1, AX2, AY2: Integer);
|
||||
function GetBrushColor: TChartColor;
|
||||
function GetFontAngle: Double; override;
|
||||
function GetFontColor: TFPColor; override;
|
||||
function GetFontName: String; override;
|
||||
function GetFontSize: Integer; override;
|
||||
|
@ -30,7 +30,6 @@ type
|
||||
strict protected
|
||||
FBitmap: TBGRABitmap;
|
||||
|
||||
function GetFontAngle: Double; override;
|
||||
procedure SetAntialiasingMode(AValue: TChartAntialiasingMode);
|
||||
function SimpleTextExtent(const AText: String): TPoint; override;
|
||||
procedure SimpleTextOut(AX, AY: Integer; const AText: String); override;
|
||||
@ -44,6 +43,7 @@ type
|
||||
procedure Ellipse(AX1, AY1, AX2, AY2: Integer);
|
||||
procedure FillRect(AX1, AY1, AX2, AY2: Integer);
|
||||
function GetBrushColor: TChartColor;
|
||||
function GetFontAngle: Double; override;
|
||||
function GetFontColor: TFPColor; override;
|
||||
function GetFontName: String; override;
|
||||
function GetFontSize: Integer; override;
|
||||
@ -71,11 +71,13 @@ type
|
||||
procedure SetTransparency(ATransparency: TChartTransparency);
|
||||
end;
|
||||
|
||||
|
||||
implementation
|
||||
|
||||
uses
|
||||
BGRAText, Graphics, Math, TAGeometry;
|
||||
|
||||
|
||||
{ TBGRABitmapDrawer }
|
||||
|
||||
procedure TBGRABitmapDrawer.AddToFontOrientation(ADelta: Integer);
|
||||
@ -136,7 +138,8 @@ end;
|
||||
|
||||
function TBGRABitmapDrawer.GetFontAngle: Double;
|
||||
begin
|
||||
Result := 0.0;
|
||||
// Result := 0.0;
|
||||
Result := OrientToRad(Canvas.Font.Orientation);
|
||||
end;
|
||||
|
||||
function TBGRABitmapDrawer.GetFontColor: TFPColor;
|
||||
@ -274,10 +277,12 @@ begin
|
||||
end;
|
||||
|
||||
procedure TBGRABitmapDrawer.SetFont(AFont: TFPCustomFont);
|
||||
var
|
||||
fs: Integer;
|
||||
begin
|
||||
Canvas.Font.Name := AFont.Name;
|
||||
Canvas.Font.Height :=
|
||||
FontEmHeightSign * AFont.Size * ScreenInfo.PixelsPerInchY div 72;
|
||||
fs := IfThen(AFont.Size = 0, DEFAULT_FONT_SIZE, AFont.Size);
|
||||
Canvas.Font.Height := FontEmHeightSign * fs * ScreenInfo.PixelsPerInchY div 72;
|
||||
Canvas.Font.Orientation := FGetFontOrientationFunc(AFont);
|
||||
Canvas.Font.BGRAColor := BGRAColorOrMono(AFont.FPColor);
|
||||
if AFont is TFont then
|
||||
|
@ -101,7 +101,7 @@ begin
|
||||
if AFont is TFont then
|
||||
Result := (AFont as TFont).Orientation
|
||||
else
|
||||
Result := 0;
|
||||
Result := AFont.Orientation; //0;
|
||||
end;
|
||||
|
||||
function ChartColorSysToFPColor(AChartColor: TChartColor): TFPColor;
|
||||
|
@ -161,7 +161,11 @@ end;
|
||||
|
||||
function TFPCanvasDrawer.GetFontAngle: Double;
|
||||
begin
|
||||
Result := 0.0;
|
||||
{$IFDEF USE_FTFONT}
|
||||
Result := FFont.Angle; // Freetype font angle is in rad.
|
||||
{$ELSE}
|
||||
Result := 0;
|
||||
{$ENDIF}
|
||||
end;
|
||||
|
||||
function TFPCanvasDrawer.GetFontColor: TFPColor;
|
||||
@ -310,20 +314,45 @@ begin
|
||||
end;
|
||||
|
||||
function TFPCanvasDrawer.SimpleTextExtent(const AText: String): TPoint;
|
||||
{$IFDEF USE_FTFONT}
|
||||
var
|
||||
angle: Double;
|
||||
{$ENDIF}
|
||||
begin
|
||||
EnsureFont;
|
||||
FCanvas.GetTextSize(AText, Result.X, Result.Y);
|
||||
(*
|
||||
{$IFDEF USE_FTFONT}
|
||||
angle := FFont.Angle;
|
||||
try
|
||||
//FFont.Angle := 0;
|
||||
FCanvas.GetTextSize(AText, Result.X, Result.Y);
|
||||
finally
|
||||
FFont.Angle := angle;
|
||||
end;
|
||||
{$ELSE}
|
||||
FCanvas.GetTextSize(AText, Result.X, Result.Y);
|
||||
{$ENDIF}
|
||||
*)
|
||||
end;
|
||||
|
||||
procedure TFPCanvasDrawer.SimpleTextOut(AX, AY: Integer; const AText: String);
|
||||
{$IFDEF USE_FTFONT}
|
||||
var
|
||||
p: TPoint;
|
||||
angle: Double;
|
||||
{$ENDIF}
|
||||
begin
|
||||
EnsureFont;
|
||||
{$IFDEF USE_FTFONT}
|
||||
// FreeType uses lower-left instead of upper-left corner as starting position.
|
||||
{
|
||||
angle := FFont.Angle;
|
||||
FFont.Angle := 0;
|
||||
p := RotatePoint(Point(0, FCanvas.GetTextHeight(AText)), -angle);
|
||||
FFont.Angle := angle;
|
||||
}
|
||||
|
||||
p := RotatePoint(Point(0, FCanvas.GetTextHeight(AText)), -FFont.Angle);
|
||||
FCanvas.TextOut(p.X + AX, p.Y + AY , AText);
|
||||
{$ELSE}
|
||||
|
@ -36,7 +36,6 @@ type
|
||||
procedure ApplyPen;
|
||||
function InvertY(AY: Integer): Integer; inline;
|
||||
strict protected
|
||||
function GetFontAngle: Double; override;
|
||||
procedure SetBrush(ABrush: TFPCustomBrush);
|
||||
procedure SetFont(AFont: TFPCustomFont);
|
||||
procedure SetPen(APen: TFPCustomPen);
|
||||
@ -53,6 +52,7 @@ type
|
||||
procedure Ellipse(AX1, AY1, AX2, AY2: Integer);
|
||||
procedure FillRect(AX1, AY1, AX2, AY2: Integer);
|
||||
function GetBrushColor: TChartColor;
|
||||
function GetFontAngle: Double; override;
|
||||
function GetFontColor: TFPColor; override;
|
||||
function GetFontName: String; override;
|
||||
function GetFontSize: Integer; override;
|
||||
|
@ -18,6 +18,8 @@
|
||||
- If LazFreeType does not find the fonts needed call InitFonts at the beginning
|
||||
of the program and specify the path to the font folder as a parameter.
|
||||
Several folders can be used if separated by LineEnding codes.
|
||||
|
||||
- The drawer does not support rotated text at the moment.
|
||||
}
|
||||
unit TADrawerOpenGL;
|
||||
|
||||
@ -44,7 +46,7 @@ type
|
||||
FFontName: String;
|
||||
FFontSize: Integer;
|
||||
FFontStyle: TChartFontStyles;
|
||||
FFontAngle: Double;
|
||||
FFontAngle: Double; // in degrees
|
||||
FPos: TPoint;
|
||||
procedure ChartGLColor(AColor: TFPColor);
|
||||
procedure ChartGLPenStyle(APenStyle: TFPPenStyle);
|
||||
@ -54,7 +56,6 @@ type
|
||||
procedure SetFont(AFont: TFPCustomFont);
|
||||
procedure SetPen(APen: TFPCustomPen);
|
||||
strict protected
|
||||
function GetFontAngle: Double; override;
|
||||
function SimpleTextExtent(const AText: String): TPoint; override;
|
||||
procedure SimpleTextOut(AX, AY: Integer; const AText: String); override;
|
||||
public
|
||||
@ -66,6 +67,7 @@ type
|
||||
procedure Ellipse(AX1, AY1, AX2, AY2: Integer);
|
||||
procedure FillRect(AX1, AY1, AX2, AY2: Integer);
|
||||
function GetBrushColor: TChartColor;
|
||||
function GetFontAngle: Double; override;
|
||||
function GetFontColor: TFPColor; override;
|
||||
function GetFontName: String; override;
|
||||
function GetFontSize: Integer; override;
|
||||
@ -566,7 +568,11 @@ end;
|
||||
|
||||
function TOpenGLDrawer.GetFontAngle: Double;
|
||||
begin
|
||||
{$IFDEF CHARTGL_USE_LAZFREETYPE}
|
||||
Result := DegToRad(FFontAngle);
|
||||
{$ELSE}
|
||||
Result := 0.0;
|
||||
{$ENDIF}
|
||||
end;
|
||||
|
||||
function TOpenGLDrawer.GetFontColor: TFPColor;
|
||||
|
@ -78,7 +78,7 @@ type
|
||||
procedure Ellipse(AX1, AY1, AX2, AY2: Integer);
|
||||
procedure FillRect(AX1, AY1, AX2, AY2: Integer);
|
||||
function GetBrushColor: TChartColor;
|
||||
function GetFontAngle: Double;
|
||||
function GetFontAngle: Double; // in radians
|
||||
function GetFontColor: TFPColor;
|
||||
function GetFontName: String;
|
||||
function GetFontSize: Integer;
|
||||
|
@ -657,7 +657,6 @@ var
|
||||
firstPointSet: Boolean = false;
|
||||
originPt: TPoint;
|
||||
fill: Boolean;
|
||||
isClosed: Boolean;
|
||||
|
||||
procedure DoDraw;
|
||||
begin
|
||||
@ -821,7 +820,6 @@ end;
|
||||
|
||||
procedure TPolarSeries.PrepareGraphPoints;
|
||||
var
|
||||
s, c: Extended;
|
||||
i: Integer;
|
||||
begin
|
||||
SetLength(FGraphPoints, Count);
|
||||
|
Loading…
Reference in New Issue
Block a user