Ich mag die folgende FunktionWie finde ich heraus, ob das System die Schriftart hat, die ich in MFC benötigte?
bool IsFontExistInSystem(const CString& fontStyle) const
{
}
Gibt es eine API in Windows schreiben, dies zu tun? Vielen Dank!
Ich mag die folgende FunktionWie finde ich heraus, ob das System die Schriftart hat, die ich in MFC benötigte?
bool IsFontExistInSystem(const CString& fontStyle) const
{
}
Gibt es eine API in Windows schreiben, dies zu tun? Vielen Dank!
Hier ist ein alter Code, den ich ausgegraben habe, der überprüft, ob eine Schriftart installiert ist. Es könnte tun aufgeräumt werden, aber Sie bekommen die Idee:
static int CALLBACK CFontHelper::EnumFontFamExProc(ENUMLOGFONTEX* /*lpelfe*/, NEWTEXTMETRICEX* /*lpntme*/, int /*FontType*/, LPARAM lParam)
{
LPARAM* l = (LPARAM*)lParam;
*l = TRUE;
return TRUE;
}
bool Font::IsInstalled(LPCTSTR lpszFont)
{
// Get the screen DC
CDC dc;
if (!dc.CreateCompatibleDC(NULL))
{
return false;
}
LOGFONT lf = { 0 };
// Any character set will do
lf.lfCharSet = DEFAULT_CHARSET;
// Set the facename to check for
_tcscpy(lf.lfFaceName, lpszFont);
LPARAM lParam = 0;
// Enumerate fonts
::EnumFontFamiliesEx(dc.GetSafeHdc(), &lf, (FONTENUMPROC)EnumFontFamExProc, (LPARAM)&lParam, 0);
return lParam ? true : false;
}
Sie könnten EnumFontFamiliesEx
verwenden, um zu finden, ob tatsächliche Schriftart vorhanden ist.
UPD: Ich habe gerade erfahren, dass es von MS empfohlen wird, EnumFontFamiliesEx anstelle von EnumFontFamilies zu verwenden.
Vielen Dank! Es klappt! – user25749