From dd2778fb3289b9829d7f91e400aefd82e153be0a Mon Sep 17 00:00:00 2001 From: Brad Parker Date: Thu, 5 Jan 2017 22:17:48 -0500 Subject: [PATCH] GDI text testing --- gfx/common/win32_common.cpp | 14 -------------- gfx/drivers_font/gdi_font.c | 23 +++++++++++++++++++---- 2 files changed, 19 insertions(+), 18 deletions(-) diff --git a/gfx/common/win32_common.cpp b/gfx/common/win32_common.cpp index 4adff55e2f..82af6fe650 100644 --- a/gfx/common/win32_common.cpp +++ b/gfx/common/win32_common.cpp @@ -515,26 +515,12 @@ LRESULT CALLBACK WndProcGDI(HWND hwnd, UINT message, { LRESULT ret; bool quit = false; - PAINTSTRUCT ps; - HDC hdc; - RECT rc; - POINT aptStar[6] = {50,2, 2,98, 98,33, 2,33, 98,98, 50,2}; if (message == WM_NCLBUTTONDBLCLK) doubleclick_on_titlebar = true; switch (message) { - case WM_PAINT: - hdc = BeginPaint(hwnd, &ps); - //TextOut(hdc, 0, 0, "Hello, Windows!", 15); - GetClientRect(hwnd, &rc); - SetMapMode(hdc, MM_ANISOTROPIC); - SetWindowExtEx(hdc, 100, 100, NULL); - SetViewportExtEx(hdc, rc.right, rc.bottom, NULL); - Polyline(hdc, aptStar, 6); - EndPaint(hwnd, &ps); - return 0L; case WM_DROPFILES: case WM_SYSCOMMAND: case WM_CHAR: diff --git a/gfx/drivers_font/gdi_font.c b/gfx/drivers_font/gdi_font.c index 2ca5c627ec..e7ae5a74a1 100644 --- a/gfx/drivers_font/gdi_font.c +++ b/gfx/drivers_font/gdi_font.c @@ -17,6 +17,7 @@ #include #include +#include #ifdef HAVE_CONFIG_H #include "../../config.h" @@ -26,6 +27,10 @@ #include "../../configuration.h" #include "../../verbosity.h" #include "../common/gdi_common.h" +#include "../common/win32_common.h" + +#include +#include typedef struct { @@ -82,6 +87,8 @@ static void gdi_render_msg(void *data, const char *msg, unsigned newX, newY; settings_t *settings = config_get_ptr(); const struct font_params *params = (const struct font_params*)userdata; + HDC hdc; + HWND hwnd = win32_get_window(); if (!font || string_is_empty(msg)) return; @@ -100,15 +107,23 @@ static void gdi_render_msg(void *data, const char *msg, if (!font->gdi) return; - newX = x * width; - newY = height - (y * height); + newX = x;//x * width; + newY = y;//height - (y * height); - if (strlen(msg) + newX > width) - newX -= strlen(msg) + newX - width; + //if (strlen(msg) + newX > width) + // newX -= strlen(msg) + newX - width; //gdi_put_str(*font->gdi->gdi_cv, newX, newY, msg); //gdi_refresh_display(*font->gdi->gdi_display); + + printf("drawing text: %s at %d x %d\n", msg, newX, newY); + + hdc = GetDC(hwnd); + TextOut(hdc, newX, newY, msg, utf8len(msg)); + ReleaseDC(hwnd, hdc); + + UpdateWindow(hwnd); } static void gdi_font_flush_block(void* data)