// MinGW options: // g++ -O3 -Wall -c -o TextOutTest.o TextOutTest.cpp // g++ -Wl,-subsystem,windows -static-libgcc -o TextOutTest.exe TextOutTest.o -lgdi32 #include #define ETO_PDY 0x2000 LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM); int OldGraMode; int bSelectObject; INT WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrecInstance, LPSTR pszCmdLine, INT nCmdShow) { WNDCLASSEX wc; wc.cbSize = sizeof(WNDCLASSEX); wc.style = CS_HREDRAW | CS_VREDRAW; wc.lpfnWndProc = WndProc; wc.cbClsExtra = 0; wc.cbWndExtra = 0; wc.hInstance = GetModuleHandle(NULL); wc.hIcon = LoadIcon(NULL, IDI_APPLICATION); wc.hCursor = LoadCursor(NULL, IDC_ARROW); wc.hbrBackground = (HBRUSH) GetStockObject(WHITE_BRUSH); wc.lpszMenuName = NULL; wc.lpszClassName = L"abcdefgh"; wc.hIconSm = LoadIcon(NULL, IDI_APPLICATION); if (!RegisterClassEx(&wc)) return -1; HWND hMainWnd = CreateWindow( L"abcdefgh", L"ReactOS Tests", WS_OVERLAPPEDWINDOW, 10, 10, 640, 480, (HWND)NULL, (HMENU)NULL, wc.hInstance, NULL ); if (!hMainWnd) return -1; ShowWindow(hMainWnd, SW_SHOW); MSG msg; while (GetMessage(&msg, NULL, 0, 0)) { TranslateMessage(&msg); DispatchMessage(&msg); } return 0; } LRESULT CALLBACK WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { switch (uMsg) { case WM_PAINT: { PAINTSTRUCT ps; HDC hDC = BeginPaint(hWnd, &ps); int scale = 8; int hello_string_len = 15; const wchar_t* hello_string = L"Hello, ReactOS!"; /* XFORM xf; xf.eM11 = 1.0f / scale; xf.eM22 = 1.0f / scale; xf.eM12 = 0.0f; xf.eM21 = 0.0f; xf.eDx = 0.0f; xf.eDy = 0.0f; OldGraMode= SetGraphicsMode(hDC, GM_ADVANCED); HFONT hFont = CreateFontA(24 * scale, 0, 0, 0, FW_DONTCARE, FALSE, FALSE, FALSE, DEFAULT_CHARSET, OUT_OUTLINE_PRECIS, CLIP_DEFAULT_PRECIS, 0, VARIABLE_PITCH, NULL); if(SelectObject(hDC, hFont) ==NULL) bSelectObject=0; SetWorldTransform(hDC, &xf); */ int* deltas = (int*)malloc(hello_string_len * 2 * sizeof(int)); for (int i = 0; i < hello_string_len; i++) { MAT2 matrix = { { 0, 1 }, { 0, 0 }, { 0, 0 }, { 0, 1 } }; GLYPHMETRICS metrics = {0}; GetGlyphOutlineW(hDC, hello_string[i], GGO_METRICS, &metrics, 0, NULL, &matrix); deltas[i * 2 + 0] = metrics.gmCellIncX * scale; deltas[i * 2 + 1] = 0; } ExtTextOutW(hDC, 32 * scale, 24 * scale, ETO_PDY, NULL, hello_string, hello_string_len, deltas); free(deltas); EndPaint(hWnd, &ps); break; } case WM_DESTROY: { PostQuitMessage(0); break; } default: { return DefWindowProc(hWnd, uMsg, wParam, lParam); } } return 0; }