/* builtin test program*/ #include extern BOOL MwExtTextOut(HDC hdc, int x, int y, UINT fuOptions, CONST RECT *lprc, LPCVOID lpszString, UINT cbCount, CONST INT *lpDx, int flags); LRESULT CALLBACK wproc(HWND,UINT,WPARAM,LPARAM); unsigned char bufUTF8[20]; unsigned short bufUC16[20]; static void loadBufFromFileUTF8(const char * fname){ FILE * pfile; int readed; pfile = fopen(fname, "r"); if( pfile > 0 ){ readed = fread(bufUTF8, 1, 20, pfile); printf("%d bytes readed from %s\n", readed, fname); fclose(pfile); } } static void loadBufFromFileUC16(const char * fname){ FILE * pfile; int readed; pfile = fopen(fname, "r"); if( pfile > 0 ){ readed = fread(bufUC16, 1, 20, pfile); printf("%d bytes readed from %s\n", readed, fname); fclose(pfile); } } int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, PSTR szCmdLine, int iCmdShow) { static char szAppName[]="FontWin"; HWND hwnd; MSG msg; WNDCLASS wndclass; wndclass.style = CS_DBLCLKS | CS_HREDRAW | CS_VREDRAW; wndclass.lpfnWndProc = (WNDPROC)wproc; wndclass.cbClsExtra =0; wndclass.cbWndExtra =0; wndclass.hInstance =0; wndclass.hIcon =0; wndclass.hCursor =0; wndclass.hbrBackground =(HBRUSH)GetStockObject(LTGRAY_BRUSH); wndclass.lpszMenuName =NULL; wndclass.lpszClassName = szAppName; RegisterClass(&wndclass); hwnd=CreateWindowEx(0L, szAppName, "mbuiltinfont", WS_OVERLAPPEDWINDOW | WS_VISIBLE, CW_USEDEFAULT, CW_USEDEFAULT, 200, 200, NULL, NULL, NULL, NULL); ShowWindow(hwnd,iCmdShow); UpdateWindow(hwnd); while (GetMessage(&msg,NULL,0,0)) { TranslateMessage(&msg); DispatchMessage(&msg); } return msg.wParam; } LRESULT CALLBACK wproc(HWND hwnd, UINT iMsg, WPARAM wParam, LPARAM lParam) { HDC hdc; PAINTSTRUCT ps; RECT rect; short tmp = 1024; HGDIOBJ oldfont; switch (iMsg) { case WM_CREATE: break; case WM_PAINT: /*case WM_MOUSEFIRST:*/ hdc=BeginPaint(hwnd,&ps); GetClientRect(hwnd,&rect); oldfont=SelectObject(hdc,CreateFont(19, 0,0,0,0,0,0,0,0,0,0,0, FF_DONTCARE|DEFAULT_PITCH, "DejaVuSans")); loadBufFromFileUTF8("utf8.txt"); loadBufFromFileUC16("unicode.txt"); MwExtTextOut(hdc, 0, 10, 0, NULL, &tmp, 1, NULL, MWTF_UC16); //This do not show nothing MwExtTextOut(hdc, 0, 20, 0, NULL, "ASCII", 5, NULL, MWTF_ASCII); MwExtTextOut(hdc, 0, 40, 0, NULL, bufUTF8, 19, NULL, MWTF_UTF8); //This show only 8 symbols MwExtTextOut(hdc, 0, 60, 0, NULL, bufUC16, 19, NULL, MWTF_UC16); // DrawText(hdc, "Hola, NOS ¤¾¤؟¤¤ار", -1, &rect, DT_SINGLELINE|DT_CENTER|DT_VCENTER); EndPaint(hwnd,&ps); break; case WM_DESTROY: PostQuitMessage(0); break; default: return DefWindowProc(hwnd,iMsg,wParam,lParam); } return (0); }