If you want to test support for the entire character set, you can use EnumFontFamiliesEx from the Windows API - this does not allow you to request a single font, but rather returns a list of installed fonts that support a given character set (or that have any other set of requested functions).
You will need a callback function of the appropriate type :
function EnumFontCallback(lpelfe : PLogFont; lpntme : PNewTextMetricEX; FontType : DWORD; lp : LPARAM) : integer; stdcall; begin TMemo(lp).Lines.Add(lpelfe^.lfFaceName); result := 1; // return zero to end enumeration end;
And then called like:
procedure TForm1.Button1Click(Sender: TObject); var lf : TLogFont; begin ZeroMemory(@lf,SizeOf(TLogFont)); lf.lfCharSet := CHINESEBIG5_CHARSET; if not EnumFontFamiliesEx(Canvas.Handle, // HDC lf, // TLogFont @EnumFontCallback, // Callback Pointer NativeInt(Memo1), // user supplied pointer 0) then // must be zero begin // function call failed. end; end;
Using the various fields in the TLogFont (MSDN) structure, you can request a wide range of font functions. In this case, I limited only the character set (for Chinese Big-5 in the example above).
The callback will fire once for each resulting font returned from the request. You will need to manage the collection of this information as it returns. To add restrictions to multiple character sets, you will need to call EnumFontFamiliesEx once for each character set. The following constants are defined in the Windows RTL block:
ANSI_CHARSET BALTIC_CHARSET CHINESEBIG5_CHARSET DEFAULT_CHARSET // depends on system locale EASTEUROPE_CHARSET GB2312_CHARSET GREEK_CHARSET HANGUL_CHARSET MAC_CHARSET OEM_CHARSET // depends on OS RUSSIAN_CHARSET SHIFTJIS_CHARSET SYMBOL_CHARSET TURKISH_CHARSET VIETNAMESE_CHARSET JOHAB_CHARSET ARABIC_CHARSET HEBREW_CHARSET THAI_CHARSET
A cross reference will then be up to you - a TDictionary seems like a reasonable tool to manage this task.
J ... source share