Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I know if a TFont Name is truly supported?

When I set the TFont Name property of a TRichEdit control to "Courier" the font changes to Courier.

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

What if I want to use a font of which I'm not really sure it is supported on the system (e.g. 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 doesn't change, the system takes care of it and sticks with the previous font, but how can I programmatically check this ?

I'd like to know if the font truly changed (because the font is available / installed) ?

Or do I need to query Screen->Fonts to find out if the Name is in the list ?

FYI: Using Borland C++ Builder (2009), but relevant to Delphi as well I'm sure.

like image 814
Peter Avatar asked Jan 03 '23 10:01

Peter


1 Answers

TScreen::Fonts represents a TStrings list that contains the names of the fonts installed in the system (the actual names and not the file names).

Use its IndexOf() method to test if your font exists:

if (Screen->Fonts->IndexOf("Courier") != -1)
{
    ShowMessage("Font installed");
}
like image 171
Nasreddine Galfout Avatar answered Jan 10 '23 11:01

Nasreddine Galfout