BOOL DoFontEnum( HDC hDC, LPWSTR pwszFace, SHORT TTPointSize) { ULONG ulFE = 0; BOOL bDeleteDC = FALSE; BOOL bFindFaces = (pwszFace == NULL); FONTENUMDC fed; DBGFONTS(("DoFontEnum \"%ls\"\n", pwszFace)); if (hDC == NULL) { hDC = CreateDCW(L"DISPLAY",NULL,NULL,NULL); bDeleteDC = TRUE; } fed.hDC = hDC; fed.bFindFaces = bFindFaces; fed.ulFE = 0; fed.TTPointSize = TTPointSize; EnumFontFamiliesW(hDC, (LPCWSTR)pwszFace, (FONTENUMPROC)FontEnum, (LPARAM)&fed); if (bDeleteDC) { DeleteDC(hDC); } return (fed.ulFE & FE_FONTOK) != 0; }
static BOOL find_installed_font(const WCHAR *name, NEWTEXTMETRICW *ntm) { HDC hdc = GetDC(0); BOOL ret = FALSE; if(!EnumFontFamiliesW(hdc, name, is_font_installed_proc, (LPARAM)ntm)) ret = TRUE; ReleaseDC(0, hdc); return ret; }
static GpStatus find_installed_font(const WCHAR *name, struct font_metrics *fm) { LOGFONTW lf; HDC hdc = CreateCompatibleDC(0); GpStatus ret = FontFamilyNotFound; if(!EnumFontFamiliesW(hdc, name, is_font_installed_proc, (LPARAM)&lf)) { HFONT hfont, old_font; hfont = CreateFontIndirectW(&lf); old_font = SelectObject(hdc, hfont); ret = get_font_metrics(hdc, fm) ? Ok : NotTrueTypeFont; SelectObject(hdc, old_font); DeleteObject(hfont); } DeleteDC(hdc); return ret; }
GpStatus WINGDIPAPI GdipIsStyleAvailable(GDIPCONST GpFontFamily* family, INT style, BOOL* IsStyleAvailable) { HDC hdc; TRACE("%p %d %p\n", family, style, IsStyleAvailable); if (!(family && IsStyleAvailable)) return InvalidParameter; *IsStyleAvailable = FALSE; hdc = GetDC(0); if(!EnumFontFamiliesW(hdc, family->FamilyName, font_has_style_proc, (LPARAM)style)) *IsStyleAvailable = TRUE; ReleaseDC(0, hdc); return Ok; }
static BOOL Combo_OnInitDialog(HWND hwnd, HWND hwndFocus, LPARAM lParam) { HWND hComboFont; HDC hdc; WNDPROC hProc; *g_SelectedFont.szFace = '\0'; g_SelectedFont.nCharSet = 0; memcpy(&m_cbr, (P_CBCREATION)lParam, sizeof(m_cbr)); g_hComboDialog = hwnd; hdc = GetDC(hwnd); hComboFont = GetDlgItem(hwnd, IDC_COMBO_FONT); hProc = (WNDPROC)SetWindowLongPtrW(hComboFont, GWLP_WNDPROC, (LONG_PTR)CFont_WndProc); SetWindowLongPtrW(hComboFont, GWLP_USERDATA, (LONG_PTR)hProc); //store fonts EnumFontFamiliesW(hdc, NULL, (FONTENUMPROCW)EnumFontFamProcW, (LPARAM)hComboFont); ReleaseDC(hwnd, hdc); if(GetDlgCtrlID(m_cbr.hButton) == CMD_FONT + 5000) ShowFontCombo(hwnd); return TRUE; }