TAChart: Fix nogui demo showing no texts. (Fix is effective only on fpc fixes or main)

This commit is contained in:
wp_xyz 2021-09-15 23:05:58 +02:00
parent a7ee5a544d
commit 002b5cd1bc
2 changed files with 26 additions and 4 deletions

View File

@ -23,6 +23,12 @@ var
d: IChartDrawer;
begin
chart := TChart.Create(nil);
chart.Width := 600;
chart.Height := 400;
chart.Title.Text.Text := 'TAChart nogui demo';
chart.Title.Font.Size := 16;
chart.Title.Font.Name := FONT_NAME;
chart.Title.Visible := true;
chart.LeftAxis.Marks.LabelFont.Name := FONT_NAME;
chart.LeftAxis.Marks.LabelFont.Size := 10;
chart.LeftAxis.Marks.LabelFont.Orientation := 450;

View File

@ -36,6 +36,7 @@ type
// in horizontal horientation. FMeasureFont is always horizontal.
{$ENDIF}
procedure EnsureFont;
function GetDefaultFontName: String;
procedure SetBrush(ABrush: TFPCustomBrush);
procedure SetFont(AFont: TFPCustomFont);
procedure SetPen(APen: TFPCustomPen);
@ -152,14 +153,16 @@ begin
{$IFDEF USE_FTFONT}
if FFont = nil then begin
FFont := TFreeTypeFont.Create;
FFont.Resolution := 72;
FFont.Size := DEFAULT_FONT_SIZE;
FFont.Resolution := 96;
FFont.AntiAliased := true; //false;
FCanvas.Font := FFont;
end;
if FMeasureFont = nil then begin
FMeasureFont := TFreeTypeFont.Create;
FMeasureFont.Resolution := 72;
FMeasureFont.Size := DEFAULT_FONT_SIZE;
FMeasureFont.Resolution := 96;
FMeasureFont.AntiAliased := false;
end;
{$ENDIF}
@ -176,6 +179,11 @@ begin
Result := FPColorToChartColor(FCanvas.Brush.FPColor);
end;
function TFPCanvasDrawer.GetDefaultFontName: String;
begin
Result := 'arial';
end;
function TFPCanvasDrawer.GetFontAngle: Double;
begin
{$IFDEF USE_FTFONT}
@ -318,9 +326,17 @@ begin
AssignFPCanvasHelper(FFont, AFont);
AssignFPCanvasHelper(FMeasureFont, AFont);
// DoCopyProps performs direct variable assignment, so call SetName by hand.
FFont.Name := AFont.Name;
if AFont.Name = 'default' then
FFont.Name := GetDefaultFontName
else
FFont.Name := AFont.Name;
if AFont.Size = 0 then
FFont.Size := DEFAULT_FONT_SIZE
else
FFont.Size := AFont.Size;
FFont.Angle := OrientToRad(FGetFontOrientationFunc(AFont));
FMeasureFont.Name := AFont.Name;
FMeasureFont.Name := FFont.Name;
FMeasureFont.Size := FFont.Size;
FMeasureFont.Angle := 0;
{$ELSE}
Unused(AFont);