mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-04-15 11:49:55 +02:00
TAChart: Add InitFonts procedure to TADrawerFPCanvas initialize default font directories. Remove GetDefaultFontName.
(cherry picked from commit 8410f7274b
)
This commit is contained in:
parent
2c9e4125ee
commit
2f4d99f301
@ -7,13 +7,9 @@ uses
|
||||
Interfaces, Classes, tachartlazaruspkg { you can add units after this },
|
||||
FPCanvas, FPImage, FPImgCanv,
|
||||
TAGraph, TASeries, TADrawerFPCanvas in '../../TADrawerFPCanvas.pas', TADrawerCanvas, TADrawUtils;
|
||||
|
||||
const
|
||||
{$IFDEF MSWINDOWS}
|
||||
FONT_NAME = 'Arial';
|
||||
{$ENDIF}
|
||||
{$IFDEF UNIX}
|
||||
FONT_NAME = '/usr/share/fonts/truetype/liberation/LiberationSans-Regular.ttf';
|
||||
{$ENDIF}
|
||||
FONT_NAME = 'LiberationSans-Regular.ttf';
|
||||
|
||||
var
|
||||
chart: TChart;
|
||||
@ -22,6 +18,7 @@ var
|
||||
c: TFPImageCanvas;
|
||||
d: IChartDrawer;
|
||||
begin
|
||||
InitFonts;
|
||||
chart := TChart.Create(nil);
|
||||
chart.Width := 600;
|
||||
chart.Height := 400;
|
||||
|
@ -36,7 +36,6 @@ 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);
|
||||
@ -83,6 +82,9 @@ type
|
||||
procedure SetPenWidth(AWidth: Integer);
|
||||
end;
|
||||
|
||||
procedure InitFonts;
|
||||
|
||||
|
||||
implementation
|
||||
|
||||
uses
|
||||
@ -179,11 +181,6 @@ begin
|
||||
Result := FPColorToChartColor(FCanvas.Brush.FPColor);
|
||||
end;
|
||||
|
||||
function TFPCanvasDrawer.GetDefaultFontName: String;
|
||||
begin
|
||||
Result := 'arial';
|
||||
end;
|
||||
|
||||
function TFPCanvasDrawer.GetFontAngle: Double;
|
||||
begin
|
||||
{$IFDEF USE_FTFONT}
|
||||
@ -326,10 +323,7 @@ begin
|
||||
AssignFPCanvasHelper(FFont, AFont);
|
||||
AssignFPCanvasHelper(FMeasureFont, AFont);
|
||||
// DoCopyProps performs direct variable assignment, so call SetName by hand.
|
||||
if AFont.Name = 'default' then
|
||||
FFont.Name := GetDefaultFontName
|
||||
else
|
||||
FFont.Name := AFont.Name;
|
||||
FFont.Name := AFont.Name;
|
||||
if AFont.Size = 0 then
|
||||
FFont.Size := DEFAULT_FONT_SIZE
|
||||
else
|
||||
@ -367,9 +361,8 @@ begin
|
||||
end;
|
||||
|
||||
function TFPCanvasDrawer.SimpleTextExtent(const AText: String): TPoint;
|
||||
var
|
||||
fnt: TFreeTypeFont;
|
||||
begin
|
||||
Result := Point(0, 0);
|
||||
EnsureFont;
|
||||
{$IFDEF USE_FTFONT}
|
||||
FCanvas.Font := FMeasureFont;
|
||||
@ -407,5 +400,39 @@ begin
|
||||
{$ENDIF}
|
||||
end;
|
||||
|
||||
procedure InitFonts;
|
||||
begin
|
||||
{$IFDEF USE_FTFONT}
|
||||
InitEngine;
|
||||
|
||||
// Windows: Search path is set automatically
|
||||
|
||||
{$IFDEF LINUX}
|
||||
FontMgr.SearchPath :=
|
||||
'/usr/share/cups/fonts/;' +
|
||||
'/usr/share/fonts/truetype/;' +
|
||||
'/usr/share/fonts/truetype/liberation/;' +
|
||||
'/usr/local/lib/X11/fonts/;' +
|
||||
GetUserDir + '.fonts/';
|
||||
{$ENDIF}
|
||||
|
||||
{$IFDEF LCLCarbon}
|
||||
FontMgr.SearchPath :=
|
||||
'/Library/Fonts/;' +
|
||||
'/System/Library/Fonts/;' +
|
||||
'/Network/Library/Fonts/;' +
|
||||
'~/Library/Fonts/';
|
||||
{$ENDIF}
|
||||
|
||||
{$IFDEF LCLCocoa}
|
||||
FontMgr.SearchPath :=
|
||||
'/Library/Fonts/;' +
|
||||
'/System/Library/Fonts/;' +
|
||||
'/Network/Library/Fonts/;' +
|
||||
'~/Library/Fonts/';
|
||||
{$ENDIF}
|
||||
{$ENDIF}
|
||||
end;
|
||||
|
||||
end.
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user