8
Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls,
9
ComCtrls, ExtCtrls, Spin, fpimage,
11
IntfGraphics, GraphType, //Intf basic routines
13
EasyLazFreeType, LazFreeTypeIntfDrawer //EasyFreeType with Intf
25
SpinEdit_Zoom: TSpinEdit;
26
TrackBar_Size: TTrackBar;
27
procedure FormCreate(Sender: TObject);
28
procedure FormDestroy(Sender: TObject);
29
procedure FormMouseMove(Sender: TObject; Shift: TShiftState; X, Y: Integer);
30
procedure FormPaint(Sender: TObject);
31
procedure SpinEdit_ZoomChange(Sender: TObject);
32
procedure TrackBar_SizeChange(Sender: TObject);
34
procedure UpdateSizeLabel;
35
{ private declarations }
37
{ public declarations }
38
lazimg: TLazIntfImage;
39
drawer: TIntfFreeTypeDrawer;
40
ftFont1,ftFont2,ftFont3: TFreeTypeFont;
41
mx,my: integer; //mouse position
51
procedure TForm1.FormCreate(Sender: TObject);
53
mx := clientwidth div 2;
54
my := clientheight div 2;
56
lazimg := TLazIntfImage.Create(0,0, [riqfRGB]);
57
drawer := TIntfFreeTypeDrawer.Create(lazimg);
63
ftFont1 := TFreeTypeFont.Create;
64
ftFont1.Name := 'arial.ttf';
66
ftFont2 := TFreeTypeFont.Create;
67
ftFont2.Name := 'timesi.ttf';
69
ftFont3 := TFreeTypeFont.Create;
70
ftFont3.Name := 'verdana.ttf';
79
MessageDlg('Font error',ex.Message,mtError,[mbOk],0);
86
procedure TForm1.FormDestroy(Sender: TObject);
95
procedure TForm1.FormMouseMove(Sender: TObject; Shift: TShiftState; X,
103
procedure TForm1.UpdateSizeLabel;
105
LFontSize.Caption := inttostr(TrackBar_Size.Position)+'pt';
106
if ftFont1 <> nil then ftFont1.SizeInPoints := TrackBar_Size.Position;
107
if ftFont2 <> nil then ftFont2.SizeInPoints := TrackBar_Size.Position;
108
if ftFont3 <> nil then ftFont3.SizeInPoints := TrackBar_Size.Position;
111
procedure TForm1.FormPaint(Sender: TObject);
112
const testtext = 'Enjoy'+LineEnding+'and play!';
115
p: array of TCharPosition;
118
StartTime,EndTime,EndTime2: TDateTime;
121
if lazimg = nil then exit;
122
canvas.Font.Name := 'Comic Sans MS';
124
zoom := SpinEdit_Zoom.Value;
127
tx := ClientWidth div zoom;
128
ty := Panel_Option.Top div zoom;
129
if (lazimg.Width <> tx) or (lazimg.Height <> ty) then
130
lazimg.SetSize(tx,ty);
132
drawer.FillPixels(TColorToFPColor(clWhite));
137
ftFont1.Hinted := true;
138
ftFont1.ClearType := true;
139
ftFont1.Quality := grqHighQuality;
140
ftFont1.SmallLinePadding := false;
141
drawer.DrawText(ftFont1.Information[ftiFullName], ftFont1, x, y, colBlack, [ftaRight, ftaBottom]);
143
ftFont2.Hinted := false;
144
ftFont2.ClearType := false;
145
ftFont2.Quality := grqHighQuality;
146
drawer.DrawText(ftFont2.Information[ftiFullName], ftFont2, x, y, colRed, 192, [ftaCenter, ftaBaseline]);
148
ftFont3.Hinted := false;
149
ftFont3.ClearType := false;
150
ftFont3.Quality := grqMonochrome;
151
drawer.DrawText(ftFont3.Information[ftiFullName]+' '+ftFont3.VersionNumber, ftFont3, x, y, colBlack, 128, [ftaLeft, ftaTop]);
153
p := ftFont1.CharsPosition(ftFont1.Information[ftiFullName],[ftaRight, ftaBottom]);
154
for i := 0 to high(p) do
156
drawer.DrawVertLine(round(x+p[i].x),round(y+p[i].yTop),round(y+p[i].yBottom), TColorToFPColor(clBlue));
157
drawer.DrawHorizLine(round(x+p[i].x),round(y+p[i].yBase),round(x+p[i].x+p[i].width), TColorToFPColor(clBlue));
162
bmp := TBitmap.Create;
163
bmp.LoadFromIntfImage(lazimg);
164
Canvas.StretchDraw(rect(0,0,lazimg.width*zoom,lazimg.height*zoom),bmp);
169
Canvas.TextOut(0,0, inttostr(round((EndTime-StartTime)*24*60*60*1000))+' ms + '+inttostr(round((EndTime2-EndTime)*24*60*60*1000))+' ms');
173
procedure TForm1.SpinEdit_ZoomChange(Sender: TObject);
178
procedure TForm1.TrackBar_SizeChange(Sender: TObject);