This is very rude, but it kind of works (on Windows at least).
It fille a combobox with the names of all monospaced fonts.
procedure TForm1.Button1Click(Sender: TObject);
var
SL: TStringList;
i: Integer;
W1, W2: Integer;
lbl: TLabel;
Tm, Tm0, Tm1: TDateTime;
HH,MM,SS,MS: word;
begin
lbl := tlabel.create(self);
SL := TStringList.Create;
try
lbl.Parent := self;
lbl.Visible := false;
Tm := Now;
repeat until Now <> Tm;
Tm0 := Now;
for i := 0 to Screen.Fonts.Count - 1 do
begin
lbl.Font.Name := Screen.Fonts.Strings[i];
if lbl.Font.IsMonoSpace then SL.Add(Font.Name) else
begin
W1 := lbl.Canvas.TextWidth('WMWMWM');
W2 := lbl.Canvas.TextWidth('iiiiii');
//writeln(lbl.Font.Name,': W1 = ',w1,' W2 = ',w2);
if (W1 = W2) then SL.Add(lbl.Font.Name);
end;
end;
Tm1 := Now;
DecodeTime(Tm0-Tm1,HH,MM,SS,Ms);
Ms := (1000*SS) + Ms;
writeln(Screen.Fonts.Count,' fonts: ',Ms,' Ms');
ComboBox1.Items.Assign(Sl);
if ComboBox1.Items.Count > 0 then ComboBox1.ItemIndex := 0;
finally
SL.free;
lbl.free;
end;
end;
Takes 328 Msec on my system.
Bart