How to find out if TFont Name is supported?

When I set the TFont Namecontrol property TRichEditto Courier, the font changes to Courier.

Edit->Font->Name  = "Courier";

What if I want to use a font that I’m not sure that it is supported on the system (for example, on an older OS)? As far as I can tell at the moment, if I assign an “unknown” name to the TFont property, the actual font will not change, the system will take care of this and adhere to the previous font, but how can I programmatically verify this?

I would like to know if the font has really changed (since the font is available / installed)?

Or do I need to request Screen-> Fonts to find out if there is a name in the list?

FYI: Using Borland C ++ Builder (2009), but also relevant for Delphi, I'm sure.

+4
source share
1 answer

TScreen :: Fonts presents a list TStringsthat contains the names of the fonts installed on the system (actual names, not file names).

Use the method IndexOf()to check if your font exists:

if (Screen->Fonts->IndexOf("Courier") != -1)
{
    ShowMessage("Font installed");
}
+9
source

Source: https://habr.com/ru/post/1686071/


All Articles