/* * CreateStatusFont - creates the font used in the status window */ void CreateStatusFont( void ) { WPI_LOGFONT logfont; WPI_PROC fp; WPI_PRES pres; pres = _wpi_getpres( HWND_DESKTOP ); #ifdef __OS2_PM__ _wpi_enumfonts( pres, NULL, (WPI_ENUMFONTPROC)EnumFontFunc, "Helv" ); fp = fp; #else fp = _wpi_makeprocinstance( EnumFontFunc, Instance ); #ifdef __NT__ EnumFonts( hdc, NULL, (LPVOID)fp, (LPARAM)(LPCSTR)"ms sans serif"); #else EnumFonts( hdc, NULL, (LPVOID)fp, (LPVOID)"ms sans serif"); #endif #endif _wpi_freeprocinstance( fp ); if( currentLogFont == NULL ) { // SmallFont = GetStockObject( ANSI_FIXED_FONT ); // GetObject( SmallFont, sizeof( LOGFONT ), (LPSTR) &logfont ); // SmallFont = CreateFontIndirect( &logfont ); } else { memcpy( &logfont, currentLogFont, sizeof(WPI_LOGFONT) ); // _wpi_setfontheight( &logfont, 11 ); // _wpi_setfontwidth( &logfont, 10 ); _wpi_setfontpointsize( &logfont, 10, 0, _wpi_fontmatch(&logfont) ); _wpi_createrealfont( logfont, SmallFont ); #if 0 SmallFont = CreateFont( 10, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, currentLogFont->lfCharSet, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, currentLogFont->lfPitchAndFamily, currentLogFont->lfFaceName ); #endif free( currentLogFont ); currentLogFont = NULL; } _wpi_releasepres( HWND_DESKTOP, pres ); } /* CreateStatusFont */
bool SchemeConfigParser::validateFont(LPCTSTR fontName) { FontValidationInfo fvi; fvi.Name = fontName; EnumFonts(GetDC(NULL), NULL, (FONTENUMPROC)ValidateFontCB, reinterpret_cast<LPARAM>(&fvi)); return fvi.Found; }
void CAutoRichEditCtrl::GetSystemFonts(CStringArray &saFontList) { CDC *pDC = GetDC (); EnumFonts (pDC->GetSafeHdc(),NULL,(FONTENUMPROC) CBEnumFonts,(LPARAM)&saFontList);//Enumerate }
static void PASCAL BuildFaceList (HWND hDlg, char *FaceName) /* This function initializes the Font list box with fixed fonts matching the current charset selection and then selects an item */ { SendDlgItemMessage (hDlg, ID_FONTSIZE, WM_SETREDRAW, FALSE, 0L); SendDlgItemMessage (hDlg, ID_FONT, LB_RESETCONTENT, 0, 0L); { HDC hDC; FARPROC ProcInstance; hDC = GetDC (hDlg); ProcInstance = MakeProcInstance ((FARPROC)EnumFacesProc, hEmacsInstance); EnumFonts (hDC, NULL, ProcInstance, LPDATA(&hDlg)); FreeProcInstance (ProcInstance); ReleaseDC (hDlg, hDC); } SendDlgItemMessage (hDlg, ID_FONT, WM_SETREDRAW, TRUE, 0L); InvalidateRect (GetDlgItem (hDlg, ID_FONT), NULL, TRUE); /*-select the same facename as before or default to the first item */ if (SendDlgItemMessage (hDlg, ID_FONT, LB_SELECTSTRING, -1, (DWORD)FaceName) == LB_ERR) { SendDlgItemMessage (hDlg, ID_FONT, LB_SETCURSEL, 0, 0L); } BuildSizeList (hDlg, &Metrics); } /* BuildFaceList */
std::unique_ptr<CFGAS_FontMgr> CFGAS_FontMgr::Create( CFX_FontSourceEnum_File* pFontEnum) { if (!pFontEnum) return nullptr; auto pFontMgr = pdfium::MakeUnique<CFGAS_FontMgr>(pFontEnum); if (!pFontMgr->EnumFonts()) return nullptr; return pFontMgr; }
/* * EnumFunc - enumerate fonts */ WINEXPORT int CALLBACK EnumFunc( LPLOGFONT lf, LPTEXTMETRIC tm, UINT ftype, LPSTR data ) { tm = tm; ftype = ftype; data = data; /* * Something has happened in the font world and Windows font mapper since * the original source was written, it checked only for Courier. All the * font names below are verified as good monospaced fonts. Check for the * best fonts first, so that the system picks the best if enumerated first. * Changed the test to == 0, because it is easier to read and understand. */ #if defined( __NT__ ) if( FARstricmp( lf->lfFaceName, "andale mono" ) == 0 || FARstricmp( lf->lfFaceName, "lucida console" ) == 0 || FARstricmp( lf->lfFaceName, "vera sans mono" ) == 0 || FARstricmp( lf->lfFaceName, "courier new" ) == 0 || FARstricmp( lf->lfFaceName, "courier" ) == 0 ) { #else if( FARstricmp( lf->lfFaceName, "courier new" ) == 0 || FARstricmp( lf->lfFaceName, "courier" ) == 0 ) { #endif courierFont = CreateFont( 13, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, lf->lfCharSet, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, lf->lfPitchAndFamily, lf->lfFaceName ); return( 0 ); } return( 1 ); } /* EnumFunc */ /* * getCourierFont - find a mono font */ static void getCourierFont( HANDLE inst ) { LOGFONT logfont; FARPROC fp; HDC hdc; inst = inst; /* shut up the compiler for NT */ hdc = GetDC( (HWND)NULL ); fp = MakeProcInstance( (FARPROC)EnumFunc, inst ); EnumFonts( hdc, NULL, (LPVOID)fp, 0 ); FreeProcInstance( fp ); ReleaseDC( (HWND)NULL, hdc ); if( courierFont == NULL ) { courierFont = GetStockObject( ANSI_FIXED_FONT ); GetObject( courierFont, sizeof( LOGFONT ), (LPSTR)&logfont ); courierFont = CreateFontIndirect( &logfont ); } } /* getCourierFont */
bool IrisFont::Existed(wstring name){ LPARAM lp = 0; lp = EnumFonts(NULL, name.c_str(), (FONTENUMPROC)EnumFontsProc, lp); if (lp == 0){ return false; } else { return true; } }
//--------------------------------------------------------------------------- void __fastcall TSourceCodeForm1::FormCreate(TObject *Sender) { FileName = "Untitled.asm"; EnumFonts(Canvas->Handle, NULL, (FONTENUMPROC) EnumProc, (LPARAM)FontSelectComboBox1) ; FontSelectComboBox1->ItemIndex = FontSelectComboBox1->Items->IndexOf(RichEdit1->Font->Name) ; RichEdit1->SelAttributes->Name = FontSelectComboBox1->Text; StatusBar1->Panels->Items[1]->Text = "0 Lines"; StatusBar1->Panels->Items[2]->Text = FileName; RichEdit1->Clear(); }
BOOL WINAPI IsFontAvailable( PCTSTR pszFaceName ) { // Yes, EnumFonts is old, but we neither need nor care about the additional // info returned by the newer font enumeration APIs; all that we care about // is whether the callback is ever called. BOOL fFound = FALSE; HDC hDC = GetDC(NULL); EnumFonts(hDC, pszFaceName, EnumFontsProc, (LPARAM)&fFound); ReleaseDC(NULL, hDC); return(fFound); }
void CRaster::loadFontSizes() { // load the font size control CString s; c_Fonts.GetWindowText(s); c_FontSize.ResetContent(); CClientDC dc(this); EnumFonts(dc.m_hDC, s, &CRaster::loadFontSizes, (LPARAM)this); // REQ #051 c_FontSize.SetCurSel(0); }
//--------------------------------------------------------------------------- __fastcall TFontMakerForm::TFontMakerForm(TComponent* Owner) : TForm(Owner) { FontPreviewForm = NULL; CharacterListInvalidated = true; CharacterList = new wchar_t [65536*2]; PrivRefControl = new TPrivRefControl(this); PrivRefControl->Parent = this; PrivRefControl->Left = -1; PrivRefControl->Top = -1; PrivRefControl->Width = 1; PrivRefControl->Height = 1; PrivRefControl->Visible = true; HMODULE gdi32dll = GetModuleHandle("gdi32.dll"); *(void**)&procGetFontUnicodeRanges = GetProcAddress(gdi32dll, "GetFontUnicodeRanges"); *(void**)&procGetGlyphIndicesW = GetProcAddress(gdi32dll, "GetGlyphIndicesW"); *(void**)&procGetGlyphOutlineW = GetProcAddress(gdi32dll, "GetGlyphOutlineW"); *(void**)&procTextOutW = GetProcAddress(gdi32dll, "TextOutW"); *(void**)&procGetTextExtentPoint32W = GetProcAddress(gdi32dll, "GetTextExtentPoint32W"); if(Win32Platform != VER_PLATFORM_WIN32_NT) procGetGlyphOutlineW = NULL; // ?? this cannot be used ... if(!procTextOutW || !procGetTextExtentPoint32W) throw Exception("Windows95 (or OS which does not support wide character code API) is not supported on this tool!"); BoldCheckBox->Enabled = (Win32Platform == VER_PLATFORM_WIN32_NT); IncludeAllFontCharsCheckBox->Enabled = (procGetFontUnicodeRanges && procGetGlyphOutlineW && procGetGlyphIndicesW); IncludePrivateCharsCheckBox->Enabled = (procGetFontUnicodeRanges && procGetGlyphOutlineW && procGetGlyphIndicesW); EnumFonts(); LOGFONT font; SetFontToCanvas(font); }
/* * getCourierFont - find a mono font */ static void getCourierFont( HANDLE inst ) { LOGFONT logfont; FARPROC fp; HDC hdc; inst = inst; /* shut up the compiler for NT */ hdc = GetDC( (HWND) NULL ); fp = MakeProcInstance( (FARPROC) EnumFunc, inst ); EnumFonts( hdc, NULL, (LPVOID) fp, 0 ); FreeProcInstance( fp ); ReleaseDC( (HWND) NULL, hdc ); if( courierFont == NULL ) { courierFont = GetStockObject( ANSI_FIXED_FONT ); GetObject( courierFont, sizeof( LOGFONT ), (LPSTR) &logfont ); courierFont = CreateFontIndirect( &logfont ); } } /* getCourierFont */
void vTestKerning( HWND hwnd, HDC hdc, RECT *prect ) { FTPARAM ftp; HBRUSH hbOld; char ach[100]; char *psz1 = "*** GetKerningPairs Test ***"; char *psz2 = "*** GetKerningPairs Test is Finished ***"; HBRUSH hbrushKern; hbrushKern = CreateHatchBrush(HS_CROSS,RGB(0xC0,0xC0,0xC0)); hbOld = SelectObject(hdc,hbrushKern); PatBlt( hdc, prect->left, prect->top, prect->right - prect->left, prect->bottom - prect->top, PATCOPY ); SelectObject(hdc,hbOld); DeleteObject(hbrushKern); ftp.hwnd = hwnd; ftp.hdc = hdc; ftp.prect = prect; TextOut(hdc,0,0,psz1,strlen(psz1)); EnumFonts(hdc,(LPCSTR) NULL,FontFunc,(LPARAM) &ftp); TextOut(hdc,0,0,psz2,strlen(psz2)); }
int far pascal zEnumFonts( HDC pp1, LPSTR pp2, FARPROC pp3, LPSTR pp4 ) { int r; FARPROC fpCentslessTaker; SaveRegs(); /* ** Log IN Parameters (No Create/Destroy Checking Yet!) */ LogIn( (LPSTR)"APICALL:EnumFonts HDC+LPSTR+FARPROC+DWORD+", pp1, pp2, pp3, pp4 ); /* Hook the callback function (a census taker) with our own little twist */ fpCentslessTaker = (FARPROC) HookAdd((void far *)FontCounter, (void far *) pp3); /* ** Call the API! */ RestoreRegs(); GrovelDS(); r = EnumFonts(pp1, pp2, fpCentslessTaker, pp4); UnGrovelDS(); SaveRegs(); /* ** Log Return Code & OUT Parameters (No Create/Destroy Checking Yet!) */ LogOut( (LPSTR)"APIRET:EnumFonts int+++++", r, (short)0, (short)0, (short)0, (short)0 ); RestoreRegs(); return( r ); }
////////////////////////////////////////////////////////////////////////// // Member BOOL WINAPI duWindowManager::OpenSkin(LPCTSTR lpszXmlFile) { if (lpszXmlFile == NULL || *lpszXmlFile == 0) return FALSE; InitTrialBitmap(); LPCTSTR lpszTypeName = GetTypeInfoName(); ITypeInfo *pTypeInfo = GetTypeInfoByName(lpszTypeName); SetTypeInfo(pTypeInfo); _tcsncpy(m_szSkinPath, lpszXmlFile, MAX_PATH); TCHAR *lpszChar = _tcsrchr(m_szSkinPath, '\\'); if (lpszChar == NULL) { ZeroMemory(m_szSkinPath, MAX_PATH * sizeof(TCHAR)); return FALSE; } lpszChar++; *lpszChar = 0; IStream *pStream = NULL; HANDLE hMem = NULL; PBYTE pByte = GetResource(_T("config.xml"), hMem, pStream); if (pByte == NULL || pStream == NULL || hMem == NULL) return FALSE; m_pResManager = new duResManager(); m_pResManager->SetWindowManager(this); m_pDocXml = new TiXmlDocument; #ifdef _UNICODE int nSize = GlobalSize(hMem); char *p = new char[nSize + 2]; memcpy(p, pByte, nSize); p[nSize] = _T('\0'); p[nSize+1] = _T('\0'); wchar_t *pW = (wchar_t *)p; pW++; m_pDocXml->Parse(pW, NULL); SAFE_DELETE_ARRAY(p); #else m_pDocXml->Parse((LPCTSTR)pByte, NULL); #endif ReleaseResource(hMem, pStream); TiXmlElement *pElement = NULL; TiXmlHandle xmlHandler(m_pDocXml->FirstChildElement(_T("directui"))); pElement = xmlHandler.FirstChildElement(_T("theme")).Element(); if (!m_pResManager->OnCreate(pElement)) return FALSE; // //×öÑźÚ×ÖÌåµÄÅжϣ¬Èç¹ûûÓÐÑźÚ×ÖÌ壬¾Í½«ÑźڼӴָÄΪÕý³£´ÖϸµÄ // g_bYaheiExist = FALSE; EnumFonts(::GetDC(NULL), NULL, (FONTENUMPROC)FPC_EnumFontProc, NULL); if (!g_bYaheiExist) //Ñźڲ»´æÔÚ { int i; int nFontCount = m_pResManager->GetResObjCount(DU_RES_FONT); for (i = 0;i < nFontCount; i++) { duFont *pFont = (duFont *)m_pResManager->GetResObjByIndex(i,DU_RES_FONT); if (pFont->GetWeight() != 400) { pFont->SetWeight(400); pFont->CreateFont(); } } } m_pJavaScript = new duJavaScript; hMem = NULL; pStream = NULL; pByte = GetResource(_T("DirectUI.js"), hMem, pStream); if (pByte == NULL || pStream == NULL || hMem == NULL) return TRUE; nSize = GlobalSize(hMem); p = new char[nSize + 128]; ZeroMemory(p, nSize); memcpy(p, pByte, nSize); p[nSize] = _T('\0'); p[nSize+1] = _T('\0'); pW = (wchar_t *)p; pW++; lstrcat(pW, _T("\r\nCollectGarbage();\r\n")); m_pJavaScript->InitJavaScript(pW); SAFE_DELETE_ARRAY(p); lpszTypeName = m_pResManager->GetTypeInfoName(); pTypeInfo = GetTypeInfoByName(lpszTypeName); m_pResManager->SetTypeInfo(pTypeInfo); ReleaseResource(hMem, pStream); m_pJavaScript->AddObject(_T("winManager"), this); m_pJavaScript->AddObject(_T("resManager"), m_pResManager); return TRUE; }
//--------------------------------------------------------------------------- void __fastcall TFontMakerForm::ShowAllFontsCheckBoxClick(TObject *Sender) { EnumFonts(); NotifyFontChanged(); }
int CALLBACK EnumFontsEnumFunc( const LOGFONT FAR *lf, const TEXTMETRIC FAR *tm, DWORD ftype, LPARAM data ) #endif { #ifdef __WINDOWS_386__ const LOGFONT __far *lf = MK_FP32( (void *)_lf ); tm = tm; #elif defined( __WINDOWS__ ) const LOGFONT FAR *lf = (const LOGFONT FAR *)elf; // const TEXTMETRIC FAR *tm = (const TEXTMETRIC FAR *)ntm; ntm = ntm; #else tm = tm; #endif ftype = ftype; data = data; /* * Something has happened in the font world and Windows font mapper since * the original source was written, it checked only for Courier. All the * font names below are verified as good monospaced fonts. Check for the * best fonts first, so that the system picks the best if enumerated first. * Changed the test to == 0, because it is easier to read and understand. */ #if defined( __NT__ ) if( FARstricmp( lf->lfFaceName, "andale mono" ) == 0 || FARstricmp( lf->lfFaceName, "lucida console" ) == 0 || FARstricmp( lf->lfFaceName, "vera sans mono" ) == 0 || FARstricmp( lf->lfFaceName, "courier new" ) == 0 || FARstricmp( lf->lfFaceName, "courier" ) == 0 ) { #else if( FARstricmp( lf->lfFaceName, "courier new" ) == 0 || FARstricmp( lf->lfFaceName, "courier" ) == 0 ) { #endif courierFont = CreateFont( 13, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, lf->lfCharSet, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, lf->lfPitchAndFamily, lf->lfFaceName ); return( 0 ); } return( 1 ); } /* EnumFunc */ /* * getCourierFont - find a mono font */ static void getCourierFont( HANDLE inst ) { LOGFONT logfont; FARPROC fp; HDC hdc; inst = inst; /* shut up the compiler for NT */ hdc = GetDC( HWND_DESKTOP ); fp = MakeFontEnumProcInstance( EnumFontsEnumFunc, inst ); #if defined( __WINDOWS__ ) && defined( _M_I86 ) EnumFonts( hdc, NULL, (OLDFONTENUMPROC)fp, 0 ); #else EnumFonts( hdc, NULL, (FONTENUMPROC)fp, 0 ); #endif FreeProcInstance( fp ); ReleaseDC( (HWND)NULL, hdc ); if( courierFont == NULL ) { courierFont = GetStockObject( ANSI_FIXED_FONT ); GetObject( courierFont, sizeof( LOGFONT ), (LPSTR)&logfont ); courierFont = CreateFontIndirect( &logfont ); } } /* getCourierFont */
static void Initialize(HWND hWnd) { _hWnd = hWnd; ResetConfig(); SE_InitEngine(""); // Get device content HDC hDC = GetDC(hWnd); if(hDC==NULL) { ASSERT(FALSE); return; } EnumFonts(hDC,NULL,(FONTENUMPROC)ProcEnumFonts,0); SendDlgItemMessage(_hWnd,ICB_FONT_NAMES,CB_SETCURSEL,(WPARAM) 0,0); char strText[32] = {0,}; INDEX ctFontSizes = sizeof(_aiFontSizes) / sizeof(INDEX); for(INDEX ifs=0;ifs<ctFontSizes;ifs++) { itoa(_aiFontSizes[ifs],strText,10); SendDlgItemMessage(_hWnd,ICB_FONT_SIZES,CB_ADDSTRING,0,(LPARAM) (LPCTSTR) strText); } SendDlgItemMessage(_hWnd,ICB_FONT_SIZES,CB_SETCURSEL,(WPARAM)4, 0); // Align SendDlgItemMessage(_hWnd,IDC_ALIGN_H,CB_ADDSTRING,0,(LPARAM) (LPCTSTR) "H"); SendDlgItemMessage(_hWnd,IDC_ALIGN_H,CB_ADDSTRING,0,(LPARAM) (LPCTSTR) "C"); SendDlgItemMessage(_hWnd,IDC_ALIGN_H,CB_ADDSTRING,0,(LPARAM) (LPCTSTR) "V"); SendDlgItemMessage(_hWnd,IDC_ALIGN_V,CB_ADDSTRING,0,(LPARAM) (LPCTSTR) "H"); SendDlgItemMessage(_hWnd,IDC_ALIGN_V,CB_ADDSTRING,0,(LPARAM) (LPCTSTR) "C"); SendDlgItemMessage(_hWnd,IDC_ALIGN_V,CB_ADDSTRING,0,(LPARAM) (LPCTSTR) "V"); SetComboIndex(IDC_ALIGN_H,1); SetComboIndex(IDC_ALIGN_V,1); INDEX ctTexSizes = sizeof(_aiTexSizes) / sizeof(INDEX); for(INDEX its=0;its<ctTexSizes;its++) { itoa(_aiTexSizes[its],strText,10); SendDlgItemMessage(_hWnd,ICB_TEX_WIDTH,CB_ADDSTRING,0,(LPARAM) (LPCTSTR) strText); SendDlgItemMessage(_hWnd,ICB_TEX_HEIGHT,CB_ADDSTRING,0,(LPARAM) (LPCTSTR) strText); } SendDlgItemMessage(_hWnd,ICB_TEX_WIDTH,CB_SETCURSEL,(WPARAM)2, 0); SendDlgItemMessage(_hWnd,ICB_TEX_HEIGHT,CB_SETCURSEL,(WPARAM)2, 0); ReleaseDC(hWnd, hDC); HWND hWndCanvas = GetDlgItem(hWnd,IDC_CANVAS); ASSERT(hWndCanvas!=NULL); ClearCharTable(); SetWindowLong(hWndCanvas,GWL_WNDPROC,(LONG)CanvasProc); _pGfx->ResetDisplayMode(GAT_OGL); _pGfx->CreateWindowCanvas(hWndCanvas, &_pvpViewPort, &_pdpDrawPort); UpdateWindow(hWndCanvas); _bInitialized = TRUE; GenerateFont(); LoadSettings((CTString)"Temp\\GenFont.cfg"); }
/* ============= */ int EXPORT FAR PASCAL EnumSizesProc (LPLOGFONT lf, LPTEXTMETRIC tm, short FontType, LPSTR Data) /* Data should point to a handle to the dialog box */ { if ((lf->lfWeight > 400) || lf->lfItalic || lf->lfUnderline || lf->lfStrikeOut) return 1; #if WIN30SDK if (FontType & 0x04) { #else if (FontType & TRUETYPE_FONTTYPE) { #endif /* make a size list up */ short int h; for (h = lf->lfHeight / 4; h <= (3 * lf->lfHeight) / 2; h += 2) { AddSize (*(HWND FAR *)Data, h, 0); } return 0; /* no need to list this one further */ } else { /* non-scalable font */ /* list it only if it has a proper aspect ratio */ HFONT hFont; LOGFONT Font; TEXTMETRIC Metrics; Font = *lf; Font.lfWidth = 0; hFont = CreateFontIndirect (&Font); GetFontMetrics (hFont, &Metrics, NULL); DeleteObject (hFont); if (tm->tmAveCharWidth == Metrics.tmAveCharWidth) { AddSize (*(HWND FAR *)Data, (short int)lf->lfHeight, (short int)lf->lfWidth); } } return 1; } /* EnumSizesProc */ /* BuildSizeList: initializes the FontSize list box */ /* ============= */ static void PASCAL BuildSizeList (HWND hDlg, TEXTMETRIC *Metrics) /* This function initializes the FontSize list box with the sizes available for the face name currently selected in the Font list box. The sizes are written in the format: CXxCY. Also, the sizes are stored in the 32 bit values retrievable by LB_GETITEMDATA: width in the low-order word and height in the high order word */ { SendDlgItemMessage (hDlg, ID_FONTSIZE, WM_SETREDRAW, FALSE, 0L); SendDlgItemMessage (hDlg, ID_FONTSIZE, CB_RESETCONTENT, 0, 0L); { HDC hDC; FARPROC ProcInstance; char FaceName[LF_FACESIZE]; SendDlgItemMessage (hDlg, ID_FONT, LB_GETTEXT, (UINT)SendDlgItemMessage (hDlg, ID_FONT, LB_GETCURSEL, 0, 0L), (DWORD)(LPSTR)&FaceName[0]); /* FaceName now contains the currently selected face name */ hDC = GetDC (hDlg); ProcInstance = MakeProcInstance ((FARPROC)EnumSizesProc, hEmacsInstance); EnumFonts (hDC, FaceName, ProcInstance, LPDATA(&hDlg)); FreeProcInstance (ProcInstance); ReleaseDC (hDlg, hDC); if (SendDlgItemMessage (hDlg, ID_FONTSIZE, CB_GETCOUNT, 0, 0L) == 0) { /* no size at all in the size list (ATM, for instance, does that!). Let's fill it with a few sample sizes... */ short int h; for (h = 6; h <= 40; h += 2) AddSize (hDlg, h, 0); } } SendDlgItemMessage (hDlg, ID_FONTSIZE, WM_SETREDRAW, TRUE, 0L); InvalidateRect (GetDlgItem (hDlg, ID_FONTSIZE), NULL, TRUE); { /*-Select the larger height that is smaller or equal to the current Metrics (assumed to be the ones of the previous font) */ int i; int BestIndex = 0; short int h, w, BestHeight = 0, BestWidth = 0; DWORD ItemData; for (i = 0;; i++) { ItemData = SendDlgItemMessage (hDlg, ID_FONTSIZE, CB_GETITEMDATA, i, 0L); if (ItemData == CB_ERR) break; /* end of list hit */ if ((h = HIWORD(ItemData)) > Metrics->tmHeight) continue; if (BestHeight > h) continue; w = LOWORD(ItemData); if (BestHeight == h) { /* use the width to optimize */ if (w > Metrics->tmAveCharWidth) continue; if (BestWidth > w) continue; } BestHeight = h; BestWidth = w; BestIndex = i; } SendDlgItemMessage (hDlg, ID_FONTSIZE, CB_SETCURSEL, BestIndex, 0L); } NewFont (hDlg, TRUE); } /* BuildSizeList */