1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80
| //-----------------------------------------------------------------------------<
//@F:main.cpp // v:00 r:000 a:009 01.05.2012, EOF=., LEN=., DEBUG;
//@C:mingw32
//@L:libgdi32.a,
#include <windows.h>
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
using namespace std;
//¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
int CALLBACK
EnumFontFamiliesExProc(
ENUMLOGFONTEXW *lpelfe, NEWTEXTMETRICEXW *lpntme, int FontType,
LPARAM lParam){
//==============================================================================
static wstring s1;
wstring s2 = lpelfe->elfFullName;
vector<wstring> *array = (vector<wstring> *)lParam;
if (s1==s2){
s1.assign(s2);
return 1;
}
s1.assign(s2);
array->push_back(s2);
return 1;
}
//¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
int main(){
//==============================================================================
HDC hDC = GetDC(NULL);
vector<wstring> array;
LOGFONTW lf = {0, 0, 0, 0, 0, 0, 0, 0, ANSI_CHARSET, 0, 0, 0, 0, L"\0"};
::EnumFontFamiliesExW(
hDC, &lf, (FONTENUMPROCW)EnumFontFamiliesExProc, (LPARAM) &array, 0);
sort(array.begin(), array.end());
/*
for (unsigned int i=0; i<array.size(); ++i)
wcout<< array[i]<< endl;
wcout<< L"done.\n"<< endl;
//*/
vector<wstring> array2;
for (unsigned int i=0; i<array.size(); ++i){
//wcout <<L"* " <<array[i] << endl;
wcsncpy(lf.lfFaceName, array[i].c_str(), LF_FACESIZE);
::EnumFontFamiliesExW(
hDC, &lf, (FONTENUMPROCW)EnumFontFamiliesExProc, (LPARAM) &array2, 0);
}
sort(array2.begin(), array2.end());
for (unsigned int i=0; i<array2.size(); ++i)
wcout << array2[i] << endl;
//wcout<< L"done2.\n"<< endl;
ReleaseDC(NULL, hDC);
return 0;
}
// |
Partager