How to filter out non-readable screen-fonts?

224 Views Asked by At

In a Delphi 10.1.2 VCL Forms Application, I fill a TComboBox with the Screen.Fonts list and display the font items using their own font-faces:

procedure TForm2.FormCreate(Sender: TObject);
begin
  AddFontsToComboList;
end;

procedure TForm2.AddFontsToComboList;
var
  i: Integer;
begin
  ComboBox1.Items.BeginUpdate;
  try
    for i := 0 to Screen.Fonts.Count - 1 do
    begin
      ComboBox1.Items.Add(Screen.Fonts[i]);
    end;
  finally
    ComboBox1.Items.EndUpdate;
  end;
end;

procedure TForm2.ComboBox1DrawItem(Control: TWinControl; Index: Integer; Rect: TRect; State: TOwnerDrawState);
// ComboBox1.Style must be csOwnerDrawVariable
begin
  with ComboBox1 do
  begin
    Canvas.fillrect(rect);
    Canvas.Font.Style := [fsbold];
    Canvas.Font.Name  := ComboBox1.Items[Index];
    Canvas.Textout(rect.Left, rect.Top, ComboBox1.Items[Index]);
  end;
end;

This is the result:

enter image description here

You can see that there are some missing items. In the above screenshot, the missing font is Cambria Math.

So how can I filter out those empty items? And how can I filter out those items which are unreadable? And how can I filter out the fonts which contain only symbols? You know what I mean.

0

There are 0 best solutions below