The opinions expressed herein are my own personal opinions. They are not necessarily fact or sactioned by any other person or organization. If you disagree that's your right. It's also my right to not care.
© Copyright 2008, Chris Tacke
A newsgroup post today reminded me of a simple app I wrote a few years back that enumerates all Fonts on a CE device, then searches a specific location (an inserted storage card in this case), adds any fonts found, then re-enumerates all the existing fonts.
Here's the code, in its entirety:
#include <windows.h>#define FONT_PATH (_T("\\Storage Card"))void FindFonts(TCHAR *location, TCHAR *type);int CALLBACK EnumFontFamProc(ENUMLOGFONT *lpelf, TEXTMETRIC *lpntm, int FontType, LPARAM lParam);int WINAPI WinMain(HINSTANCE hInst,HINSTANCE hInstPrev,LPTSTR lpszCmdLine,int nCmdShow){ HDC pDC = GetDC(NULL); // // Enumerate all the fonts // RETAILMSG(TRUE, (_T("\r\n------------------------------\r\n"))); RETAILMSG(TRUE, (_T("Available Fonts on this device\r\n------------------------------\r\n"))); EnumFontFamilies(pDC, NULL, (FONTENUMPROC)EnumFontFamProc, NULL); RETAILMSG(TRUE, (_T("------------------------------\r\n\n"))); RETAILMSG(TRUE, (_T("Looking for fonts on Storage Card...\r\n"))); // TrueType file (.ttf) FindFonts(FONT_PATH, _T("TTF")); // TrueType resource file (.fot) FindFonts(FONT_PATH, _T("FOT")); // TrueType collection file (.ttc) FindFonts(FONT_PATH, _T("TTC")); // raw bitmap font file (.fnt) FindFonts(FONT_PATH, _T("FNT")); // raster resource file (.fon) FindFonts(FONT_PATH, _T("FON")); RETAILMSG(TRUE, (_T("\r\n------------------------------\r\n"))); RETAILMSG(TRUE, (_T("Available Fonts on this device\r\n------------------------------\r\n"))); EnumFontFamilies(pDC, NULL, (FONTENUMPROC)EnumFontFamProc, NULL); RETAILMSG(TRUE, (_T("------------------------------\r\n\n"))); ReleaseDC(NULL, pDC); return 0;}void FindFonts(TCHAR *location, TCHAR *type){ TCHAR fontpath[MAX_PATH]; TCHAR findpath[MAX_PATH]; WIN32_FIND_DATA fd; _stprintf(findpath, _T("%s\\*.%s"), location, type); HANDLE hFind = FindFirstFile(findpath, &fd); if(hFind != INVALID_HANDLE_VALUE) { RETAILMSG(TRUE, (_T(" found %s\r\n"), fd.cFileName)); _stprintf(fontpath, _T("\\Storage Card\\%s"), fd.cFileName); AddFontResource(fontpath); while(FindNextFile(hFind, &fd)) { RETAILMSG(TRUE, (_T(" found %s\r\n"), fd.cFileName)); _stprintf(fontpath, _T("\\Storage Card\\%s"), fd.cFileName); AddFontResource(fontpath); } } FindClose(hFind);}int CALLBACK EnumFontFamProc(ENUMLOGFONT *lpelf, TEXTMETRIC *lpntm, int FontType, LPARAM lParam){ RETAILMSG(TRUE, (_T("\t%s\r\n"), lpelf->elfFullName)); return 1;}
Remember Me