Hi
I have a NoGui app and i am trying to change Font of bgrabitmap from default which is arial to some thing else like "Times New Roman" or "Segoe_UI", as you can see in my code, i am trying to add the font file (.ttf file) to font collection, im not sure what im missing that the default font dont change!
you can see my font files, which are in project directory in screenshot,
i am using Lazarus 1.6 in windows 10.
any help much appreciated prior
program Test1NoGui;
uses
Classes,
BGRABitmap,
BGRABitmapTypes,
LazFreeTypeFontCollection,
SysUtils;
type
Test1NoGuiClass = class
protected
public
procedure DrawPic;
end;
procedure Test1NoGuiClass.DrawPic;
var
bmp: TBGRABitmap;
FFontCollection: TFreeTypeFontCollection;
begin
FFontCollection := TFreeTypeFontCollection.Create;
FFontCollection.AddFile('times.ttf');
//FFontCollection.AddFile('arial.ttf');
//FFontCollection.AddFile('Segoe_UI.ttf');
SetDefaultFreeTypeFontCollection(FFontCollection);
TBGRABitmap.AddFreeTypeFontFolder(GetCurrentDir);
bmp.FontName := 'Times New Roman';
//bmp.FontName := 'arial';
//bmp.FontName := 'Segoe_UI';
bmp := TBGRABitmap.Create(400, 200);
bmp.FillEllipseAntialias(200, 100, 190, 90, BGRA(26, 22, 169));
bmp.FontHeight := bmp.Height div 10;
with bmp.FontPixelMetric do
bmp.TextOut(bmp.Width / 2, bmp.Height / 2 - (CapLine + Baseline) / 2,
'Too little too late!', BGRA(206, 205, 232), taCenter);
bmp.SaveToFile('Pics/Times New Roman.png');
bmp.Free;
end;
var
App: Test1NoGuiClass;
begin
App.DrawPic;
end.