void test() { LOGFONT logFont; memset(&logFont, 0x00, sizeof(logFont)); _tcscpy(logFont.lfFaceName, _T("Mic32New")); logFont.lfCharSet = DEFAULT_CHARSET; HDC hdc = ::GetWindowDC(adsw_acadMainWnd()); EnumFontFamiliesEx(hdc, &logFont,(FONTENUMPROC)EnumFontFamExProcGetRasterFontSize, 0, 0); ::ReleaseDC(adsw_acadMainWnd(), hdc); }
void fontreplace(char *font, int type) { if (!strlen(font)) return; LOGFONT logfont; ZeroMemory(&logfont, sizeof logfont); logfont.lfCharSet = DEFAULT_CHARSET; logfont.lfPitchAndFamily = FF_DONTCARE; hdc = GetDC(0); switch (type) { case MONOF: lstrcpy(logfont.lfFaceName, gli_conf_monofont); EnumFontFamiliesEx(hdc, &logfont, (FONTENUMPROC)monofont, 0, 0); break; case PROPF: lstrcpy(logfont.lfFaceName, gli_conf_propfont); EnumFontFamiliesEx(hdc, &logfont, (FONTENUMPROC)propfont, 0, 0); break; } ReleaseDC(0, hdc); }
//================================================================================================ //--------------------------------------------------------------+++--> Create a Font For the Clock: HFONT CreateMyFont(char* fontname, int fontsize, LONG weight, LONG italic, int angle) { //--+++--> LOGFONT lf; POINT pt; HDC hdc; WORD langid; char s[11]; int cp, i; BYTE charset; int FontQty; memset(&lf, 0, sizeof(LOGFONT)); langid = (WORD)GetMyRegLong("Format", "Locale", (int)GetUserDefaultLangID()); FontQty = GetMyRegLong("Clock", "FontQuality", CLEARTYPE_QUALITY); cp = CP_ACP; if(GetLocaleInfo(langid, LOCALE_IDEFAULTANSICODEPAGE, s, 10) > 0) { char *p; p = s; cp = 0; while('0' <= *p && *p <= '9') cp = cp * 10 + *p++ - '0'; if(!IsValidCodePage(cp)) cp = CP_ACP; } charset = 0; for(i = 0; codepage_charset[i].cp; i++) { if(cp == codepage_charset[i].cp) { charset = codepage_charset[i].charset; break; } } hdc = GetDC(NULL); // find a font named "fontname" if(charset == 0) charset = GetTextCharset(hdc); lf.lfCharSet = charset; if(EnumFontFamiliesEx(hdc, &lf, (FONTENUMPROC)EnumFontFamExProc, (LPARAM)fontname, 0)) { lf.lfCharSet = OEM_CHARSET; if(EnumFontFamiliesEx(hdc, &lf, (FONTENUMPROC)EnumFontFamExProc, (LPARAM)fontname, 0)) { lf.lfCharSet = ANSI_CHARSET; EnumFontFamiliesEx(hdc, &lf, (FONTENUMPROC)EnumFontFamExProc, (LPARAM)fontname, 0); } } pt.x = 0; pt.y = MulDiv(fontsize, GetDeviceCaps(hdc, LOGPIXELSY), 72); DPtoLP(hdc, &pt, 1); lf.lfHeight = -pt.y; ReleaseDC(NULL, hdc); lf.lfWidth = lf.lfEscapement = lf.lfOrientation = 0; lf.lfWeight = weight; lf.lfItalic = (BYTE)italic; lf.lfUnderline = 0; lf.lfStrikeOut = 0; if(angle >0) lf.lfEscapement = angle; lf.lfOutPrecision = OUT_DEFAULT_PRECIS; lf.lfClipPrecision = CLIP_DEFAULT_PRECIS; lf.lfQuality = FontQty; // This Just HAD To be Adjustable. lf.lfPitchAndFamily = DEFAULT_PITCH | FF_DONTCARE; strcpy(lf.lfFaceName, fontname); return CreateFontIndirect(&lf); }
static int CALLBACK wfontEnum1 (ENUMLOGFONTEXW* lpelfe, NEWTEXTMETRICEXW*, int type, LPARAM lParam) { if (lpelfe != 0 && (type & RASTER_FONTTYPE) == 0) { LOGFONTW lf; zerostruct (lf); lf.lfWeight = FW_DONTCARE; lf.lfOutPrecision = OUT_OUTLINE_PRECIS; lf.lfQuality = DEFAULT_QUALITY; lf.lfCharSet = DEFAULT_CHARSET; lf.lfClipPrecision = CLIP_DEFAULT_PRECIS; lf.lfPitchAndFamily = FF_DONTCARE; const String fontName (lpelfe->elfLogFont.lfFaceName); fontName.copyToUnicode (lf.lfFaceName, LF_FACESIZE - 1); HDC dc = CreateCompatibleDC (0); EnumFontFamiliesEx (dc, &lf, (FONTENUMPROCW) &wfontEnum2, lParam, 0); DeleteDC (dc); } return 1; }
const StringArray Font::findAllTypefaceNames() { StringArray results; HDC dc = CreateCompatibleDC (0); { LOGFONTW lf; zerostruct (lf); lf.lfWeight = FW_DONTCARE; lf.lfOutPrecision = OUT_OUTLINE_PRECIS; lf.lfQuality = DEFAULT_QUALITY; lf.lfCharSet = DEFAULT_CHARSET; lf.lfClipPrecision = CLIP_DEFAULT_PRECIS; lf.lfPitchAndFamily = FF_DONTCARE; lf.lfFaceName[0] = 0; EnumFontFamiliesEx (dc, &lf, (FONTENUMPROCW) &wfontEnum1, (LPARAM) &results, 0); } DeleteDC (dc); results.sort (true); return results; }
/*------------------------------------------------ Initialization of "Font" combo box --------------------------------------------------*/ void InitComboFont(HWND hDlg) { HDC hdc; LOGFONT lf = {0}; HWND hcombo; wchar_t font[LF_FACESIZE]; int i; hdc = GetDC(NULL); // Enumerate fonts and set in the combo box hcombo = GetDlgItem(hDlg, IDC_FONT); lf.lfCharSet = DEFAULT_CHARSET; // fonts from any charset EnumFontFamiliesEx(hdc, &lf, EnumFontFamExProc, (LPARAM)hcombo, 0); ReleaseDC(NULL, hdc); api.GetStrEx(L"Clock", L"Font", font, _countof(font), L"Arial"); i = ComboBox_FindStringExact(hcombo, -1, font); if(i == LB_ERR) i = 0; ComboBox_SetCurSel(hcombo, i); }
void CFontsPage::FillCharsets() { m_CharsetCtl.EnableWindow(TRUE); m_CharsetCtl.ResetContent(); CString tmp; tmp.LoadString(IDS_CHARSET_AUTO); VERIFY(m_CharsetCtl.AddString(tmp)==0); VERIFY(m_CharsetCtl.SetItemData(0,DEFAULT_CHARSET)!=LB_ERR); if(m_fmtChar.dwMask&CFM_FACE && *m_fmtChar.szFaceName){ CClientDC dc(NULL); LOGFONT lf; memset(&lf,0,sizeof(lf)); lf.lfCharSet = DEFAULT_CHARSET; strcpy(lf.lfFaceName,m_fmtChar.szFaceName); EnumFontFamiliesEx(dc.m_hDC,&lf,(FONTENUMPROC)FillInCharsets,(LPARAM)&m_CharsetCtl,0); } int ii = m_CharsetCtl.GetCount(); for(int i=0;i<ii;i++){ if(m_CharsetCtl.GetItemData(i)==m_fmtChar.bCharSet){ m_CharsetCtl.SetCurSel(i); break; } } m_CharsetCtl.EnableWindow(m_CharsetCtl.GetCount()>1); }
StringArray Font::findAllTypefaceFamilies() { StringArray results; #if JUCE_USE_DIRECTWRITE const Direct2DFactories& factories = Direct2DFactories::getInstance(); if (factories.systemFonts != nullptr) { ComSmartPtr<IDWriteFontFamily> dwFontFamily; uint32 fontFamilyCount = 0; fontFamilyCount = factories.systemFonts->GetFontFamilyCount(); for (uint32 i = 0; i < fontFamilyCount; ++i) { HRESULT hr = factories.systemFonts->GetFontFamily (i, dwFontFamily.resetAndGetPointerAddress()); ComSmartPtr<IDWriteLocalizedStrings> dwFamilyNames; hr = dwFontFamily->GetFamilyNames (dwFamilyNames.resetAndGetPointerAddress()); jassert (dwFamilyNames != nullptr); uint32 index = 0; BOOL exists = false; hr = dwFamilyNames->FindLocaleName (L"en-us", &index, &exists); if (! exists) index = 0; uint32 length = 0; hr = dwFamilyNames->GetStringLength (index, &length); HeapBlock <wchar_t> familyName (length + 1); hr = dwFamilyNames->GetString (index, familyName, length + 1); results.add(String (familyName)); } } else #endif { HDC dc = CreateCompatibleDC (0); { LOGFONTW lf = { 0 }; lf.lfWeight = FW_DONTCARE; lf.lfOutPrecision = OUT_OUTLINE_PRECIS; lf.lfQuality = DEFAULT_QUALITY; lf.lfCharSet = DEFAULT_CHARSET; lf.lfClipPrecision = CLIP_DEFAULT_PRECIS; lf.lfPitchAndFamily = FF_DONTCARE; EnumFontFamiliesEx (dc, &lf, (FONTENUMPROCW) &FontEnumerators::fontEnum1, (LPARAM) &results, 0); } DeleteDC (dc); } results.sort (true); return results; }
void CVisualSynanView::OnFonts() { CFontDialog dlgFonts; if( dlgFonts.DoModal() != IDOK) return; LOGFONT lfOldFont; LogFontCpy(&lfOldFont, m_LogFontForWords); dlgFonts.GetCurrentFont(&m_LogFontForWords); CString str = dlgFonts.GetFaceName(); CClientDC dc(this); EnumFontFamiliesEx(dc.m_hDC, &m_LogFontForWords, &TestIfTrueTypeEx,(LPARAM)this,0); if( !m_bExistUsefulFont ) { ::AfxMessageBox(IDS_NOT_TRUE_TYPE); LogFontCpy(&m_LogFontForWords,lfOldFont); return; } if(!(m_LogFontForWords.lfCharSet & RUSSIAN_CHARSET) ) { ::AfxMessageBox(IDS_NOT_RUSSIAN_CHARSET); LogFontCpy(&m_LogFontForWords,lfOldFont); return; }; // m_LogFontForWords has changed!! UpdateFontsFromLogFont(); CClientDC clDC(this); Recalculate(clDC); Invalidate(); }
VOID InitOptionsFont(HWND hDlg) { // load up the list of fonts HDC hDC = GetDC(hDlg); CHARFORMAT cf; LOGFONT lf; SendDlgItemMessage(hDlg, IDC_SpnFontSize, UDM_SETRANGE, 0, MAKELONG(72, 6)); lf.lfCharSet = DEFAULT_CHARSET; lf.lfFaceName[0] = TEXT('\0');; lf.lfPitchAndFamily = 0; EnumFontFamiliesEx(hDC, &lf, ListAllFonts, (LPARAM) GetDlgItem(hDlg, IDC_LstFontFace), 0); ReleaseDC(hDlg, hDC); SetDlgItemText(hDlg, IDC_RtfPreview, TEXT("Text Preview ABC abc 123")); // setup the config options RegistryReadFont(&cf); SetDlgItemText(hDlg, IDC_LstFontFace, cf.szFaceName); SetDlgItemBool(hDlg, IDC_ChkFontBold, cf.dwEffects & CFE_BOLD); SetDlgItemBool(hDlg, IDC_ChkFontItalic, cf.dwEffects & CFE_ITALIC); SetDlgItemInt(hDlg, IDC_TxtFontSize, TwipToPoint(cf.yHeight), FALSE); SetDlgItemBool(hDlg, IDC_ChkRevertCAFs, GHCi_Flag_RevertCAFs); SetDlgItemBool(hDlg, IDC_ChkPrintStats, GHCi_Flag_PrintStats); SetDlgItemBool(hDlg, IDC_ChkPrintTypes, GHCi_Flag_PrintTypes); UpdateFontPreview(hDlg); }
static int CALLBACK check_height_family_enumproc(ENUMLOGFONTEX *enumlf, NEWTEXTMETRICEX *ntm, DWORD type, LPARAM lParam) { HDC hdc = GetDC(NULL); enumlf->elfLogFont.lfHeight = 0; EnumFontFamiliesEx(hdc, &enumlf->elfLogFont, (FONTENUMPROC)check_height_font_enumproc, lParam, 0); ReleaseDC(NULL, hdc); return 1; }
VOID FillFontSizeComboList(HWND hwndCombo) { LOGFONT lf = { 0 }; HDC hdc = GetDC(hwndCombo); /* default size */ INT cursize = 12; INT i, count, nearest = 0; HFONT hFont = GetStockObject(DEFAULT_GUI_FONT); SendMessage(hwndCombo, WM_SETFONT, (WPARAM)hFont, 0); lf.lfCharSet = DEFAULT_CHARSET; lf.lfPitchAndFamily = 0; /* empty the list */ SendMessage(hwndCombo, CB_RESETCONTENT, 0, 0); /* enumerate font sizes */ EnumFontFamiliesEx(hdc, &lf, (FONTENUMPROC)EnumFontSizes, (LPARAM)hwndCombo, 0); /* set selection to first item */ count = (INT)SendMessage(hwndCombo, CB_GETCOUNT, 0, 0); for(i = 0; i < count; i++) { INT n = (INT)SendMessage(hwndCombo, CB_GETITEMDATA, i, 0); if (n <= cursize) nearest = i; } SendMessage(hwndCombo, CB_SETCURSEL, nearest, 0); ReleaseDC(hwndCombo, hdc); }
XInstalledFontCollection::XInstalledFontCollection(void) { HDC hdc=GetDC(0); iMax=0; memset(&lf,0,sizeof(lf)); lf.lfCharSet=DEFAULT_CHARSET; strName[0]=0; EnumFontFamiliesEx(hdc,&lf,(FONTENUMPROCW)funcEnumCount,(LPARAM)this,0); ReleaseDC(0,hdc); }
void ListFonts(HWND hWnd) { LOGFONT LFont; LFont.lfCharSet = DEFAULT_CHARSET; LFont.lfFaceName[0] = '\0'; HDC DC = GetDC(0); EnumFontFamiliesEx(DC, &LFont, (FONTENUMPROC)EnumFontProc, (LPARAM)hWnd, 0); ReleaseDC(0, DC); }
void FillFontListThread(void *param) { HDC hdc = GetDC((HWND)param); LOGFONT lf = {0}; lf.lfCharSet = DEFAULT_CHARSET; lf.lfFaceName[0] = 0; lf.lfPitchAndFamily = 0; EnumFontFamiliesEx(hdc, &lf, (FONTENUMPROC) EnumFontsProc, (LPARAM) GetDlgItem((HWND)param, IDC_TYPEFACE), 0); ReleaseDC((HWND)param, hdc); }
XFontFamily::XFontFamily(wchar_t *str) { HDC hdc=GetDC(0); memset(&lf,0,sizeof(lf)); dwFontType=0; fam=new FontFamily(str); memset(&lf,0,sizeof(lf)); lf.lfCharSet=DEFAULT_CHARSET; wcsncpy_s(lf.lfFaceName,LF_FACESIZE,str,32); lf.lfFaceName[31]=0; EnumFontFamiliesEx(hdc,&lf,(FONTENUMPROCW)funcEnumGet,(LPARAM)this,0); ReleaseDC(0,hdc); }
bool CRbFont::IsExist(const wchar_t *filename) { static LOGFONTW lfw; wcscpy_s(lfw.lfFaceName, filename); int lp = 0; HDC hScreenDC = GetDC(NULL); if (EnumFontFamiliesEx(hScreenDC, &lfw, (FONTENUMPROC)FontCallback, lp, 0) == 7) return true; else return false; }
extern "C" BOOL _stdcall EnumerateFonts(HWND w){ HDC hdc = GetDC(NULL); LOGFONT lf; memset(&lf,0,sizeof(lf)); lf.lfCharSet=DEFAULT_CHARSET; EnumFontFamiliesEx(hdc,&lf,(FONTENUMPROC)&EnumFontFamExProc,(LPARAM)w,0); ReleaseDC(NULL, hdc); return true; }
void FontCache::getTraitsInFamily(const AtomicString& familyName, Vector<unsigned>& traitsMasks) { LOGFONT logFont; logFont.lfCharSet = DEFAULT_CHARSET; unsigned familyLength = std::min(familyName.length(), static_cast<unsigned>(LF_FACESIZE - 1)); memcpy(logFont.lfFaceName, familyName.characters(), familyLength * sizeof(UChar)); logFont.lfFaceName[familyLength] = 0; logFont.lfPitchAndFamily = 0; TraitsInFamilyProcData procData(familyName); EnumFontFamiliesEx(g_screenDC, &logFont, traitsInFamilyEnumProc, reinterpret_cast<LPARAM>(&procData), 0); copyToVector(procData.m_traitsMasks, traitsMasks); }
CSSResourceCache::CSSResourceCache() : dpi(96.0f) { #ifdef WIN32 HDC screen_dc = GetDC(0); LOGFONT logfont = { 0 }; logfont.lfFaceName[0] = 0; logfont.lfCharSet = DEFAULT_CHARSET; logfont.lfPitchAndFamily = DEFAULT_PITCH; BOOL result = EnumFontFamiliesEx(screen_dc, &logfont, &static_enum_font_families_callback, (LPARAM)this, 0); ReleaseDC(0, screen_dc); #endif }
// // Add every fontname into specified combobox // void AddFonts(HWND hwndCombo) { HDC hdc; LOGFONT lf; lf.lfCharSet = ANSI_CHARSET; lf.lfPitchAndFamily = 0; lf.lfFaceName[0] = '\0'; hdc = GetDC(0); EnumFontFamiliesEx(hdc, &lf, (FONTENUMPROC)EnumFontProc, (LONG)hwndCombo, 0); ReleaseDC(0, hdc); }
void CVisualSynanView::OnInitialUpdate() { CView::OnInitialUpdate(); CClientDC dc(this); LOGFONT lfFont; strcpy(lfFont.lfFaceName,"Times New Roman"); lfFont.lfCharSet = RUSSIAN_CHARSET; EnumFontFamiliesEx(dc.m_hDC, &lfFont , &GetFefaultFontEx,(LPARAM)this,0); if( !m_bExistUsefulFont ) EnumFontFamiliesEx(dc.m_hDC, NULL, &GetFefaultFontEx,(LPARAM)this,0); UpdateFontsFromLogFont(); //creating tooltip ctrl EnableToolTips(); m_ctrlToolTip.Create(this); CRect StupidRect(0,0,0,0);//some unuseful rect //we will change this rect dinamicly m_ctrlToolTip.AddTool( this, LPSTR_TEXTCALLBACK, StupidRect ,ID_WORD_TOOL); m_ctrlToolTip.Activate(TRUE); m_ctrlToolTip.SetDelayTime(TTDT_AUTOPOP,1000000); ResizeScroll(); }
void XInstalledFontCollection::GetFamilies(int iNum,XFontFamily *aff,int *piNum) { HDC hdc=GetDC(0); iCount=0; afPtr=aff; iNumCount=iNum; strName[0]=0; memset(&lf,0,sizeof(lf)); lf.lfCharSet=DEFAULT_CHARSET; EnumFontFamiliesEx(hdc,&lf,(FONTENUMPROCW)funcEnumGet,(LPARAM)this,0); ReleaseDC(0,hdc); qsort(aff,iNumCount,sizeof(XFontFamily),(int (*)(const void*, const void*))funcSort); if(piNum) *piNum=iNumCount; }
bool IsFontInstalled( const char* pFaceName ) { assert(pFaceName); assert(strlen(pFaceName)<LF_FACESIZE); LOGFONT lf; FONTINFO fi; fi.yn = 0; strcpy( fi.FaceName, pFaceName ); lf.lfCharSet = DEFAULT_CHARSET; lf.lfPitchAndFamily = 0; strcpy( lf.lfFaceName, pFaceName ); EnumFontFamiliesEx( GetDC(0), &lf, (FONTENUMPROC)EnumFontProc, (LPARAM)&fi, 0 ); return fi.yn ? true : false; }
void ListFontSizes(HWND hWnd, const char* FaceName) { int Size = atoi(GetWindowText(hWnd)); SendMessage(hWnd, CB_RESETCONTENT, 0, 0); LOGFONT LFont; LFont.lfCharSet = DEFAULT_CHARSET; strncpy(LFont.lfFaceName, FaceName, LF_FACESIZE); HDC DC = GetDC(0); EnumFontFamiliesEx(DC, &LFont, (FONTENUMPROC)EnumFontSizeProc, (LPARAM)hWnd, 0); ReleaseDC(0, DC); char* Str = IntToStr(Size); if (SendMessage(hWnd, CB_SELECTSTRING, (WPARAM)0, (LPARAM)Str) == CB_ERR) SetWindowText(hWnd, Str); delete[] Str; }
StringArray Font::findAllTypefaceNames() { StringArray results; #if JUCE_USE_DIRECTWRITE const Direct2DFactories& factories = Direct2DFactories::getInstance(); if (factories.systemFonts != nullptr) { ComSmartPtr<IDWriteFontFamily> fontFamily; uint32 fontFamilyCount = 0; fontFamilyCount = factories.systemFonts->GetFontFamilyCount(); for (uint32 i = 0; i < fontFamilyCount; ++i) { HRESULT hr = factories.systemFonts->GetFontFamily (i, fontFamily.resetAndGetPointerAddress()); if (SUCCEEDED (hr)) results.addIfNotAlreadyThere (getFontFamilyName (fontFamily)); } } else #endif { HDC dc = CreateCompatibleDC (0); { LOGFONTW lf = { 0 }; lf.lfWeight = FW_DONTCARE; lf.lfOutPrecision = OUT_OUTLINE_PRECIS; lf.lfQuality = DEFAULT_QUALITY; lf.lfCharSet = DEFAULT_CHARSET; lf.lfClipPrecision = CLIP_DEFAULT_PRECIS; lf.lfPitchAndFamily = FF_DONTCARE; EnumFontFamiliesEx (dc, &lf, (FONTENUMPROCW) &FontEnumerators::fontEnum1, (LPARAM) &results, 0); } DeleteDC (dc); } results.sort (true); return results; }
static bool platformIsFontInstalled(const char* faceName) { const int MaxSize = 512; if (strlen(faceName) > MaxSize) { throw std::runtime_error("Not enough memory"); } wchar_t lz[MaxSize] = { 0 }; mbstowcs(lz, faceName, strlen(faceName)); HDC hdc = GetDC(NULL); LOGFONT lf = { 0 }; lf.lfCharSet = DEFAULT_CHARSET; _tcscpy(lf.lfFaceName, lz); LPARAM lparam = 0; EnumFontFamiliesEx(hdc, &lf, (FONTENUMPROC)EnumFontFamiliesExProc, (LPARAM)&lparam, 0); return lparam ? true : false; }
BOOL CSkinBase::FontIsPresent(LPCTSTR szFaceName) { LOGFONT lf; HDC hdc = ::GetDC(NULL); lf.lfCharSet = DEFAULT_CHARSET; lf.lfPitchAndFamily = 0; lstrcpy(lf.lfFaceName, szFaceName); BOOL bPresent = FALSE; EnumFontFamiliesEx(hdc, &lf, (FONTENUMPROC)CheckFontProc, (LPARAM)&bPresent, 0); ::ReleaseDC(NULL, hdc); return bPresent; }
void ui_menu_font_ui::list() { // create LOGFONT structure LOGFONT lf; lf.lfCharSet = ANSI_CHARSET; lf.lfFaceName[0] = '\0'; HDC hDC = GetDC( nullptr ); EnumFontFamiliesEx( hDC, &lf, (FONTENUMPROC)EnumFontFamiliesExProc, (LPARAM)&m_fonts, 0 ); ReleaseDC( nullptr, hDC ); // sort std::stable_sort(m_fonts.begin(), m_fonts.end()); // add default string to the top of array m_fonts.insert(m_fonts.begin(), std::string("default")); }
bool IsFontInstalled(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_s(lf.lfFaceName, lpszFont); LPARAM lParam = 0; // Enumerate fonts EnumFontFamiliesEx(dc.GetSafeHdc(), &lf, (FONTENUMPROC)EnumFontFamExProc, (LPARAM)&lParam, 0); return lParam ? true : false; }