Voglio scrivere la seguente funzioneCome scoprire se il sistema ha il carattere che mi serviva in MFC?
bool IsFontExistInSystem(const CString& fontStyle) const
{
}
C'è qualche API di Windows per fare questo? Molte grazie!
Voglio scrivere la seguente funzioneCome scoprire se il sistema ha il carattere che mi serviva in MFC?
bool IsFontExistInSystem(const CString& fontStyle) const
{
}
C'è qualche API di Windows per fare questo? Molte grazie!
Ecco un vecchio codice che ho scovato che controllerà se un font è installato. Potrebbe farcela con l'ordine, ma ti viene l'idea:
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;
}
È possibile utilizzare EnumFontFamiliesEx
per determinare se esistono caratteri reali.
UPD: Ho appena appreso che MS raccomanda di utilizzare EnumFontFamiliesEx anziché EnumFontFamilies.
Mille grazie! Funziona! – user25749