Home > Back-end >  Get the system font.
Get the system font.

Time:10-17

To my brother to write a font selection software just a few lines of code
Why show Chinese like be leaving the country is mostly fine
 
Procedure TForm1. FormCreate (Sender: TObject);
The begin
Edit1. Align:=alBottom;
Fonts: TStringList=(Screen Fonts);
If Fonts. Count=0 then the begin
ShowMessage (' failed to get system font);
The Halt (1);
end;
end;
Procedure TForm1. DrawGrid1DrawCell (Sender: TObject; ACol, ARow: Integer;
The Rect: TRect; State: TGridDrawState);
Var
Index: Integer;

TextSize: TSize;
The begin
Index:=ARow * DrawGrid1 ColCount + ACol;
DrawGrid1. Canvas. Brush. Color:=ColorBox2. Selected;
DrawGrid1. Canvas. FillRect (the Rect);
If the index & lt;=Fonts. Count then begin
DrawGrid1. Canvas. The Font. The Name:=(Fonts [index]);
DrawGrid1. Canvas. The Font Size:=FontSize;
DrawGrid1. Canvas. The Font Color:=ColorBox1. Selected;
TextSize:=DrawGrid1. Canvas. TextExtent (Edit1. Text);
DrawGrid1. Canvas. TextOut (the Rect. Left + ((DrawGrid1. DefaultColWidth div 2) - TextSize. Cx div 2) of the Rect. Top + ((DrawGrid1. DefaultRowHeight div 2) - (2) TextSize. Cy div, Edit1. The Text).
end;
end;

  • Related